没有内饼的Highcharts圆环图?

时间:2012-07-26 22:00:03

标签: javascript html5 highcharts donut-chart

我一直在寻找使用Highcharts库生成最简单的圆环图的解决方案。但是,Highcharts的所有示例都显示了包含内部馅饼和外部甜甜圈的图表样式(请参阅:http://www.highcharts.com/demo/pie-donut

我怎样才能摆脱内心的馅饼,只需保留外面的甜甜圈,就像其他图书馆一样? (像RGraph:http://www.rgraph.net/examples/donut.html

谢谢。

3 个答案:

答案 0 :(得分:89)

您只需要将数据提供为两个元素(键/值)数组的数组。指定innerSize以获得甜甜圈样式。

所以你的参数将包含这样的内容:

...
data: [["Firefox",6],["MSIE",4],["Chrome",7]],
innerSize: '20%',
...

这是jsFiddle of a complete example

答案 1 :(得分:2)

**I hope this example of highchat will solve your problum

http://jsfiddle.net/e2qpa/3/

$(function() {
    var chart = new Highcharts.Chart({
        chart: {
            renderTo: 'container',
            type: 'pie'
        },

        plotOptions: {
            pie: {
                borderColor: '#000000',
                innerSize: '60%'
            }
        },
        series: [{
            data: [
                ['Firefox', 44.2],
                ['IE7', 26.6],
                ['IE6', 20],
                ['Chrome', 3.1],
                ['Other', 5.4]
                ]}]
    },
    // using

    function(chart) { // on complete

        var xpos = '50%';
        var ypos = '53%';
        var circleradius = 102;

    // Render the circle
    chart.renderer.circle(xpos, ypos, circleradius).attr({
        fill: '#ddd',
    }).add();

    // Render the text
    chart.renderer.text('THIS TEXT <span style="color: red">should be in the center of the donut</span>', 155, 215).css({
            width: circleradius*2,
            color: '#4572A7',
            fontSize: '16px',
            textAlign: 'center'
      }).attr({
            // why doesn't zIndex get the text in front of the chart?
            zIndex: 999
        }).add();
    });
});

答案 2 :(得分:0)

这是最热门的搜索结果,给出的答案对我不起作用。我需要更多的控制数据点,而不仅仅是一个简单的数组。我需要使用JSON对象来配置其他选项,例如特定数据的显式颜色。我通过一些研究发现,您根本不需要修改数据格式。要将饼图制作成圆环图,只需在数据系列中设置大于0的innerSize值即可。

来自highcharts文档:

  

innerSize:内径的大小   馅饼。大于0的大小会显示圆环图。可以是一个   百分比或像素值。百分比与饼图大小有关。   像素值以整数给出。

因此,您可以获得包含以下数据的简单圆环图:

BigDecimal result = enum.getOperation().apply(t0, t1);

JS Fiddle

相关问题