awbear edited a comment on issue #9546: Only scrolling without scaling when 
using dataZoom
URL: 
https://github.com/apache/incubator-echarts/issues/9546#issuecomment-446160833
 
 
   Yes, I found this option in 
https://github.com/apache/incubator-echarts/issues/2789 and tried. It works 
without appending new data, but when adding more data all elements in chart was 
still scaled down. 
   
   Here is option:
   ```javascript
   const options = {
    dataset: {
       dimensions: ['date', 'open', 'close', 'high', 'low'],
       source: [],
     },
     dataZoom: [
       {
         type: 'inside',
         xAxisIndex: [0, 1],
         start: 50,
         end: 100,
         zoomLock: true,
       },
     ],
     xAxis: [
       {
         type: 'category',
         boundaryGap: false,
         axisLine: { lineStyle: { color: '#777' } },
         axisLabel: {
           formatter: function (value) {
             return echarts.format.formatTime('yyyy/MM', value);
           }
         },
         axisPointer: {
           label: {
             show: false,
           }
         },
         min: 'dataMin',
         max: 'dataMax',
       }, 
       {
         type: 'category',
         gridIndex: 1,
         scale: true,
         boundaryGap: false,
         splitLine: { show: false },
         axisLabel: { show: false },
         axisTick: { show: false },
         axisLine: { lineStyle: { color: '#777' } },
         splitNumber: 20,
         min: 'dataMin',
         max: 'dataMax',
         axisPointer: {
           label: {
             show: false,
           }
         },
       }
     ],
     yAxis: [
       {
         scale: true,
         splitNumber: 2,
         axisLine: { lineStyle: { color: '#777' } },
         splitLine: { show: true },
         axisTick: { show: false },
         min: 'dataMin',
         max: 'dataMax',
         axisLabel: {
           inside: true,
           formatter: '{value}\n'
         }
       },
       {
         scale: true,
         gridIndex: 1,
         splitNumber: 2,
         axisLabel: { show: false },
         axisLine: { show: false },
         axisTick: { show: false },
         splitLine: { show: false }
       }
     ],
     grid: [{
       left: 20,
       right: 20,
       top: 20,
       height: 180
     }, {
       left: 20,
       right: 20,
       height: 40,
       top: 200
     }],
     series: [
       {
         type: 'candlestick',
         encode: {
           x: 'date',
           tooltip: ['open', 'close', 'high', 'low', 'volume'],
         },
         itemStyle: {
           normal: {
             color: '#ef232a',
             color0: '#14b143',
             borderColor: '#ef232a',
             borderColor0: '#14b143'
           },
           emphasis: {
             color: 'black',
             color0: '#444',
             borderColor: 'black',
             borderColor0: '#444'
           }
         },
       },
       {
         type: 'bar',
         name: 'volume',
         tooltip: {
           show: false,
         },
         encode: {
           x: 0,
           y: 5,
         },
         xAxisIndex: 1,
         barWidth: 2,
         yAxisIndex: 1,
       }]
   }
   ```
   
   Here is update logic(simplified):
   ```javascript
   fetchData().then(resp => {
     let option = {
       dataset: {
         dimensions: ['date', 'open', 'close', 'high', 'low'],
         source: [....],
       },
     }
     option.dataset.source = prevSource.concat(resp.data)
     echarts.setOption(option)
   })
   ```
   
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@echarts.apache.org
For additional commands, e-mail: dev-h...@echarts.apache.org

Reply via email to