From 2420ac32514c45f87ba31bbe7e6c87f60c5e54a4 Mon Sep 17 00:00:00 2001 From: vargburz Date: Wed, 3 Nov 2021 17:31:50 +0300 Subject: [PATCH] update demo with an examples of zoomin/zoomout --- examples/demo.html | 7 ++++--- examples/demo_live.html | 9 ++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/examples/demo.html b/examples/demo.html index cdf57d0..30dad1e 100755 --- a/examples/demo.html +++ b/examples/demo.html @@ -15,11 +15,12 @@ const data1 = Array.from({ length: arrayLength }, (el, idx) => [startTime + idx * 10000, Math.floor(Math.random() * 40)]); const data2 = Array.from({ length: arrayLength }, (el, idx) => [startTime + idx * 10000, Math.floor(Math.random() * 100)]); const data3 = Array.from({ length: arrayLength }, (el, idx) => [startTime + idx * 10000, Math.floor(Math.random() * 20) + 90]); - const zoomIn = (ranges) => { pod.render(); } - const zoomOut = (ranges) => { pod.state.xValueRange = [startTime, startTime + arrayLength * 10000]; pod.render(); } + const zoomIn = (ranges) => { const xRange = ranges[0]; options.axis.x.range = xRange; pod.updateData(undefined, options); } + const zoomOut = (ranges) => { options.axis.x.range = [startTime, startTime + arrayLength * 10000]; pod.updateData(undefined, options); } + const panningEnd = (ranges) => { const xRange = ranges[0]; options.axis.x.range = xRange; pod.updateData(undefined, options); } let options = { renderLegend: false, usePanning: false, axis: { y: { invert: false, range: [0, 350] }, x: { format: 'time' } }, - eventsCallbacks: { zoomIn: zoomIn, zoomOut } + eventsCallbacks: { zoomIn: zoomIn, zoomOut, panningEnd } } var pod = new LinePod( document.getElementById('chart'), diff --git a/examples/demo_live.html b/examples/demo_live.html index 2c9a4d9..0e1e625 100755 --- a/examples/demo_live.html +++ b/examples/demo_live.html @@ -14,10 +14,13 @@