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 2022/06/06 07:41:17 UTC

[GitHub] [echarts] farhanabdmusa opened a new issue, #17158: [Bug] Custom Toolbox Feature Not Working Properly

farhanabdmusa opened a new issue, #17158:
URL: https://github.com/apache/echarts/issues/17158

   ### Version
   
   5.2.2
   
   ### Link to Minimal Reproduction
   
   _No response_
   
   ### Steps to Reproduce
   
   I have this setup chart, with data from ajax
   
   ```
   const elem = document.getElementById("jumlah-tabel-dinamis-n-subjek");
   const ch = echarts.init(elem);
   $.ajax({
       success: function(response, status, xhr) {
           if (response.status) {
               ch.setOption({
                   title: {
                       show: true,
                       text: '',
                       x: 'center',
                       y: 'top',
                       textStyle: {
                           fontSize: 16,
                           fontWeight: 'bolder',
                           fontFamily: 'Open Sans',
                           color: '#444452',
                       },
                       subtext: 'Per ' + response.date,
                       subtextStyle: {
                           fontSize: 12,
                           fontWeight: 'normal',
                           color: '#444452',
                           fontFamily: 'Open Sans',
                       }
                   },
                   series: [...],
                   toolbox: {
                       top: 'top',
                       left: 'right',
                       feature: {
                           dataView: {
                               show: true,
                               title: 'Data View',
                               lang: ['Data View (CSV)', 'Close', 'Refresh'],
                               readOnly: true,
                               icon: 'image://my-domain.com/assets/img/csv.png'
                           },
                           mySaveTool: saveTool(ch, {
                               title: {
                                   text: 'Chart Title For ' + response.district
                               }
                           }, {
                               title: {
                                   text: ''
                               }
                           }),
                           restore: {
                               show: true,
                               title: 'Refresh',
                               icon: 'image://my-domain.com/assets/img/refresh.png'
                           }
                       }
                   },
                   
               });
           }
       },
   });
   ```
   
   and i have this function to add title in chart when saving the chart as image
   ```
   var saveTool = function(c, s, b) {
       s.animation = false;
       b.animation = false;
       return {
           show: true,
           tooltip: 'Save',
           title: 'Save',
           icon: 'image://my-domain.com/assets/img/download.png',
           onclick: function(p) {
               c.setOption(s);
               window.open(c.getDataURL({
                   type: 'png',
                   pixelRatio: 5,
                   backgroundColor: '#fff',
                   excludeComponents: ['toolbox']
               }));
               c.setOption(b);
           }
       };
   }
   ```
   
   ### Current Behavior
   
   at initial state `response.district = 'District A'` so the Chart Title will be `Chart Title For District A`
   Then if i retrieve data from another District (example : District B). The chart title still `Chart Title For District A` not `Chart Title For District B`
   
   ### Expected Behavior
   
   The Chart Title should change depend on response from ajax `response.district`
   The expected result for the example is `Chart Title For District B`
   
   ### Environment
   
   ```markdown
   - OS:macOS Monterey
   - Browser: Firefox 101.0 (64-bit)
   - Framework: Codeigniter 3, Bootstrap 5, jQuery 3
   ```
   
   
   ### Any additional comments?
   
   _No response_


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org.apache.org

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