You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@echarts.apache.org by GitBox <gi...@apache.org> on 2019/01/08 02:36:07 UTC

[GitHub] pissang commented on issue #9700: Pie chart with radial gradient

pissang commented on issue #9700: Pie chart with radial gradient
URL: https://github.com/apache/incubator-echarts/issues/9700#issuecomment-452154285
 
 
   It's better to use `global` coordinates to declare the radial gradient in your scene.
   ```js
   option = {
     "color": [
       "rgb(65, 140, 240)",
       "rgb(252, 180, 65)",
       "rgb(224, 64, 10)",
       "rgb(5, 100, 146)",
     ],
     "dataset": [
       {
         "source": [
           {
             "name": "A",
             "value": 25,
           },
           {
             "name": "B",
             "value": 25,
           },
           {
             "name": "C",
             "value": 25
           },
           {
             "name": "D",
             "value": "25"
           }
         ],
       }
     ],
     "series": [
       {
         "type": "pie",
         "startAngle": 0,
         data: [
           {
             "name": "A",
             "value": 25,
           },
           {
             "name": "B",
             "value": 25,
           },
           {
             "name": "C",
             "value": 25
           },
           {
             "name": "D",
             "value": "25"
           }
         ],
         "itemStyle": {
             color: function (args) {
               var c = option.color[args.dataIndex],
                   c2 = c.replace(')', ',.8)'),
                   c3 = c.replace(')', ',.9)')
                   
               return {
                 // Use global coordinates
                 global: true,
                 type: 'radial',
                 x: myChart.getWidth() / 2, // calculate x
                 y: myChart.getHeight() / 2, // calculate y
                 r: 200,
                 colorStops: [
                   { offset: .75, color: c3 },
                   { offset: .95, color: c2 },
                   { offset: 1, color: c }
                 ]
               }
             }            
         },
       }
     ]
   }
   ```

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

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