You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@echarts.apache.org by Per Franck <pe...@gmail.com> on 2021/11/14 18:04:46 UTC
workable solution for slider zooming log charts
If anyone needs dataZoom for log charts, this is a workable solution,
unless there's a better way, i'd love some feedback.
1. create a dummy yAxis following your other 'real' axis
*options.yAxis = [*
* {id:"logyaxis", type:"log" ... },*
* {type:"value"}*
*]*
2. create a slider dataZoom targeting the dummy yAxis, but *not *a dataZoom
for the actual axis
*{ name: "logzoom", yAxisIndex: n, type: "slider" ... } *
(i wish this could be done with a yAxisId instead)
3. handle the datazoom event of the chart
and adjust max/min of the axis instead
*function scaleToLog(scale){*
* // play with the f(x) parameters here return 1e-20 * Math.pow(10,
scale/1.5)}*
*g_chart.on("datazoom",function(params){*
* if ( params.dataZoomId == "logzoom" ){*
* startValue = scaleToLog(params.start) endValue =
scaleToLog(params.end) g_chart.setOption({ yAxis:{*
* id: "logyaxis",*
* min: startValue, max: endValue } })*
* }*
*})*