【问题标题】:JqPlot Pie Chart - Change Pie Slice ColorsJqPlot 饼图 - 更改饼图切片颜色
【发布时间】:2012-09-18 11:32:42
【问题描述】:

我有一个使用 JqPlot 显示的饼图。我有兴趣改变切片的实际颜色,到目前为止还没有运气。

我遇到了this link 并尝试了解决方案,但我不确定我是否将它放在错误的位置(已尝试将其插入代码中的几个位置),就像我将它放入时一样,饼图不再显示(实际上阻止了页面上的其余图表显示)。

这是饼图的javascript代码:

$(document).ready(function () {
        var data = [['US',33], ['IE',30], ['GB',23], ['AU',7], ['CA',4], ['RoW',7]];
        var plot1 = jQuery.jqplot('Countries', [data],
        {
            seriesDefaults: {
                // Make this a pie chart.
                renderer: jQuery.jqplot.PieRenderer,
                rendererOptions: {
                    // Put data labels on the pie slices.
                    // By default, labels show the percentage of the slice.
                    sliceMargin: 5,
                    showDataLabels: true,
                }
            },
            legend: { show: true, border: false, /*placement: 'outsideGrid', location: 'w'*/location: 'e', border: 'none' },
            grid: {borderWidth:0, shadow:false, background: '#FFFFFF'}

        }
      );
    });

有人有什么想法吗?

【问题讨论】:

标签: javascript jqplot pie-chart


【解决方案1】:

您可以将seriesColors 应用于options 对象,例如:

options =
{
    seriesColors: [ "#4bb2c5", "#c5b47f", "#EAA228", "#579575" ]
}

相关文档可以在jqPlot Options.找到

【讨论】:

  • 请注意,jqPlot 文档的“选项”部分有时可能已过时。检查标题是否有任何提供警告的内容。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-12-27
相关资源
最近更新 更多