Skip to content

Commit 8b97888

Browse files
committed
chore(any-chart-web): remove unreachable code
1 parent 918106c commit 8b97888

File tree

14 files changed

+157
-1146
lines changed

14 files changed

+157
-1146
lines changed

packages/customWidgets/any-chart-web/src/components/PlotlyChart.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,9 @@ class PlotlyChart extends Component<PlotlyChartProps> {
123123
});
124124
const layoutOptions = deepMerge.all([layout, getDimensionsFromNode(rootNode)]);
125125
const plotlyConfig = window.dojo && window.dojo.locale ? { ...config, locale: window.dojo.locale } : config;
126-
const logger = window.mx && window.mx.logger ? window.mx.logger : window.logger;
127-
if (logger && logger.debug) {
128-
logger.debug("newPlot", this.chartNode, chartData as Data[], layoutOptions, plotlyConfig);
129-
}
126+
127+
console.debug("newPlot", this.chartNode, chartData as Data[], layoutOptions, plotlyConfig);
128+
130129
plotly.newPlot(this.chartNode, chartData as Data[], layoutOptions, plotlyConfig).then(myPlot => {
131130
if (onClick) {
132131
myPlot.on("plotly_click", onClick as any);
Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
1-
import {
2-
CLEAR_INSTANCE_STATE,
3-
ChartData,
4-
Plotly,
5-
RESET,
6-
TOGGLE_PLOTLY_API_LOADING,
7-
TOGGLE_PLOTLY_DATA_LOADING,
8-
UPDATE_DATA
9-
} from "../reducers/PlotlyChartReducer";
1+
import { CLEAR_INSTANCE_STATE, Plotly, TOGGLE_PLOTLY_API_LOADING } from "../reducers/PlotlyChartReducer";
102

11-
export const resetState = () => ({ type: RESET });
12-
export const togglePlotlyAPILoading = (widgetID: string, loadingAPI: boolean, plotly?: Plotly) =>
13-
({ type: TOGGLE_PLOTLY_API_LOADING, widgetID, loadingAPI, plotly });
14-
export const togglePlotlyDataLoading = (widgetID: string, loadingData: boolean) =>
15-
({ type: TOGGLE_PLOTLY_DATA_LOADING, widgetID, loadingData });
16-
export const updateData = (widgetID: string, data: ChartData) => ({ type: UPDATE_DATA, widgetID, ...data });
3+
export const togglePlotlyAPILoading = (widgetID: string, loadingAPI: boolean, plotly?: Plotly) => ({
4+
type: TOGGLE_PLOTLY_API_LOADING,
5+
widgetID,
6+
loadingAPI,
7+
plotly
8+
});
179

18-
export const clearInstanceState = (instanceID: string) =>
19-
({ type: CLEAR_INSTANCE_STATE, instanceID });
10+
export const clearInstanceState = (instanceID: string) => ({ type: CLEAR_INSTANCE_STATE, instanceID });

packages/customWidgets/any-chart-web/src/package.xml

Lines changed: 0 additions & 25 deletions
This file was deleted.

packages/customWidgets/any-chart-web/src/store/SeriesReducer.ts

Lines changed: 0 additions & 156 deletions
This file was deleted.
Lines changed: 1 addition & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import { Config, Layout, Transform } from "plotly.js";
2-
import * as deepMerge from "deepmerge";
3-
import { Data } from "./namespaces";
1+
import { Config, Layout } from "plotly.js";
42

53
export const configs: SharedConfigs = {
64
layout: {
@@ -29,100 +27,7 @@ export const configs: SharedConfigs = {
2927
configuration: { displayModeBar: false, doubleClick: false }
3028
};
3129

32-
export const fetchThemeConfigs = (type: ChartType): Promise<ChartConfigs> =>
33-
new Promise<ChartConfigs>((resolve, reject) => {
34-
try {
35-
const cacheBurst = window.dojoConfig.cacheBust;
36-
window
37-
.fetch(`${window.mx.remoteUrl}com.mendix.charts.json?${cacheBurst}`)
38-
.then(response => {
39-
if (response.ok) {
40-
return response.json();
41-
}
42-
43-
return { layout: {}, configuration: {} };
44-
})
45-
.then(themeConfigs => {
46-
resolve(processChartConfigs(type, themeConfigs));
47-
})
48-
.catch(error => {
49-
console.log("An error occurred while fetching theme configs", error); // tslint:disable-line
50-
reject(error);
51-
});
52-
} catch (e) {
53-
console.log("An error occurred while fetching theme configs", e); // tslint:disable-line
54-
reject(e);
55-
}
56-
});
57-
58-
export const processChartConfigs = (type: ChartType, themeConfigs: ThemeConfigs): ChartConfigs => {
59-
const sharedLayout = themeConfigs.layout || {};
60-
const sharedConfiguration = themeConfigs.configuration || {};
61-
const { charts } = themeConfigs;
62-
if (charts) {
63-
const chartConfigs = (charts as any)[type];
64-
65-
return {
66-
layout: deepMerge.all([sharedLayout, (chartConfigs && chartConfigs.layout) || {}]),
67-
configuration: deepMerge.all([sharedConfiguration, (chartConfigs && chartConfigs.configuration) || {}]),
68-
data: (chartConfigs && chartConfigs.data) || {}
69-
};
70-
}
71-
72-
return { layout: sharedLayout, configuration: sharedConfiguration, data: {} };
73-
};
74-
75-
export const arrayOverwrite = (_destinationArray: any[], sourceArray: any[]) => sourceArray;
76-
77-
export type ChartType =
78-
| "LineChart"
79-
| "BubbleChart"
80-
| "PieChart"
81-
| "HeatMap"
82-
| "AnyChart"
83-
| "PolarChart"
84-
| "BarChart"
85-
| "AreaChart"
86-
| "TimeSeries"
87-
| "ColumnChart";
88-
8930
interface SharedConfigs {
9031
layout: Partial<Layout>;
9132
configuration: Partial<Config>;
9233
}
93-
94-
export type ChartConfigs = SharedConfigs & { data: Partial<{}> };
95-
export interface ThemeConfigs extends SharedConfigs {
96-
charts?: {
97-
LineChart?: ChartConfigs;
98-
BarChart?: ChartConfigs;
99-
ColumnChart?: ChartConfigs;
100-
TimeSeries?: ChartConfigs;
101-
AreaChart?: ChartConfigs;
102-
PieChart?: ChartConfigs;
103-
PolarChart?: ChartConfigs;
104-
HeatMap?: ChartConfigs;
105-
BubbleChart?: ChartConfigs;
106-
};
107-
}
108-
109-
export const getTransforms = (series: Data.SeriesProps, traces: Data.ScatterTrace): Transform[] | undefined => {
110-
const { aggregationType } = series;
111-
if (aggregationType !== "none" && traces) {
112-
return [
113-
{
114-
type: "aggregate",
115-
groups: traces.x,
116-
aggregations: [
117-
{
118-
target: "y",
119-
func: aggregationType,
120-
enabled: true
121-
}
122-
]
123-
} as Transform
124-
];
125-
}
126-
127-
return undefined;
128-
};

0 commit comments

Comments
 (0)