【问题标题】:How to add gradient color in echarts?如何在echarts中添加渐变色?
【发布时间】:2021-10-11 07:25:35
【问题描述】:

我做了一个 echart line graph。 现在,我想给它添加渐变色,如下所示:

在这个link中,它说它支持设置为渐变色。但是当我尝试按照给出的代码执行此操作时:

它给出了这个错误:

怎么办?

提前致谢。

【问题讨论】:

    标签: angular typescript echarts apache-echarts


    【解决方案1】:
      areaStyle: {
              color: new graphic.LinearGradient(0, 0, 0, 1, [
                {
                  offset: 0,
                  color: 'rgb(255, 158, 68)'
                },
                {
                  offset: 1,
                  color: 'rgb(255, 70, 131)'
                }])
            }
    

    Echart 有图形类,可以让你访问渐变属性。您可以根据需要对其进行微调,为数组中的颜色提供起点和终点。

    【讨论】:

    • 我在哪里可以得到graphic?我以前试过这个。它给出了这个错误,Cannot find name 'graphic'
    • import { graphic } from 'echarts'。图形是从 echarts 本身实例化的。
    • 非常感谢。你介意给我一个赞成票吗?
    猜你喜欢
    • 2021-10-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-13
    • 1970-01-01
    相关资源
    最近更新 更多