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

tweak(line): tweak default line bolder logic. #14448

Closed
wants to merge 2 commits into from
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
5 changes: 1 addition & 4 deletions src/chart/line/LineSeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,7 @@ class LineSeriesModel extends SeriesModel<LineSeriesOption> {
},

emphasis: {
scale: true,
lineStyle: {
width: 'bolder'
}
scale: true
},
// areaStyle: {
// origin of areaStyle. Valid values:
Expand Down
31 changes: 27 additions & 4 deletions src/chart/line/LineView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -736,10 +736,7 @@ class LineView extends ChartView {

setStatesStylesFromModel(polyline, seriesModel, 'lineStyle');

if (polyline.style.lineWidth > 0 && seriesModel.get(['emphasis', 'lineStyle', 'width']) === 'bolder') {
const emphasisLineStyle = polyline.getState('emphasis').style;
emphasisLineStyle.lineWidth = polyline.style.lineWidth + 1;
}
this._bolderLine(polyline, seriesModel, ecModel);

// Needs seriesIndex for focus
getECData(polyline).seriesIndex = seriesModel.seriesIndex;
Expand Down Expand Up @@ -1171,6 +1168,32 @@ class LineView extends ChartView {
}
}

/**
* To determine if the line should be bolder
*
* TODO:
* It's better to disable bolder when data is large,
* but it seems no simple way to figure out.
*/
_bolderLine(polyline: ECPolyline, seriesModel: LineSeriesModel, ecModel: GlobalModel) {
if (polyline.style.lineWidth > 0) {
// only make line bolder when there is more than one series and `emphasis.focus` is enabled
// or the user manually specify `lineStyle.width` as `bolder`
// see https://github.com/apache/echarts/pull/13501
const emphasisLineWidth = seriesModel.get(['emphasis', 'lineStyle', 'width']);
const focus = seriesModel.get(['emphasis', 'focus']);
if (emphasisLineWidth === 'bolder'
|| (emphasisLineWidth == null
&& (focus && focus !== 'none')
// PENDING: only line series?
&& ecModel.getSeriesCount() > 1)
) {
const emphasisLineStyle = polyline.getState('emphasis').style;
emphasisLineStyle.lineWidth = polyline.style.lineWidth + 1;
}
}
}

/**
* @private
*/
Expand Down