supervons / react-native-echarts-pro

A React-Native charts based on Apache ECharts, support various charts and map.
https://supervons.github.io/react-native-echarts-pro-docs/
MIT License
216 stars 33 forks source link

怎么动态设置柱形图的颜色和 折线图的区域颜色渐变 #60

Closed fefuming closed 2 years ago

fefuming commented 2 years ago

itemStyle: { color: function(params){ if(params.value>12){ return '#c20919' }else{ return '#0CF49B' } } }, 这种方式设置不生效

supervons commented 2 years ago

可以使用如下属性试试:


  lineStyle: {
    color: {
      type: "linear",
          x: 0,
          y: 0,
          x2: 0,
          y2: 1,
          colorStops: [
        {
          offset: 0,
          color: "red", // 0% 处的颜色
        },
        {
          offset: 0.5,
          color: "blue", // 100% 处的颜色
        },
      ],
    },
  }

可以参考:series-line.lineStyle

supervons commented 2 years ago

太久没回复,有新进展再沟通。