我试图使用不同的图例标签,用自己的颜色代表条形系列中的每一列。正如您在屏幕截图中看到的那样,我无法让其他传奇出现。
每个都应该有不同的颜色。这是我的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 }
物种属性值应该在传说中,但我只能显示牛的价值,我也需要不同的颜色。任何帮助表示赞赏。
我有你的游乐场here。要获得Bars的多种颜色,你需要注释掉Palette
部分并在你的Bar系列中添加paletteMode="Item"
。
<BarSeries tkCartesianSeries [items]="categoricalSource"
categoryProperty="Year" paletteMode="Item" valueProperty="Amount"
seriesName="Bar" legendTitle="Cattle" showLabels="true"></BarSeries>
Legend也很好用,因为它们代表了系列类型,你可以修改每个系列的legendTitle。如果你想要多个图例,你需要添加多个Bar系列(对于你的情况下的每个牛)。