Skip to content

Commit cb4cb38

Browse files
leonardomendixgjulivan
authored andcommitted
refactor(custom-chart-web): review feedback and add extra properties
1 parent 4a7cfa1 commit cb4cb38

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

packages/pluggableWidgets/custom-chart-web/src/controllers/ChartPropsController.ts

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -126,19 +126,31 @@ export class ChartPropsController implements ReactiveController {
126126
return (data: any): void => {
127127
if (this.props.eventDataAttribute && data.points && data.points.length > 0) {
128128
const point = data.points[0];
129-
const eventData = {
130-
curveNumber: point.curveNumber,
131-
pointNumber: point.pointNumber,
132-
pointIndex: point.pointIndex,
133-
x: point.x,
134-
y: point.y,
135-
z: point.z, // for 3D charts
136-
text: point.text,
137-
hovertext: point.hovertext,
138-
customdata: point.customdata,
139-
bbox: point.bbox
140-
};
141-
this.props.eventDataAttribute.setValue(JSON.stringify(eventData));
129+
if (point) {
130+
const { curveNumber, pointNumber, pointIndex, x, y, z, lat, lon, location, pointNumbers } = point;
131+
132+
const eventData = {
133+
// Common properties for all chart types
134+
curveNumber,
135+
pointNumber,
136+
pointIndex,
137+
138+
// Coordinate values (Cartesian 2D, 3D)
139+
x,
140+
y,
141+
z, // for 3D charts
142+
143+
// Map coordinates (geographic charts)
144+
lat,
145+
lon,
146+
location,
147+
148+
// Histogram specific properties
149+
pointNumbers
150+
};
151+
152+
this.props.eventDataAttribute.setValue(JSON.stringify(eventData));
153+
}
142154
}
143155
executeAction(this.props.onClick);
144156
};

0 commit comments

Comments
 (0)