首页 > 解决方案 > 当一个值为总值的 100% 时,PieSeries 仅显示细线而不是完整的切片颜色

问题描述

我遇到了 RadPieChart 和 PieSeries 的奇怪行为。

当一个值代表总数的 100% 时,PieSeries 仅显示一条细线。

编辑:这里是 Playground 演示的链接,如果您想在您的设备上试用它 - https://play.nativescript.org/?template=play-ng&id=ZxmuR5&v=2

或者如果你想在你的设备上测试它,你可以使用我的 github 项目的这个链接:https ://github.com/VukMNE/PieSeriesMalfunction

如果我的描述不清楚,下面是图片来说明我面临的问题。第一张图片显示了 PieSeries 的常规行为,第二张图片显示了有问题的行为。

Bellow 是在我的应用程序中正常工作的普通饼图示例。有两个切片,它们都充满了颜色。

普通饼图

但是如果一个值等于总量,而不是显示一个充满颜色的切片,它只显示一条细线。

在此处输入图像描述

两个图表的代码是相同的。这些图表是动态的,它们根据用户的参数显示不同的数据。但是,下面是两个图表的代码。

<RadPieChart *ngIf="!noDataFound" tkExampleTitle tkToggleNavButton minHeight="200" allowAnimation="true" row="0">
        <PieSeries tkPieSeries
            seriesName="collectPie"
            selectionMode="None"
            expandRadius="0.4"
            outerRadiusFactor="0.7"
            valueProperty="amountCollected"
            legendLabel="nameForLabel"
            showLabels="true"
            showPercentage="false"
            [items]="pieSourceCollected">
            <PointLabelStyle tkPieLabelStyle margin="15" textFormat="%.2f €"></PointLabelStyle>
        </PieSeries>
        <Palette tkPiePalette seriesName="collectPie">
            <PaletteEntry tkPiePaletteEntry fillColor="#1B998B" strokeColor="#1B998B"></PaletteEntry>
            <PaletteEntry tkPiePaletteEntry fillColor="#97C8EB" strokeColor="#97C8EB"></PaletteEntry>
            <PaletteEntry tkPiePaletteEntry fillColor="#001F54" strokeColor="#001F54"></PaletteEntry>
            <PaletteEntry tkPiePaletteEntry fillColor="#2B193D" strokeColor="#2B193D"></PaletteEntry>
            <PaletteEntry tkPiePaletteEntry fillColor="#484D6D" strokeColor="#484D6D"></PaletteEntry>
            <PaletteEntry tkPiePaletteEntry fillColor="#2C365E" strokeColor="#2C365E"></PaletteEntry>
        </Palette>
        <RadLegendView tkPieLegend position="Top" width="100%"></RadLegendView>
      </RadPieChart>

第二张图表的代码:

<RadPieChart *ngIf="!noDataFound" tkExampleTitle tkToggleNavButton minHeight="200" allowAnimation="true" row="0">
        <PieSeries tkPieSeries
            seriesName="collectPie"
            selectionMode="None"
            expandRadius="0.4"
            outerRadiusFactor="0.7"
            valueProperty="amountSpent"
            legendLabel="nameForLabel"
            showLabels="true"
            showPercentage="false"
            [items]="pieSourceSpent">
            <PointLabelStyle tkPieLabelStyle margin="15" textFormat="%.2f €"></PointLabelStyle>
        </PieSeries>
        <Palette tkPiePalette seriesName="collectPie">
            <PaletteEntry tkPiePaletteEntry fillColor="#1B998B" strokeColor="#1B998B"></PaletteEntry>
            <PaletteEntry tkPiePaletteEntry fillColor="#97C8EB" strokeColor="#97C8EB"></PaletteEntry>
            <PaletteEntry tkPiePaletteEntry fillColor="#001F54" strokeColor="#001F54"></PaletteEntry>
            <PaletteEntry tkPiePaletteEntry fillColor="#2B193D" strokeColor="#2B193D"></PaletteEntry>
            <PaletteEntry tkPiePaletteEntry fillColor="#484D6D" strokeColor="#484D6D"></PaletteEntry>
            <PaletteEntry tkPiePaletteEntry fillColor="#2C365E" strokeColor="#2C365E"></PaletteEntry>
        </Palette>    
        <RadLegendView tkPieLegend position="Top" width="100%"></RadLegendView>
      </RadPieChart>

我什至尝试通过删除等于零的值来过滤图表的数据源,但错误仍然存​​在。它应该显示一个完整的馅饼,而不是这条细线,不是吗?

在此处输入图像描述

标签: nativescriptangular2-nativescript

解决方案


推荐阅读