Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(declarative-chart): Create Scatter plot #33843

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Next Next commit
create scatter plot from points in line chart
  • Loading branch information
Anush2303 committed Feb 12, 2025
commit a215b78f7556d2c7ffc832a2b01770f26b6dacb8
Original file line number Diff line number Diff line change
@@ -225,17 +225,21 @@ export const DeclarativeChart: React.FunctionComponent<DeclarativeChartProps> =
);
}
case 'scatter':
if (plotlyInput.data[0].mode === 'markers') {
throw new Error(`Unsupported chart - type :${plotlyInput.data[0]?.type}, mode: ${plotlyInput.data[0]?.mode}`);
if (plotlyInput.data[0].mode === 'markers' && !isNumberArray(plotlyInput.data[0].y!)) {
throw new Error(
`Unsupported chart - type :${plotlyInput.data[0]?.type}, mode: ${plotlyInput.data[0]?.mode}
, xAxisType: String`,
);
}
const isAreaChart = plotlyInput.data.some(
(series: PlotData) => series.fill === 'tonexty' || series.fill === 'tozeroy',
);
const isScatterMarkers = plotlyInput.data[0]?.mode?.includes('markers');
const renderChartJsx = (chartProps: ILineChartProps | IAreaChartProps) => {
if (isAreaChart) {
return <AreaChart {...chartProps} />;
}
return <LineChart {...chartProps} />;
return <LineChart {...chartProps} scatterMarkersMode={isScatterMarkers} />;
};
return checkAndRenderChart(renderChartJsx, isAreaChart);
case 'heatmap':
Original file line number Diff line number Diff line change
@@ -511,6 +511,7 @@ export const transformPlotlyJsonToScatterChartProps = (
data: xValues.map((x, i: number) => ({
x: isString ? (isXDate ? new Date(x as string) : isXNumber ? parseFloat(x as string) : x) : x,
y: series.y[i],
markerSize: Array.isArray(series.marker?.size) ? series.marker.size[i] : undefined,
})),
color: lineColor,
} as ILineChartPoints;
Loading
Oops, something went wrong.