Skip to content
Merged
Changes from 3 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
29 changes: 18 additions & 11 deletions packages/shared/charts/src/hooks/usePlotChartDataSeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { executeAction } from "@mendix/pluggable-widgets-commons";
import { MendixChartDataProps } from "../components/Chart";

type PlotChartDataPoints = {
x: Array<NonNullable<Datum>>;
y: Array<NonNullable<Datum>>;
x: Array<Datum>;
y: Array<Datum>;
hovertext: string[] | undefined;
hoverinfo: PlotData["hoverinfo"];
// We want this optional.
Expand Down Expand Up @@ -206,12 +206,16 @@ function extractDataPoints(
const x = xValue.get(item);
const y = yValue.get(item);

if (!x.value || !y.value) {
return null;
if (!x.value) {
xData.push(null);
} else {
xData.push(x.value instanceof Big ? Number(x.value.toString()) : x.value);
}
if (!y.value) {
yData.push(null);
} else {
yData.push(y.value instanceof Big ? Number(y.value.toString()) : y.value);
}

xData.push(x.value instanceof Big ? Number(x.value.toString()) : x.value);
yData.push(y.value instanceof Big ? Number(y.value.toString()) : y.value);

const tooltipHoverTextSource =
series.dataSet === "dynamic" ? series.dynamicTooltipHoverText : series.staticTooltipHoverText;
Expand Down Expand Up @@ -241,11 +245,14 @@ export function getPlotChartDataTransforms(
return [
{
type: "aggregate",
groups: dataPoints.x.map(dataPoint =>
typeof dataPoint === "string" || typeof dataPoint === "number"
groups: dataPoints.x.map(dataPoint => {
if (!dataPoint) {
return "";
}
return typeof dataPoint === "string" || typeof dataPoint === "number"
? dataPoint.toLocaleString()
: dataPoint.toLocaleDateString()
),
: dataPoint.toLocaleDateString();
}),
aggregations: [
{
target: "y",
Expand Down