【问题标题】:How to change color with using anychart-core js?如何使用 anychart-core js 改变颜色?
【发布时间】:2023-02-16 16:32:46
【问题描述】:

我已经使用任何图表核心 js 库链接创建了一个动态图表 https://docs.anychart.com/

代码是

var chart = anychart.radar();
      // set chart yScale settings
      chart.yScale()
        .minimum(0)
        .maximum(10)
        .ticks({'interval':2});

       chart.yGrid().stroke({
          color: "rgba(0, 0, 0, 0.4)",
          thickness: 1,
          opacity: 1,
        });
       chart.xGrid().stroke({
         color: "rgba(0, 0, 0, 0.4)",
         thickness: 1,
         opacity: 1
       });

      // create first series
      chart.line(data1);
                  
      // set chart title
      chart.title("");

      // set container id for the chart
      chart.container('spider_graph');
      // initiate chart drawing
      chart.draw();

       // set data and adjust visualisation
      var series = chart.line(data1);

      // enable markers on series
      series.markers(true);

它也会添加标记

指针是否与线相连我想将红色更改为其他任何颜色。

如果我没有创建标记,则使用 chart.palette(["Yellow"]); 应用颜色但我想要两个具有不同颜色线的标记。

任何帮助表示赞赏。

【问题讨论】:

    标签: javascript colors marker anychart


    【解决方案1】:

    要具有不同的线条和标记颜色,您需要为标记()使用 fill()方法,并且正如您正确提到的 palette()方法为线条颜色。

    // change color for the line
    chart.palette(["Blue"]);
      
    // change color of the markers
    series.markers().fill("red");
    

    此处示例所示:https://playground.anychart.com/oEm8K8hK/4

    【讨论】:

      猜你喜欢
      • 2021-10-04
      • 1970-01-01
      • 2018-12-30
      • 1970-01-01
      • 1970-01-01
      • 2021-12-15
      • 1970-01-01
      • 1970-01-01
      • 2020-11-24
      相关资源
      最近更新 更多