简体   繁体   English

如何在Sencha中设置饼图的边框

[英]How to set border for a pie chart in Sencha

Hi anybody knows how to set the border for a pie chart in sencha touch? 嗨,有人知道如何在sencha touch中设置饼图的边框吗? I tried every configuration in the docs but had no luck. 我尝试了文档中的所有配置,但没有运气。

Chart series are drawn using sprites . 图表系列是使用精灵绘制的。 You can pass custom sprite attributes through the subStyle option of the serie. 您可以通过该系列的subStyle选项传递自定义精灵属性。 See the doc of sprite (and CSS canvas properties) for available property. 有关可用属性,请参见Sprite文档(和CSS画布属性)。

Note that the subStyle option expects an array of values that will be used in order for each records. 请注意, subStyle选项需要一个值数组,该值数组将按顺序用于每个记录。

Given all that, we can add borders to the docs pie chart example this way: 考虑到所有这些,我们可以通过以下方式在文档饼图示例中添加边框:

var chart = new Ext.chart.PolarChart({
    animate: true,
    interactions: ['rotate'],
    colors: ['#115fa6', '#94ae0a', '#a61120', '#ff8809', '#ffd13e'],
    store: {
        fields: ['name', 'data1', 'data2', 'data3', 'data4', 'data5'],
        data: [
            {name: 'metric one',   data1: 10, data2: 12, data3: 14, data4: 8,  data5: 13},
            {name: 'metric two',   data1: 7,  data2: 8,  data3: 16, data4: 10, data5: 3},
            {name: 'metric three', data1: 5,  data2: 2,  data3: 14, data4: 12, data5: 7},
            {name: 'metric four',  data1: 2,  data2: 14, data3: 6,  data4: 1,  data5: 23},
            {name: 'metric five',  data1: 27, data2: 38, data3: 36, data4: 13, data5: 33}
        ]
    },
    series: [{
        type: 'pie',
        label: {
            field: 'name',
            display: 'rotate'
        },
        xField: 'data3',
        donut: 30,

        // --- Modification Here! ---

        subStyle: {
            strokeStyle: ['black', 'black', 'black', 'black', 'black'],
            lineWidth: [2,2,2,2,2]
        }

        // ---

    }]
});
Ext.Viewport.setLayout('fit');
Ext.Viewport.add(chart);

Adding border only to the external part of the chart would be much more complicated, I think. 我认为,仅在图表的外部添加边框会更加复杂。

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

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