Skip to content

Commit 49be826

Browse files
committed
chore(any-chart-web): customdata handling
Previously, this code assumed that there is an MxObject in the `customdata` field. This is not the case with AnyChart as users are able to pass `customdata` field in static configurations. This code used by other widget AnyChart shared codebase with, but they are split now. Removing this handling.
1 parent 3d3b04c commit 49be826

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

packages/customWidgets/any-chart-web/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
99
### Changed
1010

1111
- Update minimum required version of Studio Pro to 9.18.
12+
13+
### Fixed
14+
15+
- We fixed an issue with 'customdata' field causing widget to crash.

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

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -109,24 +109,12 @@ class PlotlyChart extends Component<PlotlyChartProps> {
109109
private renderChart({ config, data, layout, onClick, onHover, onRestyle }: PlotlyChartProps, plotly: Plotly) {
110110
const rootNode = this.chartNode && (this.chartNode.parentElement as HTMLDivElement);
111111
if (this.chartNode && rootNode && !this.props.loadingAPI && layout && data && Array.isArray(data) && config) {
112-
const chartData = (data as Data[]).map(data_ => {
113-
if (data_.customdata) {
114-
const customdata = data_.customdata.map(dataObject => ({
115-
entity: dataObject.getEntity() as string,
116-
guid: dataObject.getGuid() as string
117-
}));
118-
119-
return { ...data_, customdata };
120-
}
121-
122-
return { ...data_, customdata: [] };
123-
});
124112
const layoutOptions = deepMerge.all([layout, getDimensionsFromNode(rootNode)]);
125113
const plotlyConfig = window.dojo && window.dojo.locale ? { ...config, locale: window.dojo.locale } : config;
126114

127-
console.debug("newPlot", this.chartNode, chartData as Data[], layoutOptions, plotlyConfig);
115+
console.debug("newPlot", this.chartNode, data, layoutOptions, plotlyConfig);
128116

129-
plotly.newPlot(this.chartNode, chartData as Data[], layoutOptions, plotlyConfig).then(myPlot => {
117+
plotly.newPlot(this.chartNode, data as Data[], layoutOptions, plotlyConfig).then(myPlot => {
130118
if (onClick) {
131119
myPlot.on("plotly_click", onClick as any);
132120
}

0 commit comments

Comments
 (0)