【问题标题】:jqplot set custom color for pie charts based on label namejqplot根据标签名称为饼图设置自定义颜色
【发布时间】:2015-01-22 10:35:26
【问题描述】:

为了绘制我的数据,我正在使用 jqplot。我希望我可以根据标签值在我的饼图上设置特定的颜色。 例如,我有一组标签:“木头”、“塑料”,我想将“木头”的颜色设置为棕色,并且每次该类别出现在图表中时。

这是我当前的代码:

switch(attrs.type) {
        case 'pie': return $.extend(config, {
            seriesColors:['#4bb2c5', '#EAA228', '#c5b47f', '#579575', '#839557', '#958c12', '#953579', '#4b5de4', '#d8b83f', '#ff5800', '#0085cc', '#c747a3', '#cddf54', '#FBD178', '#26B4E3', '#bd70c7'],
            seriesDefaults: {
                shadow: false,
                renderer: $.jqplot.PieRenderer,
                rendererOptions: {
                    showDataLabels: true,
                    varyBarColor: true
                },
            }
        }
        );

提前致谢!

【问题讨论】:

    标签: javascript jquery colors jqplot


    【解决方案1】:

    您可以使用dataLabelsseriesColorslabels 属性(传说中的)来实现这一点。

    请参阅下面的 jqPLot 文档

    我创建了一个小提琴。这是您正在寻找的东西吗? 请点击此链接:jqPLot Pie Chart - Series labels and colors

    问候,
    阿尼什

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多