mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
PieChart: Fix sorting for null values in piechart (#39516)
* Fix sorting for null values in piechart Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com>
This commit is contained in:
parent
b891af935a
commit
4a6e354497
@ -87,7 +87,15 @@ function getLegend(props: Props, displayValues: FieldDisplay[]) {
|
|||||||
|
|
||||||
const legendItems = displayValues
|
const legendItems = displayValues
|
||||||
// Since the pie chart is always sorted, let's sort the legend as well.
|
// Since the pie chart is always sorted, let's sort the legend as well.
|
||||||
.sort((a, b) => b.display.numeric - a.display.numeric)
|
.sort((a, b) => {
|
||||||
|
if (isNaN(a.display.numeric)) {
|
||||||
|
return 1;
|
||||||
|
} else if (isNaN(b.display.numeric)) {
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
return b.display.numeric - a.display.numeric;
|
||||||
|
}
|
||||||
|
})
|
||||||
.map<VizLegendItem>((value, idx) => {
|
.map<VizLegendItem>((value, idx) => {
|
||||||
const hidden = value.field.custom.hideFrom.viz;
|
const hidden = value.field.custom.hideFrom.viz;
|
||||||
const display = value.display;
|
const display = value.display;
|
||||||
|
Loading…
Reference in New Issue
Block a user