mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-26 10:49:38 +02:00
axis calculation fixed
This commit is contained in:
@@ -113,13 +113,12 @@ function setYAxisRangeData(min: number, max: number) {
|
||||
|
||||
// this function does not set `hasSetYAxis` as there can be multiple data so we should calculate the range accordingly
|
||||
function setYAxisRangeFromPlotData(data: number[], plotType: PlotType) {
|
||||
if (plotType === PlotType.BAR) {
|
||||
dataSets.push(data);
|
||||
|
||||
let sum = new Array(data.length).fill(0);
|
||||
const sum = new Array(data.length).fill(0);
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
for (let dataSetIndex = 0; dataSetIndex < dataSets.length; dataSetIndex++) {
|
||||
sum[i] += dataSets[dataSetIndex][i];
|
||||
for (const entry of dataSets) {
|
||||
sum[i] += entry[i];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,18 +128,6 @@ function setYAxisRangeFromPlotData(data: number[], plotType: PlotType) {
|
||||
min: isLinearAxisData(xyChartData.yAxis) ? xyChartData.yAxis.min : Math.min(...sum),
|
||||
max: Math.max(...sum),
|
||||
};
|
||||
} else if (plotType === PlotType.LINE) {
|
||||
const minValue = Math.min(...data);
|
||||
const maxValue = Math.max(...data);
|
||||
const prevMinValue = isLinearAxisData(xyChartData.yAxis) ? xyChartData.yAxis.min : Infinity;
|
||||
const prevMaxValue = isLinearAxisData(xyChartData.yAxis) ? xyChartData.yAxis.max : -Infinity;
|
||||
xyChartData.yAxis = {
|
||||
type: 'linear',
|
||||
title: xyChartData.yAxis.title,
|
||||
min: Math.min(prevMinValue, minValue),
|
||||
max: Math.max(prevMaxValue, maxValue),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function transformDataWithoutCategory(data: number[], plotType: PlotType): SimplePlotDataType {
|
||||
|
Reference in New Issue
Block a user