简体   繁体   English

EXTJS中不同面板中饼图和图例的连接方法

[英]How to connect piechart and legend in different panels in EXTJS

Hello I am making a piechart in EXTJS. The legends of these charts are not displaying properly they are being cut off.您好,我正在 EXTJS 制作饼图。这些图表的图例显示不正确,它们被截断了。 Therefore i am making a piechart in one panel and just under that i am making another panel which would contain the legends.因此,我在一个面板中制作了一个饼图,而在其下方我正在制作另一个包含图例的面板。

My question is how do I connect the pie chart in one panel and showing the legend of this pie chart in another panel.我的问题是如何在一个面板中连接饼图并在另一个面板中显示该饼图的图例。

I am using EXTJS 4.2我正在使用 EXTJS 4.2

I am made 2 panels one is under the other in a vbox positioning.我制作了 2 个面板,一个在 vbox 定位中的另一个下方。

To connect a pie chart and its legend in different panels in ExtJS, you can use the following steps:要在 ExtJS 中的不同面板中连接饼图及其图例,可以使用以下步骤:

Create two panels, one for the pie chart and one for the legend.创建两个面板,一个用于饼图,一个用于图例。

In the pie chart panel, create a pie chart using the Ext.chart.PolarChart class.在饼图面板中,使用 Ext.chart.PolarChart class 创建一个饼图。

In the legend panel, create a legend using the Ext.chart.legend.SpriteLegend class.在图例面板中,使用 Ext.chart.legend.SpriteLegend class 创建一个图例。

Use the "series" config property in the legend to specify the series associated with the pie chart.使用图例中的“系列”配置属性来指定与饼图关联的系列。

Set the "docked" config property of the legend panel to "bottom" or "right" to dock it to the bottom or right of the pie chart panel.将图例面板的“停靠”配置属性设置为“底部”或“右侧”以将其停靠在饼图面板的底部或右侧。

Ext.define('MyApp.view.PieChartWithLegend', {
    extend: 'Ext.container.Container',
    xtype: 'piechartwithlegend',

    layout: {
        type: 'hbox',
        align: 'stretch'
    },

    items: [{
        xtype: 'polar',
        width: 500,
        height: 500,
        store: {
            fields: ['name', 'data1'],
            data: [{
                name: 'Item 1',
                data1: 14
            }, {
                name: 'Item 2',
                data1: 16
            }, {
                name: 'Item 3',
                data1: 14
            }, {
                name: 'Item 4',
                data1: 20
            }]
        },
        series: [{
            type: 'pie',
            xField: 'data1',
            donut: 30,
            highlight: true,
            style: {
                stroke: 'black',
                miterLimit: 1,
                lineCap: 'miter',
                lineWidth: 1
            },
            label: {
                field: 'name',
                display: 'rotate',
                contrast: true,
                font: '18px Arial'
            }
        }]
    }, {
        xtype: 'container',
        width: 100,
        layout: 'fit',
        items: [{
            xtype: 'spritelegend',
            docked: 'bottom',
            series: [{
                type: 'pie',
                store: {
                    fields: ['name', 'data1'],
                    data: [{
                        name: 'Item 1',
                        data1: 14
                    }, {
                        name: 'Item 2',
                        data1: 16
                    }, {
                        name: 'Item 3',
                        data1: 14
                    }, {
                        name: 'Item 4',
                        data1: 20
                    }]
                },
                label: {
                    field: 'name'
                }
            }]
        }]
    }]
});

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

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