Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/v1.3.1 #33

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"Charts",
"AnyChart"
],
"version": "1.3.0",
"version": "1.3.1",
"description": "Create charts based on the Plotly library",
"copyright": "Mendix BV",
"scripts": {
Expand Down
5 changes: 3 additions & 2 deletions src/AreaChart/AreaChart.webmodeler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ import LineChartContainerProps = Container.LineChartContainerProps;

// tslint:disable-next-line class-name
export class preview extends Component<LineChartContainerProps, { updatingData: boolean }> {
state = { updatingData: true };
readonly state = { updatingData: true };
private instanceID = getInstanceID(this.props.friendlyId, store, "scatter");
private scatterData = this.getData(this.props);

render() {
const alertMessage = validateSeriesProps(
Expand All @@ -35,7 +36,7 @@ export class preview extends Component<LineChartContainerProps, { updatingData:
updatingData: this.state.updatingData,
toggleUpdatingData: this.toggleUpdatingData,
fill: true,
scatterData: this.getData(this.props),
scatterData: this.scatterData,
themeConfigs: { layout: {}, configuration: {}, data: {} },
instanceID: this.instanceID
})
Expand Down
5 changes: 3 additions & 2 deletions src/BarChart/BarChart.webmodeler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ import BarChartContainerProps = Container.BarChartContainerProps;

// tslint:disable-next-line class-name
export class preview extends Component<BarChartContainerProps, { updatingData: boolean }> {
state = { updatingData: true };
readonly state = { updatingData: true };
private instanceID = getInstanceID(this.props.friendlyId, store, "bar");
private scatterData = preview.getData(this.props);

render() {
const alertMessage = validateSeriesProps(
Expand All @@ -36,7 +37,7 @@ export class preview extends Component<BarChartContainerProps, { updatingData: b
toggleUpdatingData: this.toggleUpdatingData,
instanceID: this.instanceID,
orientation: "bar",
scatterData: preview.getData(this.props),
scatterData: this.scatterData,
themeConfigs: { layout: {}, configuration: {}, data: {} }
})
);
Expand Down
47 changes: 41 additions & 6 deletions src/BarChart/components/BarChartDataHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ export type BarChartDataHandlerProps = ComponentProps & BarChartInstanceState &
export class BarChartDataHandler extends Component<BarChartDataHandlerProps> {
private subscriptionHandles: number[] = [];
private intervalID?: number;
private isRunningAction = false;
private showProgress?: number;

readonly onStopActionbound = this.onStopAction.bind(this);

render() {
return createElement("div", { className: "widget-charts-wrapper" },
Expand Down Expand Up @@ -113,12 +117,27 @@ export class BarChartDataHandler extends Component<BarChartDataHandlerProps> {
}

private onClick = (options: Data.OnClickOptions<{ x: string, y: number }, Data.SeriesProps>) => {
if (options.mxObject) {
handleOnClick(options.options, options.mxObject, options.mxForm);
} else if (options.trace) {
this.createDataPoint(options.options, options.trace)
.then(mxObject => handleOnClick(options.options, mxObject, options.mxForm))
.catch(error => mx.ui.error(`An error occured while creating ${options.options.dataEntity} object: ${error}`));
if (!this.isRunningAction) {
this.onStartAction();
if (options.mxObject) {
handleOnClick(options.options, options.mxObject, options.mxForm)
.then(this.onStopActionbound)
.catch((error) => {
mx.ui.error(error);
this.onStopActionbound();
});
} else if (options.trace) {
this.createDataPoint(options.options, options.trace)
.then(mxObject => {
handleOnClick(options.options, mxObject, options.mxForm)
.then(this.onStopActionbound)
.catch((error) => {
mx.ui.error(error);
this.onStopActionbound();
});
})
.catch(error => mx.ui.error(`An error occured while creating ${options.options.dataEntity} object: ${error}`));
}
}
}

Expand Down Expand Up @@ -150,6 +169,22 @@ export class BarChartDataHandler extends Component<BarChartDataHandlerProps> {
window.clearInterval(this.intervalID);
this.intervalID = undefined;
}

private onStartAction() {
this.isRunningAction = true;
setTimeout(() => {
if (this.isRunningAction) {
this.showProgress = mx.ui.showProgress();
}
} , 120);
}

private onStopAction() {
this.isRunningAction = false;
if (this.showProgress) {
mx.ui.hideProgress(this.showProgress);
}
}
}

const mapStateToProps: MapStateToProps<BarChartInstanceState, ComponentProps, ReduxStore> = (state, props) =>
Expand Down
5 changes: 3 additions & 2 deletions src/BubbleChart/BubbleChart.webmodeler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ import LineChartContainerProps = Container.LineChartContainerProps;

// tslint:disable-next-line class-name
export class preview extends Component<LineChartContainerProps, { updatingData: boolean }> {
state = { updatingData: true };
readonly state = { updatingData: true };
private instanceID = getInstanceID(this.props.friendlyId, store, "scatter");
private scatterData = preview.getData(this.props);

render() {
const alertMessage = validateSeriesProps(
Expand All @@ -36,7 +37,7 @@ export class preview extends Component<LineChartContainerProps, { updatingData:
updatingData: this.state.updatingData,
toggleUpdatingData: this.toggleUpdatingData,
instanceID: this.instanceID,
scatterData: preview.getData(this.props),
scatterData: this.scatterData,
themeConfigs: { layout: {}, configuration: {}, data: {} }
})
);
Expand Down
5 changes: 3 additions & 2 deletions src/ColumnChart/ColumnChart.webmodeler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ import BarChartContainerProps = Container.BarChartContainerProps;

// tslint:disable-next-line class-name
export class preview extends Component<BarChartContainerProps, { updatingData: boolean }> {
state = { updatingData: true };
readonly state = { updatingData: true };
private instanceID = getInstanceID(this.props.friendlyId, store, "bar");
private scatterData = this.getData(this.props);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When new series are added in the WM will they all have new data?


render() {
const alertMessage = validateSeriesProps(
Expand All @@ -35,7 +36,7 @@ export class preview extends Component<BarChartContainerProps, { updatingData: b
updatingData: this.state.updatingData,
toggleUpdatingData: this.toggleUpdatingData,
instanceID: this.instanceID,
scatterData: this.getData(this.props),
scatterData: this.scatterData,
themeConfigs: { layout: {}, configuration: {}, data: {} }
})
);
Expand Down
10 changes: 6 additions & 4 deletions src/HeatMap/HeatMap.webmodeler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ import HeatMapContainerProps = Container.HeatMapContainerProps;

// tslint:disable-next-line class-name
export class preview extends Component<HeatMapContainerProps, { updatingData: boolean }> {
state = { updatingData: true };
readonly state = { updatingData: true };
private instanceID = getInstanceID(this.props.friendlyId, store, "heatmap");
private scatterData = deepMerge.all([
getDefaultDataOptions(this.props as HeatMapProps),
preview.getData(this.props)
]) as HeatMapData;

render() {
const alertMessage = validateSeriesProps(
Expand All @@ -37,9 +41,7 @@ export class preview extends Component<HeatMapContainerProps, { updatingData: bo
instanceID: this.instanceID,
themeConfigs: { layout: {}, configuration: {}, data: {} },
devMode: this.props.devMode === "developer" ? "advanced" : this.props.devMode,
heatmapData: deepMerge.all(
[ getDefaultDataOptions(this.props as HeatMapProps), preview.getData(this.props) ]
) as HeatMapData
heatmapData: this.scatterData
})
);
}
Expand Down
40 changes: 37 additions & 3 deletions src/HeatMap/components/HeatMapDataHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ export type HeatMapDataHandlerProps = ComponentProps & HeatMapState & Actions;
class HeatMapDataHandler extends Component<HeatMapDataHandlerProps> {
private subscriptionHandles: number[] = [];
private intervalID?: number;
private isRunningAction = false;
private showProgress?: number;
readonly onStopActionbound = this.onStopAction.bind(this);

render() {
return createElement("div", { className: "widget-charts-wrapper" },
Expand Down Expand Up @@ -121,13 +124,27 @@ class HeatMapDataHandler extends Component<HeatMapDataHandlerProps> {
}

private handleOnClick = (options: Data.OnClickOptions<{ x: string, y: string, z: number }, HeatMapContainerProps>) => {
if (options.trace) {
if (!this.isRunningAction && options.trace) {
this.onStartAction();
const mxObject = this.findSourceObject(options.trace.x, options.trace.y, options.trace.z);

if (mxObject) {
handleOnClick(options.options, mxObject, options.mxForm);
handleOnClick(options.options, options.mxObject, options.mxForm)
.then(this.onStopActionbound)
.catch((error) => {
mx.ui.error(error);
this.onStopActionbound();
});
} else {
this.createDataPoint(options.options, options.trace)
.then(newMxObject => handleOnClick(options.options, newMxObject, options.mxForm))
.then(newMxObject => {
handleOnClick(options.options, newMxObject, options.mxForm)
.then(this.onStopActionbound)
.catch(error => {
mx.ui.error(error);
this.onStopActionbound();
});
})
.catch(error => mx.ui.error(`An error occured while creating ${options.options.dataEntity} object: ${error}`));
}
}
Expand Down Expand Up @@ -168,6 +185,23 @@ class HeatMapDataHandler extends Component<HeatMapDataHandlerProps> {
Number(data.get(this.props.valueAttribute)) === z
);
}

private onStartAction() {
this.isRunningAction = true;
setTimeout(() => {
if (this.isRunningAction) {
this.showProgress = mx.ui.showProgress();
}
} , 120);
}

private onStopAction() {
this.isRunningAction = false;
if (this.showProgress) {
mx.ui.hideProgress(this.showProgress);
}

}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove empty line

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

}

const mapStateToProps: MapStateToProps<HeatMapState, ComponentProps, ReduxStore> = (state, props) =>
Expand Down
5 changes: 3 additions & 2 deletions src/LineChart/LineChart.webmodeler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ import LineChartContainerProps = Container.LineChartContainerProps;

// tslint:disable-next-line class-name
export class preview extends Component<LineChartContainerProps, { updatingData: boolean }> {
state = { updatingData: true };
readonly state = { updatingData: true };
private instanceID = getInstanceID(this.props.friendlyId, store, "scatter");
private scatterData = preview.getData(this.props);

render() {
const alertMessage = validateSeriesProps(
Expand All @@ -35,7 +36,7 @@ export class preview extends Component<LineChartContainerProps, { updatingData:
fetchingData: false,
updatingData: this.state.updatingData,
toggleUpdatingData: this.toggleUpdatingData,
scatterData: preview.getData(this.props),
scatterData: this.scatterData,
themeConfigs: { layout: {}, configuration: {}, data: {} },
instanceID: this.instanceID
})
Expand Down
47 changes: 41 additions & 6 deletions src/LineChart/components/LineChartDataHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export type LineChartDataHandlerProps = ComponentProps & LineChartInstanceState
export class LineChartDataHandler extends Component<LineChartDataHandlerProps> {
private subscriptionHandles: number[] = [];
private intervalID?: number;
private isRunningAction = false;
private showProgress?: number;
private typeMapping: { [ key in Container.ScatterTypes ]: ChartType } = {
line: "LineChart",
area: "AreaChart",
Expand All @@ -34,6 +36,8 @@ export class LineChartDataHandler extends Component<LineChartDataHandlerProps> {
polar: "PolarChart"
};

readonly onStopActionbound = this.onStopAction.bind(this);

render() {
return createElement("div", { className: "widget-charts-wrapper" },
createElement(LineChart, {
Expand Down Expand Up @@ -120,12 +124,27 @@ export class LineChartDataHandler extends Component<LineChartDataHandlerProps> {
}

private onClick = (options: Data.OnClickOptions<{ x: string, y: number }, Data.SeriesProps>) => {
if (options.mxObject) {
handleOnClick(options.options, options.mxObject, options.mxForm);
} else if (options.trace) {
this.createDataPoint(options.options, options.trace)
.then(mxObject => handleOnClick(options.options, mxObject, options.mxForm))
.catch(error => mx.ui.error(`An error occured while creating ${options.options.dataEntity} object: ${error}`));
if (!this.isRunningAction) {
this.onStartAction();
if (options.mxObject) {
handleOnClick(options.options, options.mxObject, options.mxForm)
.then(this.onStopActionbound)
.catch((error) => {
mx.ui.error(error);
this.onStopActionbound();
});
} else if (options.trace) {
this.createDataPoint(options.options, options.trace)
.then(mxObject => {
handleOnClick(options.options, mxObject, options.mxForm)
.then(this.onStopActionbound)
.catch((error) => {
mx.ui.error(error);
this.onStopActionbound();
});
})
.catch(error => mx.ui.error(`An error occured while creating ${options.options.dataEntity} object: ${error}`));
}
}
}

Expand Down Expand Up @@ -157,6 +176,22 @@ export class LineChartDataHandler extends Component<LineChartDataHandlerProps> {
window.clearInterval(this.intervalID);
this.intervalID = undefined;
}

private onStartAction() {
this.isRunningAction = true;
setTimeout(() => {
if (this.isRunningAction) {
this.showProgress = mx.ui.showProgress();
}
} , 120);
}

private onStopAction() {
this.isRunningAction = false;
if (this.showProgress) {
mx.ui.hideProgress(this.showProgress);
}
}
}

const mapStateToProps: MapStateToProps<LineChartInstanceState, ComponentProps, ReduxStore> = (state, props) =>
Expand Down
5 changes: 3 additions & 2 deletions src/PieChart/PieChart.webmodeler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ import PieChartContainerProps = Container.PieChartContainerProps;

// tslint:disable-next-line class-name
export class preview extends Component<PieChartContainerProps, { updatingData: boolean }> {
state = { updatingData: true };
readonly state = { updatingData: true };
private instanceID = getInstanceID(this.props.friendlyId, store, "pie");
private scatterData = preview.getData(this.props);

render() {
const alertMessage = validateSeriesProps(
Expand All @@ -35,7 +36,7 @@ export class preview extends Component<PieChartContainerProps, { updatingData: b
toggleUpdatingData: this.toggleUpdatingData,
instanceID: this.instanceID,
devMode: this.props.devMode === "developer" ? "advanced" : this.props.devMode,
pieData: preview.getData(this.props),
pieData: this.scatterData,
themeConfigs: { layout: {}, configuration: {}, data: {} }
})
);
Expand Down
Loading