hoangv edited a comment on issue #11322: Bar chart pick the wrong data in 
dataset.
URL: 
https://github.com/apache/incubator-echarts/issues/11322#issuecomment-568119522
 
 
   @icetimidus I spent some time studying this bug and reading [the 
documentation](https://www.echartsjs.com/en/option.html#dataset.source).  It 
appears the library allows the option to specify the dimensions for 
dataset.source.  When not explicitly specified, it makes a best-effort to 
detect dimensions on its own.  In the minimum example, it uses the first data 
point, which unfortunately happens to be the one missing GSWY dimension.  It 
would be inefficient for the library to scan all the data points in order to 
auto-detect all potential dimensions when it can be provided by developer up 
front. It seems reasonable to first check the data and dimensions beforehand.  
If not possible, there are a couple options. 
   
   1) In the minimal example, reverse the order of dataset.source so the first 
data point contains all the dimensions.  For example:
   
   ```
       "dataset": {
           "source": [
               {
                   "timestamp": 1568191140000,
                   "ECM": 1666775.3333333333,
                   "GSWY": 1332.5333333333333,
               },
               {
                   "timestamp": 1568191020000,
                   "ECM": 26311.466666666667,
               },
           ]
   ```
   2) If not, try explicitly specifying all dimensions in option.series
   
   ```
       "series": [{
               "type": "bar",
               "name": "ECM",
               "dimensions": ['timestamp','ECM','GSWY'],
               "encode": {
                   "x": "timestamp",
                   "y": "ECM"
               },
               "stack": "one",
               "itemStyle": {
                   "normal": {
                       "color": "#2ec7c9"
                   }
               }
           },
           {
               "type": "bar",
               "name": "GSWY",
               "dimensions": ['timestamp','ECM','GSWY'],
               "encode": {
                   "x": "timestamp",
                   "y": "GSWY"
               },
               "stack": "one",
               "itemStyle": {
                   "normal": {
                       "color": "#97b552"
                   }
               }
           }
       ],
   ```
   
   Hope this helps.  Cc. @Ovilia 
   
   
   

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to