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

fix: use precision defaults only when markline type is average #15324

Closed
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
2 changes: 1 addition & 1 deletion src/component/marker/MarkLineModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class MarkLineModel extends MarkerModel<MarkLineOption> {
//symbolRotate: 0,
symbolOffset: 0,

precision: 2,
// precision: 2,
tooltip: {
trigger: 'item'
},
Expand Down
13 changes: 9 additions & 4 deletions src/component/marker/MarkLineView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import * as numberUtil from '../../util/number';
import * as markerHelper from './markerHelper';
import LineDraw from '../../chart/helper/LineDraw';
import MarkerView from './MarkerView';
import {getStackedDimension} from '../../data/helper/dataStackHelper';
import { getStackedDimension } from '../../data/helper/dataStackHelper';
import { CoordinateSystem, isCoordinateSystemType } from '../../coord/CoordinateSystem';
import MarkLineModel, { MarkLine2DDataItemOption, MarkLineOption } from './MarkLineModel';
import { ScaleDataValue, ColorString } from '../../util/types';
Expand Down Expand Up @@ -111,7 +111,12 @@ const markLineTransform = function (
mlFrom.coord[baseIndex] = -Infinity;
mlTo.coord[baseIndex] = Infinity;

const precision = mlModel.get('precision');
let precision = mlModel.get('precision');

if (mlType === 'average' && precision === undefined) {
precision = 2;
}

if (precision >= 0 && typeof value === 'number') {
value = +value.toFixed(Math.min(precision, 20));
}
Expand Down Expand Up @@ -186,7 +191,7 @@ function markLineFilter(
if (
fromCoord && toCoord
&& (ifMarkLineHasOnlyDim(1, fromCoord, toCoord, coordSys)
|| ifMarkLineHasOnlyDim(0, fromCoord, toCoord, coordSys))
|| ifMarkLineHasOnlyDim(0, fromCoord, toCoord, coordSys))
) {
return true;
}
Expand Down Expand Up @@ -442,7 +447,7 @@ function createList(coordSys: CoordinateSystem, seriesModel: SeriesModel, mlMode
seriesModel.getData().mapDimension(coordDim)
) || {};
// In map series data don't have lng and lat dimension. Fallback to same with coordSys
return defaults({name: coordDim}, info);
return defaults({ name: coordDim }, info);
});
}
else {
Expand Down
Loading