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: endLabel color support 'auto' 'inherit' #14000

Merged
merged 2 commits into from
Jan 28, 2021
Merged
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
13 changes: 8 additions & 5 deletions src/chart/line/LineView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import {getDefaultLabel, getDefaultInterpolatedLabel} from '../helper/labelHelpe

import { getECData } from '../../util/innerStore';
import { createFloat32Array } from '../../util/vendor';
import { convertToColorString } from '../../util/format';

type PolarArea = ReturnType<Polar['getArea']>;
type Cartesian2DArea = ReturnType<Cartesian2D['getArea']>;
Expand Down Expand Up @@ -609,6 +610,8 @@ class LineView extends ChartView {
}
}
this._clipShapeForSymbol = clipShapeForSymbol;
const visualColor = getVisualGradient(data, coordSys)
susiwen8 marked this conversation as resolved.
Show resolved Hide resolved
|| data.getVisual('style')[data.getVisual('drawType')];
// Initialization animation or coordinate system changed
if (
!(polyline && prevCoordSys.type === coordSys.type && step === this._step)
Expand Down Expand Up @@ -646,7 +649,7 @@ class LineView extends ChartView {

// NOTE: Must update _endLabel before setClipPath.
if (!isCoordSysPolar) {
this._initOrUpdateEndLabel(seriesModel, coordSys as Cartesian2D);
this._initOrUpdateEndLabel(seriesModel, coordSys as Cartesian2D, convertToColorString(visualColor));
}

lineGroup.setClipPath(
Expand All @@ -668,7 +671,7 @@ class LineView extends ChartView {

// NOTE: Must update _endLabel before setClipPath.
if (!isCoordSysPolar) {
this._initOrUpdateEndLabel(seriesModel, coordSys as Cartesian2D);
this._initOrUpdateEndLabel(seriesModel, coordSys as Cartesian2D, convertToColorString(visualColor));
}

// Update clipPath
Expand Down Expand Up @@ -718,8 +721,6 @@ class LineView extends ChartView {
}
}

const visualColor = getVisualGradient(data, coordSys)
|| data.getVisual('style')[data.getVisual('drawType')];
const focus = seriesModel.get(['emphasis', 'focus']);
const blurScope = seriesModel.get(['emphasis', 'blurScope']);

Expand Down Expand Up @@ -1039,7 +1040,8 @@ class LineView extends ChartView {

_initOrUpdateEndLabel(
seriesModel: LineSeriesModel,
coordSys: Cartesian2D
coordSys: Cartesian2D,
inheritColor: string
) {
const endLabelModel = seriesModel.getModel('endLabel');

Expand All @@ -1063,6 +1065,7 @@ class LineView extends ChartView {
polyline,
getLabelStatesModels(seriesModel, 'endLabel'),
{
inheritColor,
labelFetcher: seriesModel,
labelDataIndex: dataIndex,
defaultText(dataIndex, opt, interpolatedValue) {
Expand Down
6 changes: 4 additions & 2 deletions test/line-endLabel.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.