Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const AreaChartCondensed = defineComponent({
description: "Filled area under lines; use for cumulative totals or volume trends over time",
component: ({ props }) => {
if (!hasAllProps(props as Record<string, unknown>, "labels", "series")) return null;
const data = buildChartData(props.labels, props.series);
const data = buildChartData(props.labels, props.series) ?? [];
if (!data.length) return null;
return React.createElement(AreaChartCondensedComponent, {
data,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const BarChartCondensed = defineComponent({
description: "Vertical bars; use for comparing values across categories with one or more series",
component: ({ props }) => {
if (!hasAllProps(props as Record<string, unknown>, "labels", "series")) return null;
const data = buildChartData(props.labels, props.series);
const data = buildChartData(props.labels, props.series) ?? [];
if (!data.length) return null;
return React.createElement(BarChartCondensedComponent, {
data,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const HorizontalBarChart = defineComponent({
description: "Horizontal bars; prefer when category labels are long or for ranked lists",
component: ({ props }) => {
if (!hasAllProps(props as Record<string, unknown>, "labels", "series")) return null;
const data = buildChartData(props.labels, props.series);
const data = buildChartData(props.labels, props.series) ?? [];
if (!data.length) return null;
return React.createElement(HorizontalBarChartComponent, {
data,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const LineChartCondensed = defineComponent({
description: "Lines over categories; use for trends and continuous data over time",
component: ({ props }) => {
if (!hasAllProps(props as Record<string, unknown>, "labels", "series")) return null;
const data = buildChartData(props.labels, props.series);
const data = buildChartData(props.labels, props.series) ?? [];
if (!data.length) return null;
return React.createElement(LineChartCondensedComponent, {
data,
Expand Down
2 changes: 1 addition & 1 deletion packages/react-ui/src/genui-lib/Charts/PieChart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const PieChart = defineComponent({
const data = labels.map((cat, i) => ({
category: cat,
value: typeof values[i] === "number" ? values[i] : 0,
}));
})) ?? [];
return React.createElement(PieChartComponent, {
data,
categoryKey: "category",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-ui/src/genui-lib/Charts/RadarChart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const RadarChart = defineComponent({
description: "Spider/web chart; use for comparing multiple variables across one or more entities",
component: ({ props }) => {
if (!hasAllProps(props as Record<string, unknown>, "labels", "series")) return null;
const data = buildChartData(props.labels, props.series);
const data = buildChartData(props.labels, props.series) ?? [];
if (!data.length) return null;
return React.createElement(RadarChartComponent, {
data,
Expand Down
2 changes: 1 addition & 1 deletion packages/react-ui/src/genui-lib/Charts/RadialChart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const RadialChart = defineComponent({
const data = labels.map((cat, i) => ({
category: cat,
value: typeof values[i] === "number" ? values[i] : 0,
}));
})) ?? [];
if (!data.length) return null;
return React.createElement(RadialChartComponent, {
data,
Expand Down
2 changes: 1 addition & 1 deletion packages/react-ui/src/genui-lib/Charts/ScatterChart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const ScatterChart = defineComponent({
};
}),
};
});
}) ?? [];
if (!data.length) return null;
return React.createElement(ScatterChartComponent, {
data,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const SingleStackedBarChart = defineComponent({
const data = labels.map((cat, i) => ({
category: cat,
value: typeof values[i] === "number" ? values[i] : 0,
}));
})) ?? [];
if (!data.length) return null;
return React.createElement(SingleStackedBarChartComponent, {
data,
Expand Down