You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by GitBox <gi...@apache.org> on 2020/04/20 21:22:24 UTC

[GitHub] [incubator-echarts] melanke edited a comment on issue #6202: Problems when updating chart through echartsInstance.setOption()

melanke edited a comment on issue #6202:
URL: https://github.com/apache/incubator-echarts/issues/6202#issuecomment-616815917


   ```typescript
   get chartOptions() {
       return {
         grid: { right: 25, left: '10%', top: '5%' },
         tooltip: { trigger: 'axis' },
         textStyle: {
           color: !this.isPrinting ? '#666' : '#000',
         },
         xAxis: {
           type: 'category',
         },
         yAxis: {
           type: 'value',
           axisLine: { show: false },
           splitLine: { lineStyle: { opacity: 0.1 } },
           boundaryGap: false,
         },
         color: this.value.orderedColors,
       }
     }
   
     @Watch('value.chartData')
     @Watch('value.chartType')
     @Watch('value.itensRFU')
     @Watch('value.colorsMap', { deep: true })
     @Watch('value.graphics', { deep: true })
     @Watch('dataZoom')
     @Watch('drawingState.graphicBeingBuilt')
     @Watch('drawingState.graphicBeingBuilt.text')
     updateChartData() {
       if (!this.echart) {
         return
       }
   
       const typeConfig = (index = 0) => {
         const type = this.value.chartType
   
         if (type.$id === ChartType.LINE) {
           return {
             type: 'line',
             smooth: true,
           }
         } else if (type.$id === ChartType.BAR) {
           return {
             type: 'bar',
             smooth: true,
             stack: '-',
           }
         } else if (type.$id === ChartType.AREA) {
           return {
             type: 'line',
             smooth: true,
             areaStyle: {
               color: this.value.getColorByIndex(index),
             },
           }
         }
   
         return {}
       }
   
       let series = this.value.itensRFU.map((d, i) => typeConfig(i))
   
       if (this.startIndexLimiter === -1 || this.endIndexLimiter === -1) {
         error('system.error.noData')
         series = []
       }
   
       const option = {
         ...this.chartOptions, // echarts bug: we need to merge manually instead of merging on setOptions
         dataset: {
           source: this.value.chartData,
         },
         series,
         dataZoom: this.dataZoom,
         graphic: this.buildChartGraphics(),
       }
   
       this.echart.setOption(option, true)
     }
   ```
   
   @Rushan4eg I am using Vue as well, but I don't think it makes any difference


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org