fix(LineChart): skip lines at invalid/missing data points (don't force connect)
This commit is contained in:
parent
12f0d0d732
commit
62dbc35d3b
5
.changeset/wicked-dodos-float.md
Normal file
5
.changeset/wicked-dodos-float.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
'@portaljs/components': patch
|
||||
---
|
||||
|
||||
LineChart: break lines at invalid / missing values (don't connect if there are gaps in values).
|
||||
@ -47,11 +47,15 @@ export function LineChart({
|
||||
color: 'black',
|
||||
strokeWidth: 1,
|
||||
tooltip: true,
|
||||
invalid: "break-paths"
|
||||
},
|
||||
data: specData,
|
||||
...(isMultiYAxis
|
||||
? {
|
||||
transform: [{ fold: yAxis, as: ['key', 'value'] }],
|
||||
transform: [
|
||||
{ fold: yAxis, as: ['key', 'value'] },
|
||||
{ filter: 'datum.value != null && datum.value != ""' }
|
||||
],
|
||||
}
|
||||
: {}),
|
||||
selection: {
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
type URL = string; // Just in case we want to transform it into an object with configurations
|
||||
export interface Data {
|
||||
url?: URL;
|
||||
values?: { [key: string]: number | string }[];
|
||||
values?: { [key: string]: number | string | null | undefined }[];
|
||||
csv?: string;
|
||||
}
|
||||
|
||||
|
||||
@ -120,3 +120,42 @@ export const FromURL: Story = {
|
||||
yAxis: 'Price',
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
// export const FromURLMulti: Story = {
|
||||
// name: 'Line chart from URL Multi Column',
|
||||
// args: {
|
||||
// data: {
|
||||
// url: 'https://raw.githubusercontent.com/datasets/sea-level-rise/refs/heads/main/data/epa-sea-level.csv',
|
||||
// },
|
||||
// title: 'Sea Level Rise (1880-2023)',
|
||||
// xAxis: 'Year',
|
||||
// yAxis: ["CSIRO Adjusted Sea Level", "NOAA Adjusted Sea Level"],
|
||||
// xAxisType: 'temporal',
|
||||
// xAxisTimeUnit: 'year',
|
||||
// yAxisType: 'quantitative'
|
||||
// },
|
||||
// };
|
||||
|
||||
// export const MultipleSeriesMissingValues: Story = {
|
||||
// name: 'Line chart with missing values',
|
||||
// args: {
|
||||
// data: {
|
||||
// values: [
|
||||
// { year: '2020', seriesA: 10, seriesB: 15 },
|
||||
// { year: '2021', seriesA: 20 }, // seriesB missing
|
||||
// { year: '2022', seriesA: 15 }, // seriesB missing
|
||||
// { year: '2023', seriesB: 30 }, // seriesA missing
|
||||
// { year: '2024', seriesA: 25, seriesB: 35 },
|
||||
// { year: '2024', seriesA: 20, seriesB: 40 },
|
||||
// { year: '2024', seriesB: 45 },
|
||||
// ],
|
||||
// },
|
||||
// title: 'Handling Missing Data Points',
|
||||
// xAxis: 'year',
|
||||
// yAxis: ['seriesA', 'seriesB'],
|
||||
// xAxisType: 'temporal',
|
||||
// xAxisTimeUnit: 'year',
|
||||
// yAxisType: 'quantitative'
|
||||
// },
|
||||
// };
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user