Skip to content

Commit b60f105

Browse files
authored
Merge pull request #20865 from apache/feat-theme
feat: new theme for ECharts 6.0
2 parents 9c5b5fc + a1d61c2 commit b60f105

File tree

121 files changed

+3642
-449
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+3642
-449
lines changed

src/chart/bar/BarSeries.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import type Polar from '../../coord/polar/Polar';
3636
import { inheritDefaultOption } from '../../util/component';
3737
import SeriesData from '../../data/SeriesData';
3838
import { BrushCommonSelectorsForSeries } from '../../component/brush/selector';
39+
import tokens from '../../visual/tokens';
3940

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

156157
select: {
157158
itemStyle: {
158-
borderColor: '#212121'
159+
borderColor: tokens.color.primary,
160+
borderWidth: 2
159161
}
160162
},
161163

src/chart/bar/BaseBarSeries.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ export interface BaseBarSeriesOption<StateOption, ExtraStateOption extends State
6767
*/
6868
barGap?: string | number
6969

70+
/**
71+
* @private
72+
*/
73+
defaultBarGap?: string | number
74+
7075
/**
7176
* Gap between each category. Default to be 20%. can be an absolute pixel value.
7277
*/
@@ -199,7 +204,9 @@ class BaseBarSeriesModel<Opts extends BaseBarSeriesOption<unknown> = BaseBarSeri
199204
large: false,
200205
largeThreshold: 400,
201206
progressive: 3e3,
202-
progressiveChunkMode: 'mod'
207+
progressiveChunkMode: 'mod',
208+
209+
defaultBarGap: '10%'
203210
};
204211
}
205212

src/chart/bar/PictorialBarSeries.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
} from '../../util/types';
3232
import type Cartesian2D from '../../coord/cartesian/Cartesian2D';
3333
import { inheritDefaultOption } from '../../util/component';
34+
import tokens from '../../visual/tokens';
3435

3536
export interface PictorialBarStateOption {
3637
itemStyle?: ItemStyleOption
@@ -169,7 +170,7 @@ class PictorialBarSeriesModel extends BaseBarSeriesModel<PictorialBarSeriesOptio
169170

170171
select: {
171172
itemStyle: {
172-
borderColor: '#212121'
173+
borderColor: tokens.color.primary
173174
}
174175
}
175176
});

src/chart/boxplot/BoxplotSeries.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {
3434
import type Axis2D from '../../coord/cartesian/Axis2D';
3535
import Cartesian2D from '../../coord/cartesian/Cartesian2D';
3636
import { mixin } from 'zrender/src/core/util';
37+
import tokens from '../../visual/tokens';
3738

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

113114
itemStyle: {
114-
color: '#fff',
115+
color: tokens.color.neutral00,
115116
borderWidth: 1
116117
},
117118

@@ -123,7 +124,7 @@ class BoxplotSeriesModel extends SeriesModel<BoxplotSeriesOption> {
123124
shadowBlur: 5,
124125
shadowOffsetX: 1,
125126
shadowOffsetY: 1,
126-
shadowColor: 'rgba(0,0,0,0.2)'
127+
shadowColor: tokens.color.shadow
127128
}
128129
},
129130

src/chart/custom/CustomView.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ import {
103103
} from '../../animation/customGraphicKeyframeAnimation';
104104
import type SeriesModel from '../../model/Series';
105105
import { getCustomSeries } from './customSeriesRegister';
106+
import tokens from '../../visual/tokens';
106107

