0

我正在尝试使用不同的图例标签,它们自己的颜色代表条形系列中的每一列。正如您在屏幕截图中看到的那样,我无法让其他图例出现。 在此处输入图像描述

每个人都应该有不同的颜色。这是我的html。

            <CategoricalAxis tkCartesianHorizontalAxis allowPan="true" allowZoom="true"></CategoricalAxis>
            <LinearAxis tkCartesianVerticalAxis allowPan="true"></LinearAxis>

            <BarSeries tkCartesianSeries [items]="LivestockData"
                categoryProperty="Year" valueProperty="Amount" seriesName="Bar" showLabels="true" legendTitle="Cattle"></BarSeries>

            <!-- >> chart-legend-angular-definition -->                   
            <RadLegendView tkCartesianLegend position="Bottom" title="Species"
                height="150" enableSelection="true"></RadLegendView>                    

            <!-- << chart-angular-styling-bars -->
            <Palette tkCartesianPalette seriesName="Bar">
                <PaletteEntry tkCartesianPaletteEntry fillColor="#A05BC5"></PaletteEntry>
            </Palette>

        </RadCartesianChart>

这是正在显示的数据。

    { species: "Cattle", Amount: 4771, Year: 1980 },
    { species: "Sheep and goats", Amount: 3862, Year: 2000 },
    { species: "Pigs", Amount: 187, Year: 2002 },
    { species: "Poultry", Amount: 2941, Year: 1990 }

物种属性值应该在传说中,但我只能显示牛的价值,而且我还需要不同的颜色。任何帮助表示赞赏。

4

1 回答 1

0

我在这里为你准备了游乐场。要使条具有多种颜色,您需要注释掉该Palette部分并将其添加到paletteMode="Item"您的条系列中。

<BarSeries tkCartesianSeries [items]="categoricalSource"
            categoryProperty="Year" paletteMode="Item" valueProperty="Amount"
            seriesName="Bar" legendTitle="Cattle" showLabels="true"></BarSeries>

Legend 也可以正常工作,因为它们代表系列类型,您可以修改每个系列的 legendTitle。如果您想要多个图例,则需要添加多个 Bar 系列(针对您案例中的每只牛。)

于 2019-03-05T05:07:53.063 回答