MCPcopy Create free account
hub / github.com/apache/echarts / reset

Function reset

src/visual/style.ts:70–130  ·  view source on GitHub ↗
(seriesModel, ecModel)

Source from the content-addressed store, hash-verified

68 createOnAllSeries: true,
69 performRawSeries: true,
70 reset(seriesModel, ecModel) {
71 const data = seriesModel.getData();
72 const stylePath = seriesModel.visualStyleAccessPath
73 || 'itemStyle';
74 // Set in itemStyle
75 const styleModel = seriesModel.getModel(stylePath as any);
76 const getStyle = getStyleMapper(seriesModel, stylePath);
77
78 const globalStyle = getStyle(styleModel);
79
80 const decalOption = styleModel.getShallow('decal') as InnerDecalObject;
81 if (decalOption) {
82 data.setVisual('decal', decalOption);
83 decalOption.dirty = true;
84 }
85
86 // TODO
87 const colorKey = getDefaultColorKey(seriesModel, stylePath);
88 const color = globalStyle[colorKey];
89
90 // TODO style callback
91 const colorCallback = isFunction(color) ? color as unknown as ColorCallback : null;
92 const hasAutoColor = globalStyle.fill === 'auto' || globalStyle.stroke === 'auto';
93 // Get from color palette by default.
94 if (!globalStyle[colorKey] || colorCallback || hasAutoColor) {
95 // Note: If some series has color specified (e.g., by itemStyle.color), we DO NOT
96 // make it effect palette. Because some scenarios users need to make some series
97 // transparent or as background, which should better not effect the palette.
98 const colorPalette = seriesModel.getColorFromPalette(
99 // TODO series count changed.
100 seriesModel.name, null, ecModel.getSeriesCount()
101 );
102 if (!globalStyle[colorKey]) {
103 globalStyle[colorKey] = colorPalette;
104 data.setVisual('colorFromPalette', true);
105 }
106 globalStyle.fill = (globalStyle.fill === 'auto' || isFunction(globalStyle.fill))
107 ? colorPalette
108 : globalStyle.fill;
109 globalStyle.stroke = (globalStyle.stroke === 'auto' || isFunction(globalStyle.stroke))
110 ? colorPalette
111 : globalStyle.stroke;
112 }
113
114 data.setVisual('style', globalStyle);
115 data.setVisual('drawType', colorKey);
116
117 // Only visible series has each data be visual encoded
118 if (!ecModel.isSeriesFiltered(seriesModel) && colorCallback) {
119 data.setVisual('colorFromPalette', false);
120
121 return {
122 dataEach(data, idx) {
123 const dataParams = seriesModel.getDataParams(idx);
124 const itemStyle = extend({}, globalStyle);
125 itemStyle[colorKey] = colorCallback(dataParams);
126 data.setItemVisual(idx, 'style', itemStyle);
127 }

Callers

nothing calls this directly

Calls 15

getStyleMapperFunction · 0.85
getStyleFunction · 0.85
getDefaultColorKeyFunction · 0.85
extendFunction · 0.85
getShallowMethod · 0.80
getSeriesCountMethod · 0.80
isSeriesFilteredMethod · 0.80
setItemVisualMethod · 0.80
getDataMethod · 0.65
setVisualMethod · 0.65
getVisualMethod · 0.65

Tested by

no test coverage detected