简体   繁体   English

Apex 图表范围栏颜色

[英]Apex Charts Range Bar Colors

Can you use a color array for range charts?您可以将颜色数组用于范围图吗? I grabbed the same array that worked in a bar chart, but the colors are ignored in a range bar chart.我抓住了在条形图中工作的相同数组,但在范围条形图中忽略了颜色。

Most of the examples out there show you how to set the color of a series.大多数示例都向您展示了如何设置系列的颜色。 With the range chart, you end up with 1 series and multiple groups by default.使用范围图表,默认情况下您会得到 1 个系列和多个组。 However, you can set the color of individual items within a series too.但是,您也可以设置系列中单个项目的颜色。

Go to the App Galery and install the Sample Charts app.转到 App Galery 并安装示例图表应用程序。 Go to page 23 (the Range Chart) page, drill into the Attributes of the Range region, and scroll down until you see JavaScript Initialization Code.转到第 23 页(Range Chart)页面,深入到 Range 区域的 Attributes,然后向下滚动直到看到 JavaScript Initialization Code。 Add this function there:在那里添加这个函数:

function( options ){
  options.dataFilter = function( data ) {
    data.series[0].items[0].color = "#0B6623";
    data.series[0].items[1].color = "#9DC183";
    data.series[0].items[2].color = "#708238";
    data.series[0].items[3].color = "#C7EA46";
    data.series[0].items[4].color = "#3F704D";

    return data;
  };

  return options;
}

When you run the page you'll see that each item has a different color:当您运行该页面时,您会看到每个项目都有不同的颜色:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM