Skip to content

feat(theme): new theme for ECharts 6.0 #20865

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

Merged
merged 31 commits into from
Jun 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4c9428b
feat: new theme color
Ovilia Mar 26, 2025
1b19b82
design: gray tokens
Ovilia Mar 27, 2025
6fdd2be
design: colors using tokens
Ovilia Mar 28, 2025
294ed78
feat: update theme
Ovilia Mar 31, 2025
17a3bad
feat: first round color all changed
Ovilia Apr 1, 2025
5f0184b
Merge branch 'v6' into feat-theme
Ovilia Apr 8, 2025
6629fb2
feat: update dataZoom theme
Ovilia Apr 9, 2025
3898955
fix: adjust themes
Ovilia Apr 23, 2025
c88e9f7
feat: update themes
Ovilia Apr 24, 2025
74ddbde
fix: fix unit test cases
Ovilia Apr 25, 2025
e23ed44
feat(theme): use containDataZoom to avoid overlap
Ovilia May 8, 2025
230ca04
fix(theme): adjust grid, legend, tokens
Ovilia May 8, 2025
f3c93a6
fix(theme): revert containDataZoom and update theme
Ovilia May 8, 2025
8fd6cd4
fix(theme): remove comment
Ovilia May 9, 2025
731aac4
feat(theme): add dark theme
Ovilia May 12, 2025
0882edd
feat(theme): remove light colorLayer
Ovilia May 12, 2025
7b34b19
fix(theme): update according to the pr review
Ovilia May 20, 2025
77826be
fix: update styles
Ovilia May 23, 2025
f9b2a82
chore(theme): support theme in visual test
Ovilia May 26, 2025
8005bc3
test: support using theme in visual test
Ovilia May 27, 2025
f74b153
feat(theme): WIP v5 theme
Ovilia May 27, 2025
88d658a
fix(theme): update v5 theme
Ovilia May 28, 2025
e7867e1
chore(test): support mark diff as expected
Ovilia May 29, 2025
bd4d965
Merge branch 'v6' into feat-theme
Ovilia May 29, 2025
c448109
test(theme): fix test cases of v6
Ovilia May 30, 2025
acf99c7
chore: fix visual test
Ovilia Jun 4, 2025
21d4124
fix: remove an unintentionally added test case
Ovilia Jun 4, 2025
4181b3f
chore: merge v6
Ovilia Jun 4, 2025
72f92ba
chore(test): fix default actual source
Ovilia Jun 4, 2025
3c33ba5
chore: remove unintentionally added files
Ovilia Jun 4, 2025
a1d61c2
chore: remove unintentionally added import
Ovilia Jun 4, 2025
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
4 changes: 3 additions & 1 deletion src/chart/bar/BarSeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import type Polar from '../../coord/polar/Polar';
import { inheritDefaultOption } from '../../util/component';
import SeriesData from '../../data/SeriesData';
import { BrushCommonSelectorsForSeries } from '../../component/brush/selector';
import tokens from '../../visual/tokens';

export type PolarBarLabelPosition = SeriesLabelOption['position']
| 'start' | 'insideStart' | 'middle' | 'end' | 'insideEnd';
Expand Down Expand Up @@ -155,7 +156,8 @@ class BarSeriesModel extends BaseBarSeriesModel<BarSeriesOption> {

select: {
itemStyle: {
borderColor: '#212121'
borderColor: tokens.color.primary,
borderWidth: 2
}
},

Expand Down
9 changes: 8 additions & 1 deletion src/chart/bar/BaseBarSeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ export interface BaseBarSeriesOption<StateOption, ExtraStateOption extends State
*/
barGap?: string | number

/**
* @private
*/
defaultBarGap?: string | number

/**
* Gap between each category. Default to be 20%. can be an absolute pixel value.
*/
Expand Down Expand Up @@ -199,7 +204,9 @@ class BaseBarSeriesModel<Opts extends BaseBarSeriesOption<unknown> = BaseBarSeri
large: false,
largeThreshold: 400,
progressive: 3e3,
progressiveChunkMode: 'mod'
progressiveChunkMode: 'mod',

defaultBarGap: '10%'
};
}

Expand Down
3 changes: 2 additions & 1 deletion src/chart/bar/PictorialBarSeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
} from '../../util/types';
import type Cartesian2D from '../../coord/cartesian/Cartesian2D';
import { inheritDefaultOption } from '../../util/component';
import tokens from '../../visual/tokens';

export interface PictorialBarStateOption {
itemStyle?: ItemStyleOption
Expand Down Expand Up @@ -169,7 +170,7 @@ class PictorialBarSeriesModel extends BaseBarSeriesModel<PictorialBarSeriesOptio

select: {
itemStyle: {
borderColor: '#212121'
borderColor: tokens.color.primary
}
}
});
Expand Down
5 changes: 3 additions & 2 deletions src/chart/boxplot/BoxplotSeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
import type Axis2D from '../../coord/cartesian/Axis2D';
import Cartesian2D from '../../coord/cartesian/Cartesian2D';
import { mixin } from 'zrender/src/core/util';
import tokens from '../../visual/tokens';

// [min, Q1, median (or Q2), Q3, max]
type BoxplotDataValue = OptionDataValueNumeric[];
Expand Down Expand Up @@ -111,7 +112,7 @@ class BoxplotSeriesModel extends SeriesModel<BoxplotSeriesOption> {
boxWidth: [7, 50],

itemStyle: {
color: '#fff',
color: tokens.color.neutral00,
borderWidth: 1
},

Expand All @@ -123,7 +124,7 @@ class BoxplotSeriesModel extends SeriesModel<BoxplotSeriesOption> {
shadowBlur: 5,
shadowOffsetX: 1,
shadowOffsetY: 1,
shadowColor: 'rgba(0,0,0,0.2)'
shadowColor: tokens.color.shadow
}
},

Expand Down
3 changes: 2 additions & 1 deletion src/chart/custom/CustomView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ import {
} from '../../animation/customGraphicKeyframeAnimation';
import type SeriesModel from '../../model/Series';
import { getCustomSeries } from './customSeriesRegister';
import tokens from '../../visual/tokens';

const EMPHASIS = 'emphasis' as const;
const NORMAL = 'normal' as const;
Expand Down Expand Up @@ -809,7 +810,7 @@ function makeRenderItem(
visualColor != null && (itemStyle.fill = visualColor);
opacity != null && (itemStyle.opacity = opacity);

const opt = {inheritColor: isString(visualColor) ? visualColor : '#000'};
const opt = {inheritColor: isString(visualColor) ? visualColor : tokens.color.neutral99};
const labelModel = getLabelModel(dataIndexInside, NORMAL);
// Now that the feature of "auto adjust text fill/stroke" has been migrated to zrender
// since ec5, we should set `isAttached` as `false` here and make compat in
Expand Down
7 changes: 4 additions & 3 deletions src/chart/funnel/FunnelSeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {
} from '../../util/types';
import GlobalModel from '../../model/Global';
import SeriesData from '../../data/SeriesData';
import tokens from '../../visual/tokens';

type FunnelLabelOption = Omit<SeriesLabelOption, 'position'> & {
position?: LabelOption['position']
Expand Down Expand Up @@ -154,7 +155,7 @@ class FunnelSeriesModel extends SeriesModel<FunnelSeriesOption> {
left: 80,
top: 60,
right: 80,
bottom: 60,
bottom: 65,
// width: {totalWidth} - left - right,
// height: {totalHeight} - top - bottom,

Expand Down Expand Up @@ -182,7 +183,7 @@ class FunnelSeriesModel extends SeriesModel<FunnelSeriesOption> {
},
itemStyle: {
// color: 各异,
borderColor: '#fff',
borderColor: tokens.color.neutral00,
borderWidth: 1
},
emphasis: {
Expand All @@ -192,7 +193,7 @@ class FunnelSeriesModel extends SeriesModel<FunnelSeriesOption> {
},
select: {
itemStyle: {
borderColor: '#212121'
borderColor: tokens.color.primary
}
}
};
Expand Down
11 changes: 8 additions & 3 deletions src/chart/funnel/FunnelView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,17 @@ class FunnelPiece extends graphic.Polygon {
} }
);

const labelModel = itemModel.getModel('label');
const labelColor = labelModel.get('color');
const overrideColor = labelColor === 'inherit'
? visualColor
: null;

polygon.setTextConfig({
local: true,
inside: !!labelLayout.inside,
insideStroke: visualColor,
// insideFill: 'auto',
outsideFill: visualColor
insideStroke: overrideColor,
outsideFill: overrideColor
});

const linePoints = labelLayout.linePoints;
Expand Down
21 changes: 11 additions & 10 deletions src/chart/gauge/GaugeSeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
} from '../../util/types';
import GlobalModel from '../../model/Global';
import SeriesData from '../../data/SeriesData';
import tokens from '../../visual/tokens';

// [percent, color]
type GaugeColorStop = [number, ColorString];
Expand Down Expand Up @@ -218,7 +219,7 @@ class GaugeSeriesModel extends SeriesModel<GaugeSeriesOption> {
show: true,
roundCap: false,
lineStyle: { // 属性lineStyle控制线条样式
color: [[1, '#E6EBF8']],
color: [[1, tokens.color.neutral10]],
width: 10
}
},
Expand All @@ -240,7 +241,7 @@ class GaugeSeriesModel extends SeriesModel<GaugeSeriesOption> {
distance: 10,
// 属性lineStyle(详见lineStyle)控制线条样式
lineStyle: {
color: '#63677A',
color: tokens.color.axisTick,
width: 3,
type: 'solid'
}
Expand All @@ -256,7 +257,7 @@ class GaugeSeriesModel extends SeriesModel<GaugeSeriesOption> {
distance: 10,
// 属性lineStyle控制线条样式
lineStyle: {
color: '#63677A',
color: tokens.color.axisTickMinor,
width: 1,
type: 'solid'
}
Expand All @@ -265,7 +266,7 @@ class GaugeSeriesModel extends SeriesModel<GaugeSeriesOption> {
show: true,
distance: 15,
// formatter: null,
color: '#464646',
color: tokens.color.axisLabel,
fontSize: 12,
rotate: 0
},
Expand All @@ -286,9 +287,9 @@ class GaugeSeriesModel extends SeriesModel<GaugeSeriesOption> {
offsetCenter: [0, 0],
keepAspect: false,
itemStyle: {
color: '#fff',
color: tokens.color.neutral00,
borderWidth: 0,
borderColor: '#5470c6'
borderColor: tokens.color.theme[0]
}
},

Expand All @@ -297,23 +298,23 @@ class GaugeSeriesModel extends SeriesModel<GaugeSeriesOption> {
// x, y,单位px
offsetCenter: [0, '20%'],
// 其余属性默认使用全局文本样式,详见TEXTSTYLE
color: '#464646',
color: tokens.color.secondary,
fontSize: 16,
valueAnimation: false
},
detail: {
show: true,
backgroundColor: 'rgba(0,0,0,0)',
backgroundColor: tokens.color.transparent,
borderWidth: 0,
borderColor: '#ccc',
borderColor: tokens.color.neutral40,
width: 100,
height: null, // self-adaption
padding: [5, 10],
// x, y,单位px
offsetCenter: [0, '40%'],
// formatter: null,
// 其余属性默认使用全局文本样式,详见TEXTSTYLE
color: '#464646',
color: tokens.color.primary,
fontSize: 30,
fontWeight: 'bold',
lineHeight: 30,
Expand Down
6 changes: 4 additions & 2 deletions src/chart/graph/GraphSeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import { createTooltipMarkup } from '../../component/tooltip/tooltipMarkup';
import { defaultSeriesFormatTooltip } from '../../component/tooltip/seriesFormatTooltip';
import {initCurvenessList, createEdgeMapForCurveness} from '../helper/multipleGraphEdgeHelper';
import Thumbnail, { ThumbnailOption } from './Thumbnail';
import tokens from '../../visual/tokens';


type GraphDataValue = OptionDataValue | OptionDataValue[];
Expand Down Expand Up @@ -496,7 +497,8 @@ class GraphSeriesModel extends SeriesModel<GraphSeriesOption> {
itemStyle: {},

lineStyle: {
color: '#aaa',
// Don't use tokens.color.border because of the opacity
color: tokens.color.neutral50,
width: 1,
opacity: 0.5
},
Expand All @@ -509,7 +511,7 @@ class GraphSeriesModel extends SeriesModel<GraphSeriesOption> {

select: {
itemStyle: {
borderColor: '#212121'
borderColor: tokens.color.primary
}
},

Expand Down
11 changes: 6 additions & 5 deletions src/chart/graph/Thumbnail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import SeriesModel from '../../model/Series';
import { BoxLayoutOptionMixin, ItemStyleOption } from '../../util/types';
import RoamController, { RoamEventDefinition, RoamType } from '../../component/helper/RoamController';
import Eventful from 'zrender/src/core/Eventful';
import tokens from '../../visual/tokens';


// TODO:
Expand Down Expand Up @@ -82,7 +83,7 @@ class Thumbnail extends Eventful<Pick<RoamEventDefinition, 'zoom' | 'pan'>> {
const cursor = opt.roamType ? 'pointer' : 'default';
const itemStyleModel = thumbnailModel.getModel('itemStyle');
const itemStyle = itemStyleModel.getItemStyle();
itemStyle.fill = seriesModel.ecModel.get('backgroundColor') || '#fff';
itemStyle.fill = seriesModel.ecModel.get('backgroundColor') || tokens.color.neutral00;

// Try to use border-box in thumbnail, see https://github.com/apache/echarts/issues/18022
const boxBorderWidth = itemStyle.lineWidth || 0;
Expand Down Expand Up @@ -250,14 +251,14 @@ class Thumbnail extends Eventful<Pick<RoamEventDefinition, 'zoom' | 'pan'>> {

itemStyle: {
// Use echarts option.backgorundColor by default.
borderColor: '#555',
borderWidth: 2
borderColor: tokens.color.border,
borderWidth: 1
},

windowStyle: {
borderWidth: 1,
color: 'green',
borderColor: '#000',
color: tokens.color.neutral30,
borderColor: tokens.color.neutral40,
opacity: 0.3
}
};
Expand Down
3 changes: 2 additions & 1 deletion src/chart/heatmap/HeatmapLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
/* global Uint8ClampedArray */

import { platformApi } from 'zrender/src/core/platform';
import tokens from '../../visual/tokens';

const GRADIENT_LEVELS = 256;

Expand Down Expand Up @@ -144,7 +145,7 @@ class HeatmapLayer {
ctx.shadowBlur = this.blurSize;
// draw the shadow in black, and use alpha and shadow blur to generate
// color in color map
ctx.shadowColor = '#000';
ctx.shadowColor = tokens.color.neutral99;

// draw circle in the left to the canvas
ctx.beginPath();
Expand Down
3 changes: 2 additions & 1 deletion src/chart/heatmap/HeatmapSeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import SeriesData from '../../data/SeriesData';
import type Geo from '../../coord/geo/Geo';
import type Cartesian2D from '../../coord/cartesian/Cartesian2D';
import type Calendar from '../../coord/calendar/Calendar';
import tokens from '../../visual/tokens';

type HeatmapDataValue = OptionDataValue[];

Expand Down Expand Up @@ -126,7 +127,7 @@ class HeatmapSeriesModel extends SeriesModel<HeatmapSeriesOption> {

select: {
itemStyle: {
borderColor: '#212121'
borderColor: tokens.color.primary
}
}
};
Expand Down
3 changes: 2 additions & 1 deletion src/chart/helper/LargeLineDraw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { StageHandlerProgressParams, LineStyleOption, ColorString } from '../../
import Model from '../../model/Model';
import { getECData } from '../../util/innerStore';
import Element from 'zrender/src/Element';
import tokens from '../../visual/tokens';

class LargeLinesPathShape {
polyline = false;
Expand Down Expand Up @@ -74,7 +75,7 @@ class LargeLinesPath extends graphic.Path {

getDefaultStyle() {
return {
stroke: '#000',
stroke: tokens.color.neutral99,
fill: null as ColorString
};
}
Expand Down
3 changes: 2 additions & 1 deletion src/chart/helper/Line.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import type { LineDrawSeriesScope, LineDrawModelOption } from './LineDraw';
import { TextStyleProps } from 'zrender/src/graphic/Text';
import { LineDataVisual } from '../../visual/commonVisualTypes';
import Model from '../../model/Model';
import tokens from '../../visual/tokens';

const SYMBOL_CATEGORIES = ['fromSymbol', 'toSymbol'] as const;

Expand Down Expand Up @@ -297,7 +298,7 @@ class Line extends graphic.Group {
return seriesModel.getFormattedLabel(dataIndex, stateName, lineData.dataType);
}
},
inheritColor: visualColor as ColorString || '#000',
inheritColor: visualColor as ColorString || tokens.color.neutral99,
defaultOpacity: lineStyle.opacity,
defaultText: (rawVal == null
? lineData.getName(idx)
Expand Down
3 changes: 2 additions & 1 deletion src/chart/helper/LinePath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import * as graphic from '../../util/graphic';
import * as vec2 from 'zrender/src/core/vector';
import { PathProps } from 'zrender/src/graphic/Path';
import { ColorString } from '../../util/types';
import tokens from '../../visual/tokens';

const straightLineProto = graphic.Line.prototype;
const bezierCurveProto = graphic.BezierCurve.prototype;
Expand Down Expand Up @@ -64,7 +65,7 @@ class ECLinePath extends graphic.Path<ECLineProps> {

getDefaultStyle() {
return {
stroke: '#000',
stroke: tokens.color.neutral99,
fill: null as ColorString
};
}
Expand Down
Loading