107108
const EMPHASIS = 'emphasis' as const;
108109
const NORMAL = 'normal' as const;
@@ -809,7 +810,7 @@ function makeRenderItem(
809810
visualColor != null && (itemStyle.fill = visualColor);
810811
opacity != null && (itemStyle.opacity = opacity);
811812

812-
const opt = {inheritColor: isString(visualColor) ? visualColor : '#000'};
813+
const opt = {inheritColor: isString(visualColor) ? visualColor : tokens.color.neutral99};
813814
const labelModel = getLabelModel(dataIndexInside, NORMAL);
814815
// Now that the feature of "auto adjust text fill/stroke" has been migrated to zrender
815816
// since ec5, we should set `isAttached` as `false` here and make compat in

src/chart/funnel/FunnelSeries.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import {
4242
} from '../../util/types';
4343
import GlobalModel from '../../model/Global';
4444
import SeriesData from '../../data/SeriesData';
45+
import tokens from '../../visual/tokens';
4546

4647
type FunnelLabelOption = Omit<SeriesLabelOption, 'position'> & {
4748
position?: LabelOption['position']
@@ -154,7 +155,7 @@ class FunnelSeriesModel extends SeriesModel<FunnelSeriesOption> {
154155
left: 80,
155156
top: 60,
156157
right: 80,
157-
bottom: 60,
158+
bottom: 65,
158159
// width: {totalWidth} - left - right,
159160
// height: {totalHeight} - top - bottom,
160161

@@ -182,7 +183,7 @@ class FunnelSeriesModel extends SeriesModel<FunnelSeriesOption> {
182183
},
183184
itemStyle: {
184185
// color: 各异,
185-
borderColor: '#fff',
186+
borderColor: tokens.color.neutral00,
186187
borderWidth: 1
187188
},
188189
emphasis: {
@@ -192,7 +193,7 @@ class FunnelSeriesModel extends SeriesModel<FunnelSeriesOption> {
192193
},
193194
select: {
194195
itemStyle: {
195-
borderColor: '#212121'
196+
borderColor: tokens.color.primary
196197
}
197198
}
198199
};

src/chart/funnel/FunnelView.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,17 @@ class FunnelPiece extends graphic.Polygon {
128128
} }
129129
);
130130

131+
const labelModel = itemModel.getModel('label');
132+
const labelColor = labelModel.get('color');
133+
const overrideColor = labelColor === 'inherit'
134+
? visualColor
135+
: null;
136+
131137
polygon.setTextConfig({
132138
local: true,
133139
inside: !!labelLayout.inside,
134-
insideStroke: visualColor,
135-
// insideFill: 'auto',
136-
outsideFill: visualColor
140+
insideStroke: overrideColor,
141+
outsideFill: overrideColor
137142
});
138143

139144
const linePoints = labelLayout.linePoints;

src/chart/gauge/GaugeSeries.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {
3434
} from '../../util/types';
3535
import GlobalModel from '../../model/Global';
3636
import SeriesData from '../../data/SeriesData';
37+
import tokens from '../../visual/tokens';
3738

3839
// [percent, color]
3940
type GaugeColorStop = [number, ColorString];
@@ -218,7 +219,7 @@ class GaugeSeriesModel extends SeriesModel<GaugeSeriesOption> {
218219
show: true,
219220
roundCap: false,
220221
lineStyle: { // 属性lineStyle控制线条样式
221-
color: [[1, '#E6EBF8']],
222+
color: [[1, tokens.color.neutral10]],
222223
width: 10
223224
}
224225
},
@@ -240,7 +241,7 @@ class GaugeSeriesModel extends SeriesModel<GaugeSeriesOption> {
240241
distance: 10,
241242
// 属性lineStyle(详见lineStyle)控制线条样式
242243
lineStyle: {
243-
color: '#63677A',
244+
color: tokens.color.axisTick,
244245
width: 3,
245246
type: 'solid'
246247
}
@@ -256,7 +257,7 @@ class GaugeSeriesModel extends SeriesModel<GaugeSeriesOption> {
256257
distance: 10,
257258
// 属性lineStyle控制线条样式
258259
lineStyle: {
259-
color: '#63677A',
260+
color: tokens.color.axisTickMinor,
260261
width: 1,
261262
type: 'solid'
262263
}
@@ -265,7 +266,7 @@ class GaugeSeriesModel extends SeriesModel<GaugeSeriesOption> {
265266
show: true,
266267
distance: 15,
267268
// formatter: null,
268-
color: '#464646',
269+
color: tokens.color.axisLabel,
269270
fontSize: 12,
270271
rotate: 0
271272
},
@@ -286,9 +287,9 @@ class GaugeSeriesModel extends SeriesModel<GaugeSeriesOption> {
286287
offsetCenter: [0, 0],
287288
keepAspect: false,
288289
itemStyle: {
289-
color: '#fff',
290+
color: tokens.color.neutral00,
290291
borderWidth: 0,
291-
borderColor: '#5470c6'
292+
borderColor: tokens.color.theme[0]
292293
}
293294
},
294295

@@ -297,23 +298,23 @@ class GaugeSeriesModel extends SeriesModel<GaugeSeriesOption> {
297298
// x, y,单位px
298299
offsetCenter: [0, '20%'],
299300
// 其余属性默认使用全局文本样式,详见TEXTSTYLE
300-
color: '#464646',
301+
color: tokens.color.secondary,
301302
fontSize: 16,
302303
valueAnimation: false
303304
},
304305
detail: {
305306
show: true,
306-
backgroundColor: 'rgba(0,0,0,0)',
307+
backgroundColor: tokens.color.transparent,
307308
borderWidth: 0,
308-
borderColor: '#ccc',
309+
borderColor: tokens.color.neutral40,
309310
width: 100,
310311
height: null, // self-adaption
311312
padding: [5, 10],
312313
// x, y,单位px
313314
offsetCenter: [0, '40%'],
314315
// formatter: null,
315316
// 其余属性默认使用全局文本样式,详见TEXTSTYLE
316-
color: '#464646',
317+
color: tokens.color.primary,
317318
fontSize: 30,
318319
fontWeight: 'bold',
319320
lineHeight: 30,

src/chart/graph/GraphSeries.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ import { createTooltipMarkup } from '../../component/tooltip/tooltipMarkup';
5555
import { defaultSeriesFormatTooltip } from '../../component/tooltip/seriesFormatTooltip';
5656
import {initCurvenessList, createEdgeMapForCurveness} from '../helper/multipleGraphEdgeHelper';
5757
import Thumbnail, { ThumbnailOption } from './Thumbnail';
58+
import tokens from '../../visual/tokens';
5859

5960

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

498499
lineStyle: {
499-
color: '#aaa',
500+
// Don't use tokens.color.border because of the opacity
501+
color: tokens.color.neutral50,
500502
width: 1,
501503
opacity: 0.5
502504
},
@@ -509,7 +511,7 @@ class GraphSeriesModel extends SeriesModel<GraphSeriesOption> {
509511

510512
select: {
511513
itemStyle: {
512-
borderColor: '#212121'
514+
borderColor: tokens.color.primary
513515
}
514516
},
515517

src/chart/graph/Thumbnail.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import SeriesModel from '../../model/Series';
1111
import { BoxLayoutOptionMixin, ItemStyleOption } from '../../util/types';
1212
import RoamController, { RoamEventDefinition, RoamType } from '../../component/helper/RoamController';
1313
import Eventful from 'zrender/src/core/Eventful';
14+
import tokens from '../../visual/tokens';
1415

1516

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

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

251252
itemStyle: {
252253
// Use echarts option.backgorundColor by default.
253-
borderColor: '#555',
254-
borderWidth: 2
254+
borderColor: tokens.color.border,
255+
borderWidth: 1
255256
},
256257

257258
windowStyle: {
258259
borderWidth: 1,
259-
color: 'green',
260-
borderColor: '#000',
260+
color: tokens.color.neutral30,
261+
borderColor: tokens.color.neutral40,
261262
opacity: 0.3
262263
}
263264
};

0 commit comments

Comments
 (0)