簡體   English   中英

在RadCharts中使用本機腳本角度為每個欄顯示不同的圖例

[英]Showing different legends for each bar in RadCharts with nativescript angular

我嘗試使用不同的圖例標簽和自己的顏色來代表條形圖中的每一列。 正如您在屏幕快照中看到的那樣,我無法顯示其他圖例。 在此處輸入圖片說明

每個都應具有不同的顏色。 這是我的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 }

物種屬性值應該在圖例中,但我只能顯示牛的值,並且每種顏色也需要不同的顏色。 任何幫助表示贊賞。

這里有操場供您使用。 要使paletteMode="Item"具有多種顏色,您需要注釋掉“ Palette部分,並在paletteMode="Item"條形系列paletteMode="Item"中添加paletteMode="Item"

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

Legend也可以正常工作,因為它們表示系列類型,您可以修改每個系列的legendTitle。 如果需要多個圖例,則需要添加多個Bar系列(對於您的情況下的每頭牛)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM