You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by "luojiandan (via GitHub)" <gi...@apache.org> on 2024/01/31 14:54:37 UTC

[I] [Bug] Bar chart with legend issue [echarts]

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

   ### Version
   
   5.4.3
   
   ### Link to Minimal Reproduction
   
   Bar chart with legend issue
   
   ### Steps to Reproduce
   
   Code:
   
   `
   //test data
   var arrDatas = [
     {
       name: 'Ronaldo',
       sport: 'Football',
       salary: 1.36
     },
     {
       name: 'Messi',
       sport: 'Football',
       salary: 1.3
     },
     {
       name: 'Mbappe',
       sport: 'Football',
       salary: 1.2
     },
     {
       name: 'James',
       sport: 'Basketball',
       salary: 1.19
     },
     {
       name: 'Alvarez',
       sport: 'Boxing',
       salary: 1.1
     },
     {
       name: 'Johnson',
       sport: 'Golf',
       salary: 1.07
     },
     {
       name: 'Federer',
       sport: 'Tennis',
       salary: 0.95
     }
   ];
   //color data
   var colors = {
     Basketball: '#D09726',
     Football: '#27D0B3',
     Tennis: '#267FCF',
     Golf: '#4CF53E',
     Boxing: '#D02F27'
   };
   option = {
     xAxis: {
       type: 'category',
       axisLabel:{
         interval:0,  //show all
       },
       data: arrDatas.map((item) => item.name +'('+ item.sport+')')
     },
     yAxis: {
       type: 'value'
     },
     legend: {},
     series: [
       {
         name:'sport',
         type: 'bar',
         data: arrDatas.map((item) => ({
           value: item.salary,
           itemStyle: {
             color: colors[item.sport]  //color
           }
         }))
       }
     ]
   };
   
   
   `
   
   ### Current Behavior
   
   **1.create bar chart like this:**
   [Example Code](https://echarts.apache.org/examples/zh/editor.html?c=bar-data-color&code=PTAuFMGdQAgEwIagQKAG4IE4y5gIkgpDALwwDaKMMA3ldTAHYIC24AXDAOQBKA9swA2cPlwA09apAAOfTKE5cAYnz6gARgkGDxkmJC1YAnpwCMAOgDMANnoBfCdToMmrDtwCyUSAEtdLmTkFbhU1TW1_BgNBYzMre0daPWY2RQ9NaWlwSKlZeUVQjS0dRKlDTBMYCwAmBPpnBhT3LgApN0gc_TzgrgAhIgBrcCKI0v1yyotTAE46p2S3RQBBQQxMcAAvTsD87l6-AA8fRgBzbYm40zmklybFFr4AC0ZIAW3uxQBxPkEAM3OYhU4gAGADs1wa1DuIXAcHA60w7yCigAKuBGIwfB0xtFYjBgeZpgBWewoAC6AG4UCAAMY_OTwQjoLAwOmCOTEMgNfqQIYjQSKADEeGB01B1WskUK4QF3EF1VBIt6lkiaIxWKFEtBSgAwkpIt8_kKACx6omWACikX2R1OQpF1SUCq4KDsVL40lAPgEpBuMAOSyOkE4kJgoCMWUUNKQ4BOciMnQQQYAMgh1OABaHqMcIJgMALgWJqCBII8-AB3HDaPQOPSIZCcXAEZCQcwsBDSAAUnZ8EBYAEpSAA-GC98AscxNGAAai4na409HffMO1As_7XH71yMgY1fuo4cj3HzAFdstdBLH0XAQ7WpPCfFBOJQXFnXKkuKvOgeI81NIixmoesEEbTB8EIVt2y7Hs-0HEgR07N9qFPdwxwnXEKkAhg0IAZXDS8Qz0FxqDZOROFIzBIHINCV26Mli2ACiiIYOxmLsfstxcVjqDJV0KSAA)
   
   **2.the default legend is not right**
   It only show one color:
   ![image](https://github.com/apache/echarts/assets/5663556/32874417-5584-4afd-9d46-5282f953c69a)
   
   **but not show color by sport name.**
   `
   //color data
   var colors = {
       Basketball: '#D09726',
       Football: '#27D0B3',
       Tennis: '#267FCF',
       Golf: '#4CF53E',
       Boxing: '#D02F27'
   };
   
   `
   
   ### Expected Behavior
   
   Show legend by colors data.
   
   ### Environment
   
   ```markdown
   - OS:
   - Browser:
   - Framework:
   ```
   
   
   ### 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


Re: [I] [Bug] Bar chart with legend issue [echarts]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #19581:
URL: https://github.com/apache/echarts/issues/19581#issuecomment-3829325886

   This issue has been automatically marked as stale because it did not have recent activity. It will be closed in 7 days if no further activity occurs. If you wish not to mark it as stale, please leave a comment in this issue.


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

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


Re: [I] [Bug] Bar chart with legend issue [echarts]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #19581:
URL: https://github.com/apache/echarts/issues/19581#issuecomment-3865485275

   This issue has been automatically closed because it did not have recent activity. If this remains to be a problem with the latest version of Apache ECharts, please open a new issue and link this to it. Thanks!


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

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


Re: [I] [Bug] Bar chart with legend issue [echarts]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed issue #19581: [Bug] Bar chart with legend issue
URL: https://github.com/apache/echarts/issues/19581


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

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


Re: [I] [Bug] Bar chart with legend issue [echarts]

Posted by "MatthiasMert (via GitHub)" <gi...@apache.org>.
MatthiasMert commented on issue #19581:
URL: https://github.com/apache/echarts/issues/19581#issuecomment-1919314155

   If [legend data](https://echarts.apache.org/en/option.html#legend.data) is not supplied it is populated with series names. So put one series per sport name and it will show up correctly.


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

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