From d9d1b5e501b639afc04239bfcad60760d1b85d07 Mon Sep 17 00:00:00 2001 From: glitch4347 Date: Mon, 18 Dec 2023 14:44:33 +0100 Subject: [PATCH 1/3] example with mouse over and refactor react component events --- examples/mouse.html | 31 +++++++++++++++++++++++ react/ChartwerkLinePod.tsx | 52 +------------------------------------- 2 files changed, 32 insertions(+), 51 deletions(-) create mode 100755 examples/mouse.html diff --git a/examples/mouse.html b/examples/mouse.html new file mode 100755 index 0000000..6657099 --- /dev/null +++ b/examples/mouse.html @@ -0,0 +1,31 @@ + + + + + + + + + +
+ + + + diff --git a/react/ChartwerkLinePod.tsx b/react/ChartwerkLinePod.tsx index 16e0cdb..f0db6e3 100644 --- a/react/ChartwerkLinePod.tsx +++ b/react/ChartwerkLinePod.tsx @@ -1,6 +1,4 @@ import { LineTimeSerie, LineOptions, LinePod } from '@chartwerk/line-pod'; - -import { AxisRange } from '@chartwerk/core/dist/types'; import { MarkersConf } from '@chartwerk/line-pod/dist/models/marker'; import { SegmentSerie } from '@chartwerk/line-pod/dist/models/segment'; @@ -16,18 +14,6 @@ export type ChartwerkLinePodProps = { markersConf?: MarkersConf, segments?: SegmentSerie[], className?: string; - // TODO: callback types should be exported from chartwerk - onZoomIn?: (ranges: AxisRange[]) => void; - onZoomOut?: (centers: { x: number, y: number }) => void; - onMouseMove?: (event: any) => void; - onMouseOut?: () => void; - onLegendClick?: (idx: number) => void, - onPanning?: (event: { ranges: AxisRange[], d3Event: any }) => void; - onPanningEnd?: (ranges: AxisRange[]) => void; - onContextMenu?: (evt: any) => void; - onSharedCrosshairMove?: (evt: any) => void; - onRenderStart?: () => void, - onRenderEnd?: () => void, } export function ChartwerkLinePod(props: ChartwerkLinePodProps) { @@ -49,48 +35,12 @@ export function ChartwerkLinePod(props: ChartwerkLinePodProps) { useEffect(() => { if(chart === null) { return; } - - let eventsCallbacks = _.cloneDeep(props.options?.eventsCallbacks || {}); - if (props.onZoomIn) { - eventsCallbacks.zoomIn = props.onZoomIn; - } - if (props.onZoomOut) { - eventsCallbacks.zoomOut = props.onZoomOut; - } - if (props.onMouseMove) { - eventsCallbacks.mouseMove = props.onMouseMove; - } - if (props.onMouseOut) { - eventsCallbacks.mouseOut = props.onMouseOut; - } - if (props.onLegendClick) { - eventsCallbacks.onLegendClick = props.onLegendClick; - } - if (props.onPanning) { - eventsCallbacks.panning = props.onPanning; - } - if (props.onPanningEnd) { - eventsCallbacks.panningEnd = props.onPanningEnd; - } - if (props.onContextMenu) { - eventsCallbacks.contextMenu = props.onContextMenu; - } - if (props.onSharedCrosshairMove) { - eventsCallbacks.sharedCrosshairMove = props.onSharedCrosshairMove; - } - if (props.onRenderStart) { - eventsCallbacks.renderStart = props.onRenderStart; - } - if(pod === null) { const newPod = new LinePod( // @ts-ignore chart, props.series, - { - ...props.options, - eventsCallbacks - }, + props.options, props.markersConf, props.segments ); From d66da50c1a131844068f26c65502640362c51e25 Mon Sep 17 00:00:00 2001 From: glitch4347 Date: Mon, 18 Dec 2023 14:47:35 +0100 Subject: [PATCH 2/3] rm line --- examples/mouse.html | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/mouse.html b/examples/mouse.html index 6657099..c07dc80 100755 --- a/examples/mouse.html +++ b/examples/mouse.html @@ -3,7 +3,6 @@ - From 79b759569fb9edbc8cf88ccaf9fd589dc07719a5 Mon Sep 17 00:00:00 2001 From: glitch4347 Date: Mon, 18 Dec 2023 14:48:55 +0100 Subject: [PATCH 3/3] simpler example --- examples/mouse.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/mouse.html b/examples/mouse.html index c07dc80..74ccd21 100755 --- a/examples/mouse.html +++ b/examples/mouse.html @@ -7,7 +7,6 @@
-