Skip to content

Commit

Permalink
Merge pull request #1193 from merico-dev/1192-yaxismininterval-of-car…
Browse files Browse the repository at this point in the history
…tesian-is-wrong-when-all-numbers-are-zero-and-group_by_key-is-set

1192 yaxismininterval of cartesian is wrong when all numbers are zero and group by key is set
  • Loading branch information
GerilLeto authored Sep 19, 2023
2 parents d2bfcd5 + d9d9cb6 commit 3e99040
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 10 deletions.
2 changes: 1 addition & 1 deletion api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@devtable/api",
"version": "10.34.5",
"version": "10.34.6",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion dashboard/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@devtable/dashboard",
"version": "10.34.5",
"version": "10.34.6",
"license": "Apache-2.0",
"publishConfig": {
"access": "public",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,41 @@
import _ from 'lodash';
import { ICartesianChartConf, IYAxisConf } from '../type';

type SeriesData = number[];
type SeriesDataOut = number[];
type SeriesDataIn = [string | number, number][] | SeriesDataOut;
type PartialSeriesConfType = {
yAxisIndex: number;
data: SeriesData;
data: SeriesDataIn;
};

function getNumbersFromData(seriesData: SeriesDataIn): SeriesDataOut {
try {
if (Array.isArray(seriesData[0]) && seriesData[0]?.length >= 2) {
const s = seriesData as [string | number, number][];
return s.map((d) => Number(d[1]));
}

return [...seriesData] as SeriesDataOut;
} catch (error) {
console.error(error);
return [...seriesData] as SeriesDataOut;
}
}

function getReduceIntervalNeeds(series: PartialSeriesConfType[]) {
if (series.length === 0) {
return {};
}

const ret: Record<string, number> = {};
const datas: Record<number, SeriesData> = {};
const datas: Record<number, SeriesDataOut> = {};
series.forEach((s) => {
const data = getNumbersFromData(s.data);
if (!datas[s.yAxisIndex]) {
datas[s.yAxisIndex] = [...s.data];
datas[s.yAxisIndex] = data;
return;
}
datas[s.yAxisIndex] = datas[s.yAxisIndex].concat(s.data);
datas[s.yAxisIndex] = datas[s.yAxisIndex].concat(data);
});

Object.entries(datas).forEach(([index, data]) => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@devtable/root",
"version": "10.34.5",
"version": "10.34.6",
"private": true,
"workspaces": [
"api",
Expand Down
2 changes: 1 addition & 1 deletion settings-form/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@devtable/settings-form",
"version": "10.34.5",
"version": "10.34.6",
"license": "Apache-2.0",
"publishConfig": {
"access": "public",
Expand Down
2 changes: 1 addition & 1 deletion website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@devtable/website",
"private": true,
"license": "Apache-2.0",
"version": "10.34.5",
"version": "10.34.6",
"scripts": {
"dev": "vite",
"preview": "vite preview"
Expand Down

0 comments on commit 3e99040

Please sign in to comment.