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


With regards,
Apache Git Services

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

Reply via email to