q2-tecton-elements 1.22.2 → 1.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/dist/cjs/charting-d02cba1f.js +3127 -0
  2. package/dist/cjs/{installCanvasRenderer-b4d10c92.js → installCanvasRenderer-6c4fbcc9.js} +230 -1130
  3. package/dist/cjs/installLabelLayout-d6b548fe.js +1048 -0
  4. package/dist/cjs/loader.cjs.js +1 -1
  5. package/dist/cjs/q2-btn_2.cjs.entry.js +1 -1
  6. package/dist/cjs/q2-card.cjs.entry.js +1 -1
  7. package/dist/cjs/q2-chart-area.cjs.entry.js +4569 -0
  8. package/dist/cjs/q2-chart-bar.cjs.entry.js +24 -3132
  9. package/dist/cjs/q2-chart-donut.cjs.entry.js +8 -7
  10. package/dist/cjs/q2-checkbox.cjs.entry.js +1 -1
  11. package/dist/cjs/q2-loading-element.cjs.entry.js +1 -1
  12. package/dist/cjs/q2-select.cjs.entry.js +2 -1
  13. package/dist/cjs/q2-tecton-elements.cjs.js +1 -1
  14. package/dist/collection/collection-manifest.json +1 -0
  15. package/dist/collection/components/q2-card/index.js +1 -1
  16. package/dist/collection/components/q2-chart-area/index.js +622 -0
  17. package/dist/collection/components/q2-chart-area/styles.css +82 -0
  18. package/dist/collection/components/q2-chart-bar/index.js +4 -4
  19. package/dist/collection/components/q2-chart-bar/styles.css +3 -6
  20. package/dist/collection/components/q2-chart-donut/index.js +1 -1
  21. package/dist/collection/components/q2-checkbox/styles.css +1 -0
  22. package/dist/collection/components/q2-loading/skeleton/q2-loading-element/styles.css +4 -0
  23. package/dist/collection/components/q2-loading/styles.css +4 -0
  24. package/dist/collection/components/q2-select/index.js +19 -1
  25. package/dist/components/charting.js +3113 -0
  26. package/dist/components/index.d.ts +1 -0
  27. package/dist/components/index.js +1 -0
  28. package/dist/components/index9.js +1 -1
  29. package/dist/components/installCanvasRenderer.js +188 -1123
  30. package/dist/components/installLabelLayout.js +1042 -0
  31. package/dist/components/q2-card.js +1 -1
  32. package/dist/components/q2-chart-area.d.ts +11 -0
  33. package/dist/components/q2-chart-area.js +4604 -0
  34. package/dist/components/q2-chart-bar.js +10 -3118
  35. package/dist/components/q2-chart-donut.js +3 -2
  36. package/dist/components/q2-checkbox.js +1 -1
  37. package/dist/components/q2-loading-element.js +1 -1
  38. package/dist/components/q2-select.js +3 -1
  39. package/dist/esm/charting-2a73ba8e.js +3113 -0
  40. package/dist/esm/{installCanvasRenderer-0143b52d.js → installCanvasRenderer-4a470516.js} +188 -1123
  41. package/dist/esm/installLabelLayout-d660eaad.js +1042 -0
  42. package/dist/esm/loader.js +1 -1
  43. package/dist/esm/q2-btn_2.entry.js +1 -1
  44. package/dist/esm/q2-card.entry.js +1 -1
  45. package/dist/esm/q2-chart-area.entry.js +4565 -0
  46. package/dist/esm/q2-chart-bar.entry.js +10 -3118
  47. package/dist/esm/q2-chart-donut.entry.js +3 -2
  48. package/dist/esm/q2-checkbox.entry.js +1 -1
  49. package/dist/esm/q2-loading-element.entry.js +1 -1
  50. package/dist/esm/q2-select.entry.js +2 -1
  51. package/dist/esm/q2-tecton-elements.js +1 -1
  52. package/dist/q2-tecton-elements/p-458b1987.js +1 -0
  53. package/dist/q2-tecton-elements/p-52063431.js +39 -0
  54. package/dist/q2-tecton-elements/p-604b22a8.entry.js +1 -0
  55. package/dist/q2-tecton-elements/p-6be86940.entry.js +1 -0
  56. package/dist/q2-tecton-elements/p-70b01387.entry.js +1 -0
  57. package/dist/q2-tecton-elements/p-833398d1.js +1 -0
  58. package/dist/q2-tecton-elements/{p-2cb7163e.entry.js → p-acc77332.entry.js} +1 -1
  59. package/dist/q2-tecton-elements/p-bbdae095.entry.js +1 -0
  60. package/dist/q2-tecton-elements/{p-84b19eff.entry.js → p-d68b5eb3.entry.js} +1 -1
  61. package/dist/q2-tecton-elements/p-d88e4383.entry.js +1 -0
  62. package/dist/q2-tecton-elements/{p-6e6b5b80.entry.js → p-f0ec4d2c.entry.js} +1 -1
  63. package/dist/q2-tecton-elements/q2-tecton-elements.esm.js +1 -1
  64. package/dist/types/components/q2-card/index.d.ts +1 -1
  65. package/dist/types/components/q2-chart-area/index.d.ts +40 -0
  66. package/dist/types/components/q2-chart-bar/index.d.ts +2 -2
  67. package/dist/types/components/q2-chart-donut/index.d.ts +1 -1
  68. package/dist/types/components/q2-select/index.d.ts +1 -0
  69. package/dist/types/components.d.ts +58 -0
  70. package/package.json +2 -2
  71. package/dist/q2-tecton-elements/p-1f303a21.entry.js +0 -1
  72. package/dist/q2-tecton-elements/p-1f85cced.js +0 -39
  73. package/dist/q2-tecton-elements/p-91d830c3.entry.js +0 -1
  74. package/dist/q2-tecton-elements/p-aec145e9.entry.js +0 -1
  75. package/dist/q2-tecton-elements/p-cd1c68d2.entry.js +0 -1
  76. /package/dist/types/workspace/workspace/{tecton-production_release_1.22.x → Tecton_tecton-production_master}/packages/q2-tecton-elements/.stencil/test/helpers.d.ts +0 -0
@@ -0,0 +1,3127 @@
1
+ 'use strict';
2
+
3
+ const installCanvasRenderer = require('./installCanvasRenderer-6c4fbcc9.js');
4
+
5
+ /**
6
+ * @class
7
+ * For example:
8
+ * {
9
+ * coordSysName: 'cartesian2d',
10
+ * coordSysDims: ['x', 'y', ...],
11
+ * axisMap: HashMap({
12
+ * x: xAxisModel,
13
+ * y: yAxisModel
14
+ * }),
15
+ * categoryAxisMap: HashMap({
16
+ * x: xAxisModel,
17
+ * y: undefined
18
+ * }),
19
+ * // The index of the first category axis in `coordSysDims`.
20
+ * // `null/undefined` means no category axis exists.
21
+ * firstCategoryDimIndex: 1,
22
+ * // To replace user specified encode.
23
+ * }
24
+ */
25
+
26
+ var CoordSysInfo =
27
+ /** @class */
28
+ function () {
29
+ function CoordSysInfo(coordSysName) {
30
+ this.coordSysDims = [];
31
+ this.axisMap = installCanvasRenderer.createHashMap();
32
+ this.categoryAxisMap = installCanvasRenderer.createHashMap();
33
+ this.coordSysName = coordSysName;
34
+ }
35
+
36
+ return CoordSysInfo;
37
+ }();
38
+
39
+ function getCoordSysInfoBySeries(seriesModel) {
40
+ var coordSysName = seriesModel.get('coordinateSystem');
41
+ var result = new CoordSysInfo(coordSysName);
42
+ var fetch = fetchers[coordSysName];
43
+
44
+ if (fetch) {
45
+ fetch(seriesModel, result, result.axisMap, result.categoryAxisMap);
46
+ return result;
47
+ }
48
+ }
49
+ var fetchers = {
50
+ cartesian2d: function (seriesModel, result, axisMap, categoryAxisMap) {
51
+ var xAxisModel = seriesModel.getReferringComponents('xAxis', installCanvasRenderer.SINGLE_REFERRING).models[0];
52
+ var yAxisModel = seriesModel.getReferringComponents('yAxis', installCanvasRenderer.SINGLE_REFERRING).models[0];
53
+
54
+ result.coordSysDims = ['x', 'y'];
55
+ axisMap.set('x', xAxisModel);
56
+ axisMap.set('y', yAxisModel);
57
+
58
+ if (isCategory(xAxisModel)) {
59
+ categoryAxisMap.set('x', xAxisModel);
60
+ result.firstCategoryDimIndex = 0;
61
+ }
62
+
63
+ if (isCategory(yAxisModel)) {
64
+ categoryAxisMap.set('y', yAxisModel);
65
+ result.firstCategoryDimIndex == null && (result.firstCategoryDimIndex = 1);
66
+ }
67
+ },
68
+ singleAxis: function (seriesModel, result, axisMap, categoryAxisMap) {
69
+ var singleAxisModel = seriesModel.getReferringComponents('singleAxis', installCanvasRenderer.SINGLE_REFERRING).models[0];
70
+
71
+ result.coordSysDims = ['single'];
72
+ axisMap.set('single', singleAxisModel);
73
+
74
+ if (isCategory(singleAxisModel)) {
75
+ categoryAxisMap.set('single', singleAxisModel);
76
+ result.firstCategoryDimIndex = 0;
77
+ }
78
+ },
79
+ polar: function (seriesModel, result, axisMap, categoryAxisMap) {
80
+ var polarModel = seriesModel.getReferringComponents('polar', installCanvasRenderer.SINGLE_REFERRING).models[0];
81
+ var radiusAxisModel = polarModel.findAxisModel('radiusAxis');
82
+ var angleAxisModel = polarModel.findAxisModel('angleAxis');
83
+
84
+ result.coordSysDims = ['radius', 'angle'];
85
+ axisMap.set('radius', radiusAxisModel);
86
+ axisMap.set('angle', angleAxisModel);
87
+
88
+ if (isCategory(radiusAxisModel)) {
89
+ categoryAxisMap.set('radius', radiusAxisModel);
90
+ result.firstCategoryDimIndex = 0;
91
+ }
92
+
93
+ if (isCategory(angleAxisModel)) {
94
+ categoryAxisMap.set('angle', angleAxisModel);
95
+ result.firstCategoryDimIndex == null && (result.firstCategoryDimIndex = 1);
96
+ }
97
+ },
98
+ geo: function (seriesModel, result, axisMap, categoryAxisMap) {
99
+ result.coordSysDims = ['lng', 'lat'];
100
+ },
101
+ parallel: function (seriesModel, result, axisMap, categoryAxisMap) {
102
+ var ecModel = seriesModel.ecModel;
103
+ var parallelModel = ecModel.getComponent('parallel', seriesModel.get('parallelIndex'));
104
+ var coordSysDims = result.coordSysDims = parallelModel.dimensions.slice();
105
+ installCanvasRenderer.each(parallelModel.parallelAxisIndex, function (axisIndex, index) {
106
+ var axisModel = ecModel.getComponent('parallelAxis', axisIndex);
107
+ var axisDim = coordSysDims[index];
108
+ axisMap.set(axisDim, axisModel);
109
+
110
+ if (isCategory(axisModel)) {
111
+ categoryAxisMap.set(axisDim, axisModel);
112
+
113
+ if (result.firstCategoryDimIndex == null) {
114
+ result.firstCategoryDimIndex = index;
115
+ }
116
+ }
117
+ });
118
+ }
119
+ };
120
+
121
+ function isCategory(axisModel) {
122
+ return axisModel.get('type') === 'category';
123
+ }
124
+
125
+ function getCoordSysDimDefs(seriesModel, coordSysInfo) {
126
+ var coordSysName = seriesModel.get('coordinateSystem');
127
+ var registeredCoordSys = installCanvasRenderer.CoordinateSystemManager.get(coordSysName);
128
+ var coordSysDimDefs;
129
+
130
+ if (coordSysInfo && coordSysInfo.coordSysDims) {
131
+ coordSysDimDefs = installCanvasRenderer.map(coordSysInfo.coordSysDims, function (dim) {
132
+ var dimInfo = {
133
+ name: dim
134
+ };
135
+ var axisModel = coordSysInfo.axisMap.get(dim);
136
+
137
+ if (axisModel) {
138
+ var axisType = axisModel.get('type');
139
+ dimInfo.type = installCanvasRenderer.getDimensionTypeByAxis(axisType);
140
+ }
141
+
142
+ return dimInfo;
143
+ });
144
+ }
145
+
146
+ if (!coordSysDimDefs) {
147
+ // Get dimensions from registered coordinate system
148
+ coordSysDimDefs = registeredCoordSys && (registeredCoordSys.getDimensionsInfo ? registeredCoordSys.getDimensionsInfo() : registeredCoordSys.dimensions.slice()) || ['x', 'y'];
149
+ }
150
+
151
+ return coordSysDimDefs;
152
+ }
153
+
154
+ function injectOrdinalMeta(dimInfoList, createInvertedIndices, coordSysInfo) {
155
+ var firstCategoryDimIndex;
156
+ var hasNameEncode;
157
+ coordSysInfo && installCanvasRenderer.each(dimInfoList, function (dimInfo, dimIndex) {
158
+ var coordDim = dimInfo.coordDim;
159
+ var categoryAxisModel = coordSysInfo.categoryAxisMap.get(coordDim);
160
+
161
+ if (categoryAxisModel) {
162
+ if (firstCategoryDimIndex == null) {
163
+ firstCategoryDimIndex = dimIndex;
164
+ }
165
+
166
+ dimInfo.ordinalMeta = categoryAxisModel.getOrdinalMeta();
167
+
168
+ if (createInvertedIndices) {
169
+ dimInfo.createInvertedIndices = true;
170
+ }
171
+ }
172
+
173
+ if (dimInfo.otherDims.itemName != null) {
174
+ hasNameEncode = true;
175
+ }
176
+ });
177
+
178
+ if (!hasNameEncode && firstCategoryDimIndex != null) {
179
+ dimInfoList[firstCategoryDimIndex].otherDims.itemName = 0;
180
+ }
181
+
182
+ return firstCategoryDimIndex;
183
+ }
184
+ /**
185
+ * Caution: there are side effects to `sourceManager` in this method.
186
+ * Should better only be called in `Series['getInitialData']`.
187
+ */
188
+
189
+
190
+ function createSeriesData(sourceRaw, seriesModel, opt) {
191
+ opt = opt || {};
192
+ var sourceManager = seriesModel.getSourceManager();
193
+ var source;
194
+ var isOriginalSource = false;
195
+
196
+ if (sourceRaw) {
197
+ isOriginalSource = true;
198
+ source = installCanvasRenderer.createSourceFromSeriesDataOption(sourceRaw);
199
+ } else {
200
+ source = sourceManager.getSource(); // Is series.data. not dataset.
201
+
202
+ isOriginalSource = source.sourceFormat === installCanvasRenderer.SOURCE_FORMAT_ORIGINAL;
203
+ }
204
+
205
+ var coordSysInfo = getCoordSysInfoBySeries(seriesModel);
206
+ var coordSysDimDefs = getCoordSysDimDefs(seriesModel, coordSysInfo);
207
+ var useEncodeDefaulter = opt.useEncodeDefaulter;
208
+ var encodeDefaulter = installCanvasRenderer.isFunction(useEncodeDefaulter) ? useEncodeDefaulter : useEncodeDefaulter ? installCanvasRenderer.curry(installCanvasRenderer.makeSeriesEncodeForAxisCoordSys, coordSysDimDefs, seriesModel) : null;
209
+ var createDimensionOptions = {
210
+ coordDimensions: coordSysDimDefs,
211
+ generateCoord: opt.generateCoord,
212
+ encodeDefine: seriesModel.getEncode(),
213
+ encodeDefaulter: encodeDefaulter,
214
+ canOmitUnusedDimensions: !isOriginalSource
215
+ };
216
+ var schema = installCanvasRenderer.prepareSeriesDataSchema(source, createDimensionOptions);
217
+ var firstCategoryDimIndex = injectOrdinalMeta(schema.dimensions, opt.createInvertedIndices, coordSysInfo);
218
+ var store = !isOriginalSource ? sourceManager.getSharedDataStore(schema) : null;
219
+ var stackCalculationInfo = installCanvasRenderer.enableDataStack(seriesModel, {
220
+ schema: schema,
221
+ store: store
222
+ });
223
+ var data = new installCanvasRenderer.SeriesData(schema, seriesModel);
224
+ data.setCalculationInfo(stackCalculationInfo);
225
+ var dimValueGetter = firstCategoryDimIndex != null && isNeedCompleteOrdinalData(source) ? function (itemOpt, dimName, dataIndex, dimIndex) {
226
+ // Use dataIndex as ordinal value in categoryAxis
227
+ return dimIndex === firstCategoryDimIndex ? dataIndex : this.defaultDimValueGetter(itemOpt, dimName, dataIndex, dimIndex);
228
+ } : null;
229
+ data.hasItemOption = false;
230
+ data.initData( // Try to reuse the data store in sourceManager if using dataset.
231
+ isOriginalSource ? source : store, null, dimValueGetter);
232
+ return data;
233
+ }
234
+
235
+ function isNeedCompleteOrdinalData(source) {
236
+ if (source.sourceFormat === installCanvasRenderer.SOURCE_FORMAT_ORIGINAL) {
237
+ var sampleItem = firstDataNotNull(source.data || []);
238
+ return !installCanvasRenderer.isArray(installCanvasRenderer.getDataItemValue(sampleItem));
239
+ }
240
+ }
241
+
242
+ function firstDataNotNull(arr) {
243
+ var i = 0;
244
+
245
+ while (i < arr.length && arr[i] == null) {
246
+ i++;
247
+ }
248
+
249
+ return arr[i];
250
+ }
251
+
252
+ /*
253
+ * Licensed to the Apache Software Foundation (ASF) under one
254
+ * or more contributor license agreements. See the NOTICE file
255
+ * distributed with this work for additional information
256
+ * regarding copyright ownership. The ASF licenses this file
257
+ * to you under the Apache License, Version 2.0 (the
258
+ * "License"); you may not use this file except in compliance
259
+ * with the License. You may obtain a copy of the License at
260
+ *
261
+ * http://www.apache.org/licenses/LICENSE-2.0
262
+ *
263
+ * Unless required by applicable law or agreed to in writing,
264
+ * software distributed under the License is distributed on an
265
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
266
+ * KIND, either express or implied. See the License for the
267
+ * specific language governing permissions and limitations
268
+ * under the License.
269
+ */
270
+
271
+
272
+ /**
273
+ * AUTO-GENERATED FILE. DO NOT MODIFY.
274
+ */
275
+
276
+ /*
277
+ * Licensed to the Apache Software Foundation (ASF) under one
278
+ * or more contributor license agreements. See the NOTICE file
279
+ * distributed with this work for additional information
280
+ * regarding copyright ownership. The ASF licenses this file
281
+ * to you under the Apache License, Version 2.0 (the
282
+ * "License"); you may not use this file except in compliance
283
+ * with the License. You may obtain a copy of the License at
284
+ *
285
+ * http://www.apache.org/licenses/LICENSE-2.0
286
+ *
287
+ * Unless required by applicable law or agreed to in writing,
288
+ * software distributed under the License is distributed on an
289
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
290
+ * KIND, either express or implied. See the License for the
291
+ * specific language governing permissions and limitations
292
+ * under the License.
293
+ */
294
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
295
+ var AxisModelCommonMixin =
296
+ /** @class */
297
+ function () {
298
+ function AxisModelCommonMixin() {}
299
+
300
+ AxisModelCommonMixin.prototype.getNeedCrossZero = function () {
301
+ var option = this.option;
302
+ return !option.scale;
303
+ };
304
+ /**
305
+ * Should be implemented by each axis model if necessary.
306
+ * @return coordinate system model
307
+ */
308
+
309
+
310
+ AxisModelCommonMixin.prototype.getCoordSysModel = function () {
311
+ return;
312
+ };
313
+
314
+ return AxisModelCommonMixin;
315
+ }();
316
+
317
+ var inner$1 = installCanvasRenderer.makeInner();
318
+ function createAxisLabels(axis) {
319
+ // Only ordinal scale support tick interval
320
+ return axis.type === 'category' ? makeCategoryLabels(axis) : makeRealNumberLabels(axis);
321
+ }
322
+ /**
323
+ * @param {module:echats/coord/Axis} axis
324
+ * @param {module:echarts/model/Model} tickModel For example, can be axisTick, splitLine, splitArea.
325
+ * @return {Object} {
326
+ * ticks: Array.<number>
327
+ * tickCategoryInterval: number
328
+ * }
329
+ */
330
+
331
+ function createAxisTicks(axis, tickModel) {
332
+ // Only ordinal scale support tick interval
333
+ return axis.type === 'category' ? makeCategoryTicks(axis, tickModel) : {
334
+ ticks: installCanvasRenderer.map(axis.scale.getTicks(), function (tick) {
335
+ return tick.value;
336
+ })
337
+ };
338
+ }
339
+
340
+ function makeCategoryLabels(axis) {
341
+ var labelModel = axis.getLabelModel();
342
+ var result = makeCategoryLabelsActually(axis, labelModel);
343
+ return !labelModel.get('show') || axis.scale.isBlank() ? {
344
+ labels: [],
345
+ labelCategoryInterval: result.labelCategoryInterval
346
+ } : result;
347
+ }
348
+
349
+ function makeCategoryLabelsActually(axis, labelModel) {
350
+ var labelsCache = getListCache(axis, 'labels');
351
+ var optionLabelInterval = installCanvasRenderer.getOptionCategoryInterval(labelModel);
352
+ var result = listCacheGet(labelsCache, optionLabelInterval);
353
+
354
+ if (result) {
355
+ return result;
356
+ }
357
+
358
+ var labels;
359
+ var numericLabelInterval;
360
+
361
+ if (installCanvasRenderer.isFunction(optionLabelInterval)) {
362
+ labels = makeLabelsByCustomizedCategoryInterval(axis, optionLabelInterval);
363
+ } else {
364
+ numericLabelInterval = optionLabelInterval === 'auto' ? makeAutoCategoryInterval(axis) : optionLabelInterval;
365
+ labels = makeLabelsByNumericCategoryInterval(axis, numericLabelInterval);
366
+ } // Cache to avoid calling interval function repeatedly.
367
+
368
+
369
+ return listCacheSet(labelsCache, optionLabelInterval, {
370
+ labels: labels,
371
+ labelCategoryInterval: numericLabelInterval
372
+ });
373
+ }
374
+
375
+ function makeCategoryTicks(axis, tickModel) {
376
+ var ticksCache = getListCache(axis, 'ticks');
377
+ var optionTickInterval = installCanvasRenderer.getOptionCategoryInterval(tickModel);
378
+ var result = listCacheGet(ticksCache, optionTickInterval);
379
+
380
+ if (result) {
381
+ return result;
382
+ }
383
+
384
+ var ticks;
385
+ var tickCategoryInterval; // Optimize for the case that large category data and no label displayed,
386
+ // we should not return all ticks.
387
+
388
+ if (!tickModel.get('show') || axis.scale.isBlank()) {
389
+ ticks = [];
390
+ }
391
+
392
+ if (installCanvasRenderer.isFunction(optionTickInterval)) {
393
+ ticks = makeLabelsByCustomizedCategoryInterval(axis, optionTickInterval, true);
394
+ } // Always use label interval by default despite label show. Consider this
395
+ // scenario, Use multiple grid with the xAxis sync, and only one xAxis shows
396
+ // labels. `splitLine` and `axisTick` should be consistent in this case.
397
+ else if (optionTickInterval === 'auto') {
398
+ var labelsResult = makeCategoryLabelsActually(axis, axis.getLabelModel());
399
+ tickCategoryInterval = labelsResult.labelCategoryInterval;
400
+ ticks = installCanvasRenderer.map(labelsResult.labels, function (labelItem) {
401
+ return labelItem.tickValue;
402
+ });
403
+ } else {
404
+ tickCategoryInterval = optionTickInterval;
405
+ ticks = makeLabelsByNumericCategoryInterval(axis, tickCategoryInterval, true);
406
+ } // Cache to avoid calling interval function repeatedly.
407
+
408
+
409
+ return listCacheSet(ticksCache, optionTickInterval, {
410
+ ticks: ticks,
411
+ tickCategoryInterval: tickCategoryInterval
412
+ });
413
+ }
414
+
415
+ function makeRealNumberLabels(axis) {
416
+ var ticks = axis.scale.getTicks();
417
+ var labelFormatter = installCanvasRenderer.makeLabelFormatter(axis);
418
+ return {
419
+ labels: installCanvasRenderer.map(ticks, function (tick, idx) {
420
+ return {
421
+ level: tick.level,
422
+ formattedLabel: labelFormatter(tick, idx),
423
+ rawLabel: axis.scale.getLabel(tick),
424
+ tickValue: tick.value
425
+ };
426
+ })
427
+ };
428
+ }
429
+
430
+ function getListCache(axis, prop) {
431
+ // Because key can be a function, and cache size always is small, we use array cache.
432
+ return inner$1(axis)[prop] || (inner$1(axis)[prop] = []);
433
+ }
434
+
435
+ function listCacheGet(cache, key) {
436
+ for (var i = 0; i < cache.length; i++) {
437
+ if (cache[i].key === key) {
438
+ return cache[i].value;
439
+ }
440
+ }
441
+ }
442
+
443
+ function listCacheSet(cache, key, value) {
444
+ cache.push({
445
+ key: key,
446
+ value: value
447
+ });
448
+ return value;
449
+ }
450
+
451
+ function makeAutoCategoryInterval(axis) {
452
+ var result = inner$1(axis).autoInterval;
453
+ return result != null ? result : inner$1(axis).autoInterval = axis.calculateCategoryInterval();
454
+ }
455
+ /**
456
+ * Calculate interval for category axis ticks and labels.
457
+ * To get precise result, at least one of `getRotate` and `isHorizontal`
458
+ * should be implemented in axis.
459
+ */
460
+
461
+
462
+ function calculateCategoryInterval(axis) {
463
+ var params = fetchAutoCategoryIntervalCalculationParams(axis);
464
+ var labelFormatter = installCanvasRenderer.makeLabelFormatter(axis);
465
+ var rotation = (params.axisRotate - params.labelRotate) / 180 * Math.PI;
466
+ var ordinalScale = axis.scale;
467
+ var ordinalExtent = ordinalScale.getExtent(); // Providing this method is for optimization:
468
+ // avoid generating a long array by `getTicks`
469
+ // in large category data case.
470
+
471
+ var tickCount = ordinalScale.count();
472
+
473
+ if (ordinalExtent[1] - ordinalExtent[0] < 1) {
474
+ return 0;
475
+ }
476
+
477
+ var step = 1; // Simple optimization. Empirical value: tick count should less than 40.
478
+
479
+ if (tickCount > 40) {
480
+ step = Math.max(1, Math.floor(tickCount / 40));
481
+ }
482
+
483
+ var tickValue = ordinalExtent[0];
484
+ var unitSpan = axis.dataToCoord(tickValue + 1) - axis.dataToCoord(tickValue);
485
+ var unitW = Math.abs(unitSpan * Math.cos(rotation));
486
+ var unitH = Math.abs(unitSpan * Math.sin(rotation));
487
+ var maxW = 0;
488
+ var maxH = 0; // Caution: Performance sensitive for large category data.
489
+ // Consider dataZoom, we should make appropriate step to avoid O(n) loop.
490
+
491
+ for (; tickValue <= ordinalExtent[1]; tickValue += step) {
492
+ var width = 0;
493
+ var height = 0; // Not precise, do not consider align and vertical align
494
+ // and each distance from axis line yet.
495
+
496
+ var rect = installCanvasRenderer.getBoundingRect(labelFormatter({
497
+ value: tickValue
498
+ }), params.font, 'center', 'top'); // Magic number
499
+
500
+ width = rect.width * 1.3;
501
+ height = rect.height * 1.3; // Min size, void long loop.
502
+
503
+ maxW = Math.max(maxW, width, 7);
504
+ maxH = Math.max(maxH, height, 7);
505
+ }
506
+
507
+ var dw = maxW / unitW;
508
+ var dh = maxH / unitH; // 0/0 is NaN, 1/0 is Infinity.
509
+
510
+ isNaN(dw) && (dw = Infinity);
511
+ isNaN(dh) && (dh = Infinity);
512
+ var interval = Math.max(0, Math.floor(Math.min(dw, dh)));
513
+ var cache = inner$1(axis.model);
514
+ var axisExtent = axis.getExtent();
515
+ var lastAutoInterval = cache.lastAutoInterval;
516
+ var lastTickCount = cache.lastTickCount; // Use cache to keep interval stable while moving zoom window,
517
+ // otherwise the calculated interval might jitter when the zoom
518
+ // window size is close to the interval-changing size.
519
+ // For example, if all of the axis labels are `a, b, c, d, e, f, g`.
520
+ // The jitter will cause that sometimes the displayed labels are
521
+ // `a, d, g` (interval: 2) sometimes `a, c, e`(interval: 1).
522
+
523
+ if (lastAutoInterval != null && lastTickCount != null && Math.abs(lastAutoInterval - interval) <= 1 && Math.abs(lastTickCount - tickCount) <= 1 // Always choose the bigger one, otherwise the critical
524
+ // point is not the same when zooming in or zooming out.
525
+ && lastAutoInterval > interval // If the axis change is caused by chart resize, the cache should not
526
+ // be used. Otherwise some hidden labels might not be shown again.
527
+ && cache.axisExtent0 === axisExtent[0] && cache.axisExtent1 === axisExtent[1]) {
528
+ interval = lastAutoInterval;
529
+ } // Only update cache if cache not used, otherwise the
530
+ // changing of interval is too insensitive.
531
+ else {
532
+ cache.lastTickCount = tickCount;
533
+ cache.lastAutoInterval = interval;
534
+ cache.axisExtent0 = axisExtent[0];
535
+ cache.axisExtent1 = axisExtent[1];
536
+ }
537
+
538
+ return interval;
539
+ }
540
+
541
+ function fetchAutoCategoryIntervalCalculationParams(axis) {
542
+ var labelModel = axis.getLabelModel();
543
+ return {
544
+ axisRotate: axis.getRotate ? axis.getRotate() : axis.isHorizontal && !axis.isHorizontal() ? 90 : 0,
545
+ labelRotate: labelModel.get('rotate') || 0,
546
+ font: labelModel.getFont()
547
+ };
548
+ }
549
+
550
+ function makeLabelsByNumericCategoryInterval(axis, categoryInterval, onlyTick) {
551
+ var labelFormatter = installCanvasRenderer.makeLabelFormatter(axis);
552
+ var ordinalScale = axis.scale;
553
+ var ordinalExtent = ordinalScale.getExtent();
554
+ var labelModel = axis.getLabelModel();
555
+ var result = []; // TODO: axisType: ordinalTime, pick the tick from each month/day/year/...
556
+
557
+ var step = Math.max((categoryInterval || 0) + 1, 1);
558
+ var startTick = ordinalExtent[0];
559
+ var tickCount = ordinalScale.count(); // Calculate start tick based on zero if possible to keep label consistent
560
+ // while zooming and moving while interval > 0. Otherwise the selection
561
+ // of displayable ticks and symbols probably keep changing.
562
+ // 3 is empirical value.
563
+
564
+ if (startTick !== 0 && step > 1 && tickCount / step > 2) {
565
+ startTick = Math.round(Math.ceil(startTick / step) * step);
566
+ } // (1) Only add min max label here but leave overlap checking
567
+ // to render stage, which also ensure the returned list
568
+ // suitable for splitLine and splitArea rendering.
569
+ // (2) Scales except category always contain min max label so
570
+ // do not need to perform this process.
571
+
572
+
573
+ var showAllLabel = installCanvasRenderer.shouldShowAllLabels(axis);
574
+ var includeMinLabel = labelModel.get('showMinLabel') || showAllLabel;
575
+ var includeMaxLabel = labelModel.get('showMaxLabel') || showAllLabel;
576
+
577
+ if (includeMinLabel && startTick !== ordinalExtent[0]) {
578
+ addItem(ordinalExtent[0]);
579
+ } // Optimize: avoid generating large array by `ordinalScale.getTicks()`.
580
+
581
+
582
+ var tickValue = startTick;
583
+
584
+ for (; tickValue <= ordinalExtent[1]; tickValue += step) {
585
+ addItem(tickValue);
586
+ }
587
+
588
+ if (includeMaxLabel && tickValue - step !== ordinalExtent[1]) {
589
+ addItem(ordinalExtent[1]);
590
+ }
591
+
592
+ function addItem(tickValue) {
593
+ var tickObj = {
594
+ value: tickValue
595
+ };
596
+ result.push(onlyTick ? tickValue : {
597
+ formattedLabel: labelFormatter(tickObj),
598
+ rawLabel: ordinalScale.getLabel(tickObj),
599
+ tickValue: tickValue
600
+ });
601
+ }
602
+
603
+ return result;
604
+ }
605
+
606
+ function makeLabelsByCustomizedCategoryInterval(axis, categoryInterval, onlyTick) {
607
+ var ordinalScale = axis.scale;
608
+ var labelFormatter = installCanvasRenderer.makeLabelFormatter(axis);
609
+ var result = [];
610
+ installCanvasRenderer.each(ordinalScale.getTicks(), function (tick) {
611
+ var rawLabel = ordinalScale.getLabel(tick);
612
+ var tickValue = tick.value;
613
+
614
+ if (categoryInterval(tick.value, rawLabel)) {
615
+ result.push(onlyTick ? tickValue : {
616
+ formattedLabel: labelFormatter(tick),
617
+ rawLabel: rawLabel,
618
+ tickValue: tickValue
619
+ });
620
+ }
621
+ });
622
+ return result;
623
+ }
624
+
625
+ var NORMALIZED_EXTENT = [0, 1];
626
+ /**
627
+ * Base class of Axis.
628
+ */
629
+
630
+ var Axis =
631
+ /** @class */
632
+ function () {
633
+ function Axis(dim, scale, extent) {
634
+ this.onBand = false;
635
+ this.inverse = false;
636
+ this.dim = dim;
637
+ this.scale = scale;
638
+ this._extent = extent || [0, 0];
639
+ }
640
+ /**
641
+ * If axis extent contain given coord
642
+ */
643
+
644
+
645
+ Axis.prototype.contain = function (coord) {
646
+ var extent = this._extent;
647
+ var min = Math.min(extent[0], extent[1]);
648
+ var max = Math.max(extent[0], extent[1]);
649
+ return coord >= min && coord <= max;
650
+ };
651
+ /**
652
+ * If axis extent contain given data
653
+ */
654
+
655
+
656
+ Axis.prototype.containData = function (data) {
657
+ return this.scale.contain(data);
658
+ };
659
+ /**
660
+ * Get coord extent.
661
+ */
662
+
663
+
664
+ Axis.prototype.getExtent = function () {
665
+ return this._extent.slice();
666
+ };
667
+ /**
668
+ * Get precision used for formatting
669
+ */
670
+
671
+
672
+ Axis.prototype.getPixelPrecision = function (dataExtent) {
673
+ return installCanvasRenderer.getPixelPrecision(dataExtent || this.scale.getExtent(), this._extent);
674
+ };
675
+ /**
676
+ * Set coord extent
677
+ */
678
+
679
+
680
+ Axis.prototype.setExtent = function (start, end) {
681
+ var extent = this._extent;
682
+ extent[0] = start;
683
+ extent[1] = end;
684
+ };
685
+ /**
686
+ * Convert data to coord. Data is the rank if it has an ordinal scale
687
+ */
688
+
689
+
690
+ Axis.prototype.dataToCoord = function (data, clamp) {
691
+ var extent = this._extent;
692
+ var scale = this.scale;
693
+ data = scale.normalize(data);
694
+
695
+ if (this.onBand && scale.type === 'ordinal') {
696
+ extent = extent.slice();
697
+ fixExtentWithBands(extent, scale.count());
698
+ }
699
+
700
+ return installCanvasRenderer.linearMap(data, NORMALIZED_EXTENT, extent, clamp);
701
+ };
702
+ /**
703
+ * Convert coord to data. Data is the rank if it has an ordinal scale
704
+ */
705
+
706
+
707
+ Axis.prototype.coordToData = function (coord, clamp) {
708
+ var extent = this._extent;
709
+ var scale = this.scale;
710
+
711
+ if (this.onBand && scale.type === 'ordinal') {
712
+ extent = extent.slice();
713
+ fixExtentWithBands(extent, scale.count());
714
+ }
715
+
716
+ var t = installCanvasRenderer.linearMap(coord, extent, NORMALIZED_EXTENT, clamp);
717
+ return this.scale.scale(t);
718
+ };
719
+ /**
720
+ * Convert pixel point to data in axis
721
+ */
722
+
723
+
724
+ Axis.prototype.pointToData = function (point, clamp) {
725
+ // Should be implemented in derived class if necessary.
726
+ return;
727
+ };
728
+ /**
729
+ * Different from `zrUtil.map(axis.getTicks(), axis.dataToCoord, axis)`,
730
+ * `axis.getTicksCoords` considers `onBand`, which is used by
731
+ * `boundaryGap:true` of category axis and splitLine and splitArea.
732
+ * @param opt.tickModel default: axis.model.getModel('axisTick')
733
+ * @param opt.clamp If `true`, the first and the last
734
+ * tick must be at the axis end points. Otherwise, clip ticks
735
+ * that outside the axis extent.
736
+ */
737
+
738
+
739
+ Axis.prototype.getTicksCoords = function (opt) {
740
+ opt = opt || {};
741
+ var tickModel = opt.tickModel || this.getTickModel();
742
+ var result = createAxisTicks(this, tickModel);
743
+ var ticks = result.ticks;
744
+ var ticksCoords = installCanvasRenderer.map(ticks, function (tickVal) {
745
+ return {
746
+ coord: this.dataToCoord(this.scale.type === 'ordinal' ? this.scale.getRawOrdinalNumber(tickVal) : tickVal),
747
+ tickValue: tickVal
748
+ };
749
+ }, this);
750
+ var alignWithLabel = tickModel.get('alignWithLabel');
751
+ fixOnBandTicksCoords(this, ticksCoords, alignWithLabel, opt.clamp);
752
+ return ticksCoords;
753
+ };
754
+
755
+ Axis.prototype.getMinorTicksCoords = function () {
756
+ if (this.scale.type === 'ordinal') {
757
+ // Category axis doesn't support minor ticks
758
+ return [];
759
+ }
760
+
761
+ var minorTickModel = this.model.getModel('minorTick');
762
+ var splitNumber = minorTickModel.get('splitNumber'); // Protection.
763
+
764
+ if (!(splitNumber > 0 && splitNumber < 100)) {
765
+ splitNumber = 5;
766
+ }
767
+
768
+ var minorTicks = this.scale.getMinorTicks(splitNumber);
769
+ var minorTicksCoords = installCanvasRenderer.map(minorTicks, function (minorTicksGroup) {
770
+ return installCanvasRenderer.map(minorTicksGroup, function (minorTick) {
771
+ return {
772
+ coord: this.dataToCoord(minorTick),
773
+ tickValue: minorTick
774
+ };
775
+ }, this);
776
+ }, this);
777
+ return minorTicksCoords;
778
+ };
779
+
780
+ Axis.prototype.getViewLabels = function () {
781
+ return createAxisLabels(this).labels;
782
+ };
783
+
784
+ Axis.prototype.getLabelModel = function () {
785
+ return this.model.getModel('axisLabel');
786
+ };
787
+ /**
788
+ * Notice here we only get the default tick model. For splitLine
789
+ * or splitArea, we should pass the splitLineModel or splitAreaModel
790
+ * manually when calling `getTicksCoords`.
791
+ * In GL, this method may be overridden to:
792
+ * `axisModel.getModel('axisTick', grid3DModel.getModel('axisTick'));`
793
+ */
794
+
795
+
796
+ Axis.prototype.getTickModel = function () {
797
+ return this.model.getModel('axisTick');
798
+ };
799
+ /**
800
+ * Get width of band
801
+ */
802
+
803
+
804
+ Axis.prototype.getBandWidth = function () {
805
+ var axisExtent = this._extent;
806
+ var dataExtent = this.scale.getExtent();
807
+ var len = dataExtent[1] - dataExtent[0] + (this.onBand ? 1 : 0); // Fix #2728, avoid NaN when only one data.
808
+
809
+ len === 0 && (len = 1);
810
+ var size = Math.abs(axisExtent[1] - axisExtent[0]);
811
+ return Math.abs(size) / len;
812
+ };
813
+ /**
814
+ * Only be called in category axis.
815
+ * Can be overridden, consider other axes like in 3D.
816
+ * @return Auto interval for cateogry axis tick and label
817
+ */
818
+
819
+
820
+ Axis.prototype.calculateCategoryInterval = function () {
821
+ return calculateCategoryInterval(this);
822
+ };
823
+
824
+ return Axis;
825
+ }();
826
+
827
+ function fixExtentWithBands(extent, nTick) {
828
+ var size = extent[1] - extent[0];
829
+ var len = nTick;
830
+ var margin = size / len / 2;
831
+ extent[0] += margin;
832
+ extent[1] -= margin;
833
+ } // If axis has labels [1, 2, 3, 4]. Bands on the axis are
834
+ // |---1---|---2---|---3---|---4---|.
835
+ // So the displayed ticks and splitLine/splitArea should between
836
+ // each data item, otherwise cause misleading (e.g., split tow bars
837
+ // of a single data item when there are two bar series).
838
+ // Also consider if tickCategoryInterval > 0 and onBand, ticks and
839
+ // splitLine/spliteArea should layout appropriately corresponding
840
+ // to displayed labels. (So we should not use `getBandWidth` in this
841
+ // case).
842
+
843
+
844
+ function fixOnBandTicksCoords(axis, ticksCoords, alignWithLabel, clamp) {
845
+ var ticksLen = ticksCoords.length;
846
+
847
+ if (!axis.onBand || alignWithLabel || !ticksLen) {
848
+ return;
849
+ }
850
+
851
+ var axisExtent = axis.getExtent();
852
+ var last;
853
+ var diffSize;
854
+
855
+ if (ticksLen === 1) {
856
+ ticksCoords[0].coord = axisExtent[0];
857
+ last = ticksCoords[1] = {
858
+ coord: axisExtent[0]
859
+ };
860
+ } else {
861
+ var crossLen = ticksCoords[ticksLen - 1].tickValue - ticksCoords[0].tickValue;
862
+ var shift_1 = (ticksCoords[ticksLen - 1].coord - ticksCoords[0].coord) / crossLen;
863
+ installCanvasRenderer.each(ticksCoords, function (ticksItem) {
864
+ ticksItem.coord -= shift_1 / 2;
865
+ });
866
+ var dataExtent = axis.scale.getExtent();
867
+ diffSize = 1 + dataExtent[1] - ticksCoords[ticksLen - 1].tickValue;
868
+ last = {
869
+ coord: ticksCoords[ticksLen - 1].coord + shift_1 * diffSize
870
+ };
871
+ ticksCoords.push(last);
872
+ }
873
+
874
+ var inverse = axisExtent[0] > axisExtent[1]; // Handling clamp.
875
+
876
+ if (littleThan(ticksCoords[0].coord, axisExtent[0])) {
877
+ clamp ? ticksCoords[0].coord = axisExtent[0] : ticksCoords.shift();
878
+ }
879
+
880
+ if (clamp && littleThan(axisExtent[0], ticksCoords[0].coord)) {
881
+ ticksCoords.unshift({
882
+ coord: axisExtent[0]
883
+ });
884
+ }
885
+
886
+ if (littleThan(axisExtent[1], last.coord)) {
887
+ clamp ? last.coord = axisExtent[1] : ticksCoords.pop();
888
+ }
889
+
890
+ if (clamp && littleThan(last.coord, axisExtent[1])) {
891
+ ticksCoords.push({
892
+ coord: axisExtent[1]
893
+ });
894
+ }
895
+
896
+ function littleThan(a, b) {
897
+ // Avoid rounding error cause calculated tick coord different with extent.
898
+ // It may cause an extra unnecessary tick added.
899
+ a = installCanvasRenderer.round(a);
900
+ b = installCanvasRenderer.round(b);
901
+ return inverse ? a > b : a < b;
902
+ }
903
+ }
904
+
905
+ var GridModel =
906
+ /** @class */
907
+ function (_super) {
908
+ installCanvasRenderer.__extends(GridModel, _super);
909
+
910
+ function GridModel() {
911
+ return _super !== null && _super.apply(this, arguments) || this;
912
+ }
913
+
914
+ GridModel.type = 'grid';
915
+ GridModel.dependencies = ['xAxis', 'yAxis'];
916
+ GridModel.layoutMode = 'box';
917
+ GridModel.defaultOption = {
918
+ show: false,
919
+ // zlevel: 0,
920
+ z: 0,
921
+ left: '10%',
922
+ top: 60,
923
+ right: '10%',
924
+ bottom: 70,
925
+ // If grid size contain label
926
+ containLabel: false,
927
+ // width: {totalWidth} - left - right,
928
+ // height: {totalHeight} - top - bottom,
929
+ backgroundColor: 'rgba(0,0,0,0)',
930
+ borderWidth: 1,
931
+ borderColor: '#ccc'
932
+ };
933
+ return GridModel;
934
+ }(installCanvasRenderer.ComponentModel);
935
+
936
+ var CartesianAxisModel =
937
+ /** @class */
938
+ function (_super) {
939
+ installCanvasRenderer.__extends(CartesianAxisModel, _super);
940
+
941
+ function CartesianAxisModel() {
942
+ return _super !== null && _super.apply(this, arguments) || this;
943
+ }
944
+
945
+ CartesianAxisModel.prototype.getCoordSysModel = function () {
946
+ return this.getReferringComponents('grid', installCanvasRenderer.SINGLE_REFERRING).models[0];
947
+ };
948
+
949
+ CartesianAxisModel.type = 'cartesian2dAxis';
950
+ return CartesianAxisModel;
951
+ }(installCanvasRenderer.ComponentModel);
952
+ installCanvasRenderer.mixin(CartesianAxisModel, AxisModelCommonMixin);
953
+
954
+ var defaultOption = {
955
+ show: true,
956
+ // zlevel: 0,
957
+ z: 0,
958
+ // Inverse the axis.
959
+ inverse: false,
960
+ // Axis name displayed.
961
+ name: '',
962
+ // 'start' | 'middle' | 'end'
963
+ nameLocation: 'end',
964
+ // By degree. By default auto rotate by nameLocation.
965
+ nameRotate: null,
966
+ nameTruncate: {
967
+ maxWidth: null,
968
+ ellipsis: '...',
969
+ placeholder: '.'
970
+ },
971
+ // Use global text style by default.
972
+ nameTextStyle: {},
973
+ // The gap between axisName and axisLine.
974
+ nameGap: 15,
975
+ // Default `false` to support tooltip.
976
+ silent: false,
977
+ // Default `false` to avoid legacy user event listener fail.
978
+ triggerEvent: false,
979
+ tooltip: {
980
+ show: false
981
+ },
982
+ axisPointer: {},
983
+ axisLine: {
984
+ show: true,
985
+ onZero: true,
986
+ onZeroAxisIndex: null,
987
+ lineStyle: {
988
+ color: '#6E7079',
989
+ width: 1,
990
+ type: 'solid'
991
+ },
992
+ // The arrow at both ends the the axis.
993
+ symbol: ['none', 'none'],
994
+ symbolSize: [10, 15]
995
+ },
996
+ axisTick: {
997
+ show: true,
998
+ // Whether axisTick is inside the grid or outside the grid.
999
+ inside: false,
1000
+ // The length of axisTick.
1001
+ length: 5,
1002
+ lineStyle: {
1003
+ width: 1
1004
+ }
1005
+ },
1006
+ axisLabel: {
1007
+ show: true,
1008
+ // Whether axisLabel is inside the grid or outside the grid.
1009
+ inside: false,
1010
+ rotate: 0,
1011
+ // true | false | null/undefined (auto)
1012
+ showMinLabel: null,
1013
+ // true | false | null/undefined (auto)
1014
+ showMaxLabel: null,
1015
+ margin: 8,
1016
+ // formatter: null,
1017
+ fontSize: 12
1018
+ },
1019
+ splitLine: {
1020
+ show: true,
1021
+ lineStyle: {
1022
+ color: ['#E0E6F1'],
1023
+ width: 1,
1024
+ type: 'solid'
1025
+ }
1026
+ },
1027
+ splitArea: {
1028
+ show: false,
1029
+ areaStyle: {
1030
+ color: ['rgba(250,250,250,0.2)', 'rgba(210,219,238,0.2)']
1031
+ }
1032
+ }
1033
+ };
1034
+ var categoryAxis = installCanvasRenderer.merge({
1035
+ // The gap at both ends of the axis. For categoryAxis, boolean.
1036
+ boundaryGap: true,
1037
+ // Set false to faster category collection.
1038
+ deduplication: null,
1039
+ // splitArea: {
1040
+ // show: false
1041
+ // },
1042
+ splitLine: {
1043
+ show: false
1044
+ },
1045
+ axisTick: {
1046
+ // If tick is align with label when boundaryGap is true
1047
+ alignWithLabel: false,
1048
+ interval: 'auto'
1049
+ },
1050
+ axisLabel: {
1051
+ interval: 'auto'
1052
+ }
1053
+ }, defaultOption);
1054
+ var valueAxis = installCanvasRenderer.merge({
1055
+ boundaryGap: [0, 0],
1056
+ axisLine: {
1057
+ // Not shown when other axis is categoryAxis in cartesian
1058
+ show: 'auto'
1059
+ },
1060
+ axisTick: {
1061
+ // Not shown when other axis is categoryAxis in cartesian
1062
+ show: 'auto'
1063
+ },
1064
+ // TODO
1065
+ // min/max: [30, datamin, 60] or [20, datamin] or [datamin, 60]
1066
+ splitNumber: 5,
1067
+ minorTick: {
1068
+ // Minor tick, not available for cateogry axis.
1069
+ show: false,
1070
+ // Split number of minor ticks. The value should be in range of (0, 100)
1071
+ splitNumber: 5,
1072
+ // Length of minor tick
1073
+ length: 3,
1074
+ // Line style
1075
+ lineStyle: {// Default to be same with axisTick
1076
+ }
1077
+ },
1078
+ minorSplitLine: {
1079
+ show: false,
1080
+ lineStyle: {
1081
+ color: '#F4F7FD',
1082
+ width: 1
1083
+ }
1084
+ }
1085
+ }, defaultOption);
1086
+ var timeAxis = installCanvasRenderer.merge({
1087
+ splitNumber: 6,
1088
+ axisLabel: {
1089
+ // To eliminate labels that are not nice
1090
+ showMinLabel: false,
1091
+ showMaxLabel: false,
1092
+ rich: {
1093
+ primary: {
1094
+ fontWeight: 'bold'
1095
+ }
1096
+ }
1097
+ },
1098
+ splitLine: {
1099
+ show: false
1100
+ }
1101
+ }, valueAxis);
1102
+ var logAxis = installCanvasRenderer.defaults({
1103
+ logBase: 10
1104
+ }, valueAxis);
1105
+ const axisDefault = {
1106
+ category: categoryAxis,
1107
+ value: valueAxis,
1108
+ time: timeAxis,
1109
+ log: logAxis
1110
+ };
1111
+
1112
+ /*
1113
+ * Licensed to the Apache Software Foundation (ASF) under one
1114
+ * or more contributor license agreements. See the NOTICE file
1115
+ * distributed with this work for additional information
1116
+ * regarding copyright ownership. The ASF licenses this file
1117
+ * to you under the Apache License, Version 2.0 (the
1118
+ * "License"); you may not use this file except in compliance
1119
+ * with the License. You may obtain a copy of the License at
1120
+ *
1121
+ * http://www.apache.org/licenses/LICENSE-2.0
1122
+ *
1123
+ * Unless required by applicable law or agreed to in writing,
1124
+ * software distributed under the License is distributed on an
1125
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1126
+ * KIND, either express or implied. See the License for the
1127
+ * specific language governing permissions and limitations
1128
+ * under the License.
1129
+ */
1130
+
1131
+
1132
+ /**
1133
+ * AUTO-GENERATED FILE. DO NOT MODIFY.
1134
+ */
1135
+
1136
+ /*
1137
+ * Licensed to the Apache Software Foundation (ASF) under one
1138
+ * or more contributor license agreements. See the NOTICE file
1139
+ * distributed with this work for additional information
1140
+ * regarding copyright ownership. The ASF licenses this file
1141
+ * to you under the Apache License, Version 2.0 (the
1142
+ * "License"); you may not use this file except in compliance
1143
+ * with the License. You may obtain a copy of the License at
1144
+ *
1145
+ * http://www.apache.org/licenses/LICENSE-2.0
1146
+ *
1147
+ * Unless required by applicable law or agreed to in writing,
1148
+ * software distributed under the License is distributed on an
1149
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1150
+ * KIND, either express or implied. See the License for the
1151
+ * specific language governing permissions and limitations
1152
+ * under the License.
1153
+ */
1154
+ var AXIS_TYPES = {
1155
+ value: 1,
1156
+ category: 1,
1157
+ time: 1,
1158
+ log: 1
1159
+ };
1160
+
1161
+ /**
1162
+ * Generate sub axis model class
1163
+ * @param axisName 'x' 'y' 'radius' 'angle' 'parallel' ...
1164
+ */
1165
+
1166
+ function axisModelCreator(registers, axisName, BaseAxisModelClass, extraDefaultOption) {
1167
+ installCanvasRenderer.each(AXIS_TYPES, function (v, axisType) {
1168
+ var defaultOption = installCanvasRenderer.merge(installCanvasRenderer.merge({}, axisDefault[axisType], true), extraDefaultOption, true);
1169
+
1170
+ var AxisModel =
1171
+ /** @class */
1172
+ function (_super) {
1173
+ installCanvasRenderer.__extends(AxisModel, _super);
1174
+
1175
+ function AxisModel() {
1176
+ var _this = _super !== null && _super.apply(this, arguments) || this;
1177
+
1178
+ _this.type = axisName + 'Axis.' + axisType;
1179
+ return _this;
1180
+ }
1181
+
1182
+ AxisModel.prototype.mergeDefaultAndTheme = function (option, ecModel) {
1183
+ var layoutMode = installCanvasRenderer.fetchLayoutMode(this);
1184
+ var inputPositionParams = layoutMode ? installCanvasRenderer.getLayoutParams(option) : {};
1185
+ var themeModel = ecModel.getTheme();
1186
+ installCanvasRenderer.merge(option, themeModel.get(axisType + 'Axis'));
1187
+ installCanvasRenderer.merge(option, this.getDefaultOption());
1188
+ option.type = getAxisType(option);
1189
+
1190
+ if (layoutMode) {
1191
+ installCanvasRenderer.mergeLayoutParam(option, inputPositionParams, layoutMode);
1192
+ }
1193
+ };
1194
+
1195
+ AxisModel.prototype.optionUpdated = function () {
1196
+ var thisOption = this.option;
1197
+
1198
+ if (thisOption.type === 'category') {
1199
+ this.__ordinalMeta = installCanvasRenderer.OrdinalMeta.createByAxisModel(this);
1200
+ }
1201
+ };
1202
+ /**
1203
+ * Should not be called before all of 'getInitailData' finished.
1204
+ * Because categories are collected during initializing data.
1205
+ */
1206
+
1207
+
1208
+ AxisModel.prototype.getCategories = function (rawData) {
1209
+ var option = this.option; // FIXME
1210
+ // warning if called before all of 'getInitailData' finished.
1211
+
1212
+ if (option.type === 'category') {
1213
+ if (rawData) {
1214
+ return option.data;
1215
+ }
1216
+
1217
+ return this.__ordinalMeta.categories;
1218
+ }
1219
+ };
1220
+
1221
+ AxisModel.prototype.getOrdinalMeta = function () {
1222
+ return this.__ordinalMeta;
1223
+ };
1224
+
1225
+ AxisModel.type = axisName + 'Axis.' + axisType;
1226
+ AxisModel.defaultOption = defaultOption;
1227
+ return AxisModel;
1228
+ }(BaseAxisModelClass);
1229
+
1230
+ registers.registerComponentModel(AxisModel);
1231
+ });
1232
+ registers.registerSubTypeDefaulter(axisName + 'Axis', getAxisType);
1233
+ }
1234
+
1235
+ function getAxisType(option) {
1236
+ // Default axis with data is category axis
1237
+ return option.type || (option.data ? 'category' : 'value');
1238
+ }
1239
+
1240
+ var Cartesian =
1241
+ /** @class */
1242
+ function () {
1243
+ function Cartesian(name) {
1244
+ this.type = 'cartesian';
1245
+ this._dimList = [];
1246
+ this._axes = {};
1247
+ this.name = name || '';
1248
+ }
1249
+
1250
+ Cartesian.prototype.getAxis = function (dim) {
1251
+ return this._axes[dim];
1252
+ };
1253
+
1254
+ Cartesian.prototype.getAxes = function () {
1255
+ return installCanvasRenderer.map(this._dimList, function (dim) {
1256
+ return this._axes[dim];
1257
+ }, this);
1258
+ };
1259
+
1260
+ Cartesian.prototype.getAxesByScale = function (scaleType) {
1261
+ scaleType = scaleType.toLowerCase();
1262
+ return installCanvasRenderer.filter(this.getAxes(), function (axis) {
1263
+ return axis.scale.type === scaleType;
1264
+ });
1265
+ };
1266
+
1267
+ Cartesian.prototype.addAxis = function (axis) {
1268
+ var dim = axis.dim;
1269
+ this._axes[dim] = axis;
1270
+
1271
+ this._dimList.push(dim);
1272
+ };
1273
+
1274
+ return Cartesian;
1275
+ }();
1276
+
1277
+ var cartesian2DDimensions = ['x', 'y'];
1278
+
1279
+ function canCalculateAffineTransform(scale) {
1280
+ return scale.type === 'interval' || scale.type === 'time';
1281
+ }
1282
+
1283
+ var Cartesian2D =
1284
+ /** @class */
1285
+ function (_super) {
1286
+ installCanvasRenderer.__extends(Cartesian2D, _super);
1287
+
1288
+ function Cartesian2D() {
1289
+ var _this = _super !== null && _super.apply(this, arguments) || this;
1290
+
1291
+ _this.type = 'cartesian2d';
1292
+ _this.dimensions = cartesian2DDimensions;
1293
+ return _this;
1294
+ }
1295
+ /**
1296
+ * Calculate an affine transform matrix if two axes are time or value.
1297
+ * It's mainly for accelartion on the large time series data.
1298
+ */
1299
+
1300
+
1301
+ Cartesian2D.prototype.calcAffineTransform = function () {
1302
+ this._transform = this._invTransform = null;
1303
+ var xAxisScale = this.getAxis('x').scale;
1304
+ var yAxisScale = this.getAxis('y').scale;
1305
+
1306
+ if (!canCalculateAffineTransform(xAxisScale) || !canCalculateAffineTransform(yAxisScale)) {
1307
+ return;
1308
+ }
1309
+
1310
+ var xScaleExtent = xAxisScale.getExtent();
1311
+ var yScaleExtent = yAxisScale.getExtent();
1312
+ var start = this.dataToPoint([xScaleExtent[0], yScaleExtent[0]]);
1313
+ var end = this.dataToPoint([xScaleExtent[1], yScaleExtent[1]]);
1314
+ var xScaleSpan = xScaleExtent[1] - xScaleExtent[0];
1315
+ var yScaleSpan = yScaleExtent[1] - yScaleExtent[0];
1316
+
1317
+ if (!xScaleSpan || !yScaleSpan) {
1318
+ return;
1319
+ } // Accelerate data to point calculation on the special large time series data.
1320
+
1321
+
1322
+ var scaleX = (end[0] - start[0]) / xScaleSpan;
1323
+ var scaleY = (end[1] - start[1]) / yScaleSpan;
1324
+ var translateX = start[0] - xScaleExtent[0] * scaleX;
1325
+ var translateY = start[1] - yScaleExtent[0] * scaleY;
1326
+ var m = this._transform = [scaleX, 0, 0, scaleY, translateX, translateY];
1327
+ this._invTransform = installCanvasRenderer.invert([], m);
1328
+ };
1329
+ /**
1330
+ * Base axis will be used on stacking.
1331
+ */
1332
+
1333
+
1334
+ Cartesian2D.prototype.getBaseAxis = function () {
1335
+ return this.getAxesByScale('ordinal')[0] || this.getAxesByScale('time')[0] || this.getAxis('x');
1336
+ };
1337
+
1338
+ Cartesian2D.prototype.containPoint = function (point) {
1339
+ var axisX = this.getAxis('x');
1340
+ var axisY = this.getAxis('y');
1341
+ return axisX.contain(axisX.toLocalCoord(point[0])) && axisY.contain(axisY.toLocalCoord(point[1]));
1342
+ };
1343
+
1344
+ Cartesian2D.prototype.containData = function (data) {
1345
+ return this.getAxis('x').containData(data[0]) && this.getAxis('y').containData(data[1]);
1346
+ };
1347
+
1348
+ Cartesian2D.prototype.containZone = function (data1, data2) {
1349
+ var zoneDiag1 = this.dataToPoint(data1);
1350
+ var zoneDiag2 = this.dataToPoint(data2);
1351
+ var area = this.getArea();
1352
+ var zone = new installCanvasRenderer.BoundingRect(zoneDiag1[0], zoneDiag1[1], zoneDiag2[0] - zoneDiag1[0], zoneDiag2[1] - zoneDiag1[1]);
1353
+ return area.intersect(zone);
1354
+ };
1355
+
1356
+ Cartesian2D.prototype.dataToPoint = function (data, clamp, out) {
1357
+ out = out || [];
1358
+ var xVal = data[0];
1359
+ var yVal = data[1]; // Fast path
1360
+
1361
+ if (this._transform // It's supported that if data is like `[Inifity, 123]`, where only Y pixel calculated.
1362
+ && xVal != null && isFinite(xVal) && yVal != null && isFinite(yVal)) {
1363
+ return installCanvasRenderer.applyTransform(out, data, this._transform);
1364
+ }
1365
+
1366
+ var xAxis = this.getAxis('x');
1367
+ var yAxis = this.getAxis('y');
1368
+ out[0] = xAxis.toGlobalCoord(xAxis.dataToCoord(xVal, clamp));
1369
+ out[1] = yAxis.toGlobalCoord(yAxis.dataToCoord(yVal, clamp));
1370
+ return out;
1371
+ };
1372
+
1373
+ Cartesian2D.prototype.clampData = function (data, out) {
1374
+ var xScale = this.getAxis('x').scale;
1375
+ var yScale = this.getAxis('y').scale;
1376
+ var xAxisExtent = xScale.getExtent();
1377
+ var yAxisExtent = yScale.getExtent();
1378
+ var x = xScale.parse(data[0]);
1379
+ var y = yScale.parse(data[1]);
1380
+ out = out || [];
1381
+ out[0] = Math.min(Math.max(Math.min(xAxisExtent[0], xAxisExtent[1]), x), Math.max(xAxisExtent[0], xAxisExtent[1]));
1382
+ out[1] = Math.min(Math.max(Math.min(yAxisExtent[0], yAxisExtent[1]), y), Math.max(yAxisExtent[0], yAxisExtent[1]));
1383
+ return out;
1384
+ };
1385
+
1386
+ Cartesian2D.prototype.pointToData = function (point, clamp) {
1387
+ var out = [];
1388
+
1389
+ if (this._invTransform) {
1390
+ return installCanvasRenderer.applyTransform(out, point, this._invTransform);
1391
+ }
1392
+
1393
+ var xAxis = this.getAxis('x');
1394
+ var yAxis = this.getAxis('y');
1395
+ out[0] = xAxis.coordToData(xAxis.toLocalCoord(point[0]), clamp);
1396
+ out[1] = yAxis.coordToData(yAxis.toLocalCoord(point[1]), clamp);
1397
+ return out;
1398
+ };
1399
+
1400
+ Cartesian2D.prototype.getOtherAxis = function (axis) {
1401
+ return this.getAxis(axis.dim === 'x' ? 'y' : 'x');
1402
+ };
1403
+ /**
1404
+ * Get rect area of cartesian.
1405
+ * Area will have a contain function to determine if a point is in the coordinate system.
1406
+ */
1407
+
1408
+
1409
+ Cartesian2D.prototype.getArea = function () {
1410
+ var xExtent = this.getAxis('x').getGlobalExtent();
1411
+ var yExtent = this.getAxis('y').getGlobalExtent();
1412
+ var x = Math.min(xExtent[0], xExtent[1]);
1413
+ var y = Math.min(yExtent[0], yExtent[1]);
1414
+ var width = Math.max(xExtent[0], xExtent[1]) - x;
1415
+ var height = Math.max(yExtent[0], yExtent[1]) - y;
1416
+ return new installCanvasRenderer.BoundingRect(x, y, width, height);
1417
+ };
1418
+
1419
+ return Cartesian2D;
1420
+ }(Cartesian);
1421
+
1422
+ var Axis2D =
1423
+ /** @class */
1424
+ function (_super) {
1425
+ installCanvasRenderer.__extends(Axis2D, _super);
1426
+
1427
+ function Axis2D(dim, scale, coordExtent, axisType, position) {
1428
+ var _this = _super.call(this, dim, scale, coordExtent) || this;
1429
+ /**
1430
+ * Index of axis, can be used as key
1431
+ * Injected outside.
1432
+ */
1433
+
1434
+
1435
+ _this.index = 0;
1436
+ _this.type = axisType || 'value';
1437
+ _this.position = position || 'bottom';
1438
+ return _this;
1439
+ }
1440
+
1441
+ Axis2D.prototype.isHorizontal = function () {
1442
+ var position = this.position;
1443
+ return position === 'top' || position === 'bottom';
1444
+ };
1445
+ /**
1446
+ * Each item cooresponds to this.getExtent(), which
1447
+ * means globalExtent[0] may greater than globalExtent[1],
1448
+ * unless `asc` is input.
1449
+ *
1450
+ * @param {boolean} [asc]
1451
+ * @return {Array.<number>}
1452
+ */
1453
+
1454
+
1455
+ Axis2D.prototype.getGlobalExtent = function (asc) {
1456
+ var ret = this.getExtent();
1457
+ ret[0] = this.toGlobalCoord(ret[0]);
1458
+ ret[1] = this.toGlobalCoord(ret[1]);
1459
+ asc && ret[0] > ret[1] && ret.reverse();
1460
+ return ret;
1461
+ };
1462
+
1463
+ Axis2D.prototype.pointToData = function (point, clamp) {
1464
+ return this.coordToData(this.toLocalCoord(point[this.dim === 'x' ? 0 : 1]), clamp);
1465
+ };
1466
+ /**
1467
+ * Set ordinalSortInfo
1468
+ * @param info new OrdinalSortInfo
1469
+ */
1470
+
1471
+
1472
+ Axis2D.prototype.setCategorySortInfo = function (info) {
1473
+ if (this.type !== 'category') {
1474
+ return false;
1475
+ }
1476
+
1477
+ this.model.option.categorySortInfo = info;
1478
+ this.scale.setSortInfo(info);
1479
+ };
1480
+
1481
+ return Axis2D;
1482
+ }(Axis);
1483
+
1484
+ var mathLog = Math.log;
1485
+ function alignScaleTicks(scale, axisModel, alignToScale) {
1486
+ var intervalScaleProto = installCanvasRenderer.IntervalScale.prototype; // NOTE: There is a precondition for log scale here:
1487
+ // In log scale we store _interval and _extent of exponent value.
1488
+ // So if we use the method of InternalScale to set/get these data.
1489
+ // It process the exponent value, which is linear and what we want here.
1490
+
1491
+ var alignToTicks = intervalScaleProto.getTicks.call(alignToScale);
1492
+ var alignToNicedTicks = intervalScaleProto.getTicks.call(alignToScale, true);
1493
+ var alignToSplitNumber = alignToTicks.length - 1;
1494
+ var alignToInterval = intervalScaleProto.getInterval.call(alignToScale);
1495
+ var scaleExtent = installCanvasRenderer.getScaleExtent(scale, axisModel);
1496
+ var rawExtent = scaleExtent.extent;
1497
+ var isMinFixed = scaleExtent.fixMin;
1498
+ var isMaxFixed = scaleExtent.fixMax;
1499
+
1500
+ if (scale.type === 'log') {
1501
+ var logBase = mathLog(scale.base);
1502
+ rawExtent = [mathLog(rawExtent[0]) / logBase, mathLog(rawExtent[1]) / logBase];
1503
+ }
1504
+
1505
+ scale.setExtent(rawExtent[0], rawExtent[1]);
1506
+ scale.calcNiceExtent({
1507
+ splitNumber: alignToSplitNumber,
1508
+ fixMin: isMinFixed,
1509
+ fixMax: isMaxFixed
1510
+ });
1511
+ var extent = intervalScaleProto.getExtent.call(scale); // Need to update the rawExtent.
1512
+ // Because value in rawExtent may be not parsed. e.g. 'dataMin', 'dataMax'
1513
+
1514
+ if (isMinFixed) {
1515
+ rawExtent[0] = extent[0];
1516
+ }
1517
+
1518
+ if (isMaxFixed) {
1519
+ rawExtent[1] = extent[1];
1520
+ }
1521
+
1522
+ var interval = intervalScaleProto.getInterval.call(scale);
1523
+ var min = rawExtent[0];
1524
+ var max = rawExtent[1];
1525
+
1526
+ if (isMinFixed && isMaxFixed) {
1527
+ // User set min, max, divide to get new interval
1528
+ interval = (max - min) / alignToSplitNumber;
1529
+ } else if (isMinFixed) {
1530
+ max = rawExtent[0] + interval * alignToSplitNumber; // User set min, expand extent on the other side
1531
+
1532
+ while (max < rawExtent[1] && isFinite(max) && isFinite(rawExtent[1])) {
1533
+ interval = installCanvasRenderer.increaseInterval(interval);
1534
+ max = rawExtent[0] + interval * alignToSplitNumber;
1535
+ }
1536
+ } else if (isMaxFixed) {
1537
+ // User set max, expand extent on the other side
1538
+ min = rawExtent[1] - interval * alignToSplitNumber;
1539
+
1540
+ while (min > rawExtent[0] && isFinite(min) && isFinite(rawExtent[0])) {
1541
+ interval = installCanvasRenderer.increaseInterval(interval);
1542
+ min = rawExtent[1] - interval * alignToSplitNumber;
1543
+ }
1544
+ } else {
1545
+ var nicedSplitNumber = scale.getTicks().length - 1;
1546
+
1547
+ if (nicedSplitNumber > alignToSplitNumber) {
1548
+ interval = installCanvasRenderer.increaseInterval(interval);
1549
+ }
1550
+
1551
+ var range = interval * alignToSplitNumber;
1552
+ max = Math.ceil(rawExtent[1] / interval) * interval;
1553
+ min = installCanvasRenderer.round(max - range); // Not change the result that crossing zero.
1554
+
1555
+ if (min < 0 && rawExtent[0] >= 0) {
1556
+ min = 0;
1557
+ max = installCanvasRenderer.round(range);
1558
+ } else if (max > 0 && rawExtent[1] <= 0) {
1559
+ max = 0;
1560
+ min = -installCanvasRenderer.round(range);
1561
+ }
1562
+ } // Adjust min, max based on the extent of alignTo. When min or max is set in alignTo scale
1563
+
1564
+
1565
+ var t0 = (alignToTicks[0].value - alignToNicedTicks[0].value) / alignToInterval;
1566
+ var t1 = (alignToTicks[alignToSplitNumber].value - alignToNicedTicks[alignToSplitNumber].value) / alignToInterval; // NOTE: Must in setExtent -> setInterval -> setNiceExtent order.
1567
+
1568
+ intervalScaleProto.setExtent.call(scale, min + interval * t0, max + interval * t1);
1569
+ intervalScaleProto.setInterval.call(scale, interval);
1570
+
1571
+ if (t0 || t1) {
1572
+ intervalScaleProto.setNiceExtent.call(scale, min + interval, max - interval);
1573
+ }
1574
+ }
1575
+
1576
+ var Grid =
1577
+ /** @class */
1578
+ function () {
1579
+ function Grid(gridModel, ecModel, api) {
1580
+ // FIXME:TS where used (different from registered type 'cartesian2d')?
1581
+ this.type = 'grid';
1582
+ this._coordsMap = {};
1583
+ this._coordsList = [];
1584
+ this._axesMap = {};
1585
+ this._axesList = [];
1586
+ this.axisPointerEnabled = true;
1587
+ this.dimensions = cartesian2DDimensions;
1588
+
1589
+ this._initCartesian(gridModel, ecModel, api);
1590
+
1591
+ this.model = gridModel;
1592
+ }
1593
+
1594
+ Grid.prototype.getRect = function () {
1595
+ return this._rect;
1596
+ };
1597
+
1598
+ Grid.prototype.update = function (ecModel, api) {
1599
+ var axesMap = this._axesMap;
1600
+
1601
+ this._updateScale(ecModel, this.model);
1602
+
1603
+ function updateAxisTicks(axes) {
1604
+ var alignTo; // Axis is added in order of axisIndex.
1605
+
1606
+ var axesIndices = installCanvasRenderer.keys(axes);
1607
+ var len = axesIndices.length;
1608
+
1609
+ if (!len) {
1610
+ return;
1611
+ }
1612
+
1613
+ var axisNeedsAlign = []; // Process once and calculate the ticks for those don't use alignTicks.
1614
+
1615
+ for (var i = len - 1; i >= 0; i--) {
1616
+ var idx = +axesIndices[i]; // Convert to number.
1617
+
1618
+ var axis = axes[idx];
1619
+ var model = axis.model;
1620
+ var scale = axis.scale;
1621
+
1622
+ if ( // Only value and log axis without interval support alignTicks.
1623
+ installCanvasRenderer.isIntervalOrLogScale(scale) && model.get('alignTicks') && model.get('interval') == null) {
1624
+ axisNeedsAlign.push(axis);
1625
+ } else {
1626
+ installCanvasRenderer.niceScaleExtent(scale, model);
1627
+
1628
+ if (installCanvasRenderer.isIntervalOrLogScale(scale)) {
1629
+ // Can only align to interval or log axis.
1630
+ alignTo = axis;
1631
+ }
1632
+ }
1633
+ }
1634
+ // PENDING. Should we find the axis that both set interval, min, max and align to this one?
1635
+
1636
+ if (axisNeedsAlign.length) {
1637
+ if (!alignTo) {
1638
+ alignTo = axisNeedsAlign.pop();
1639
+ installCanvasRenderer.niceScaleExtent(alignTo.scale, alignTo.model);
1640
+ }
1641
+
1642
+ installCanvasRenderer.each(axisNeedsAlign, function (axis) {
1643
+ alignScaleTicks(axis.scale, axis.model, alignTo.scale);
1644
+ });
1645
+ }
1646
+ }
1647
+
1648
+ updateAxisTicks(axesMap.x);
1649
+ updateAxisTicks(axesMap.y); // Key: axisDim_axisIndex, value: boolean, whether onZero target.
1650
+
1651
+ var onZeroRecords = {};
1652
+ installCanvasRenderer.each(axesMap.x, function (xAxis) {
1653
+ fixAxisOnZero(axesMap, 'y', xAxis, onZeroRecords);
1654
+ });
1655
+ installCanvasRenderer.each(axesMap.y, function (yAxis) {
1656
+ fixAxisOnZero(axesMap, 'x', yAxis, onZeroRecords);
1657
+ }); // Resize again if containLabel is enabled
1658
+ // FIXME It may cause getting wrong grid size in data processing stage
1659
+
1660
+ this.resize(this.model, api);
1661
+ };
1662
+ /**
1663
+ * Resize the grid
1664
+ */
1665
+
1666
+
1667
+ Grid.prototype.resize = function (gridModel, api, ignoreContainLabel) {
1668
+ var boxLayoutParams = gridModel.getBoxLayoutParams();
1669
+ var isContainLabel = !ignoreContainLabel && gridModel.get('containLabel');
1670
+ var gridRect = installCanvasRenderer.getLayoutRect(boxLayoutParams, {
1671
+ width: api.getWidth(),
1672
+ height: api.getHeight()
1673
+ });
1674
+ this._rect = gridRect;
1675
+ var axesList = this._axesList;
1676
+ adjustAxes(); // Minus label size
1677
+
1678
+ if (isContainLabel) {
1679
+ installCanvasRenderer.each(axesList, function (axis) {
1680
+ if (!axis.model.get(['axisLabel', 'inside'])) {
1681
+ var labelUnionRect = installCanvasRenderer.estimateLabelUnionRect(axis);
1682
+
1683
+ if (labelUnionRect) {
1684
+ var dim = axis.isHorizontal() ? 'height' : 'width';
1685
+ var margin = axis.model.get(['axisLabel', 'margin']);
1686
+ gridRect[dim] -= labelUnionRect[dim] + margin;
1687
+
1688
+ if (axis.position === 'top') {
1689
+ gridRect.y += labelUnionRect.height + margin;
1690
+ } else if (axis.position === 'left') {
1691
+ gridRect.x += labelUnionRect.width + margin;
1692
+ }
1693
+ }
1694
+ }
1695
+ });
1696
+ adjustAxes();
1697
+ }
1698
+
1699
+ installCanvasRenderer.each(this._coordsList, function (coord) {
1700
+ // Calculate affine matrix to accelerate the data to point transform.
1701
+ // If all the axes scales are time or value.
1702
+ coord.calcAffineTransform();
1703
+ });
1704
+
1705
+ function adjustAxes() {
1706
+ installCanvasRenderer.each(axesList, function (axis) {
1707
+ var isHorizontal = axis.isHorizontal();
1708
+ var extent = isHorizontal ? [0, gridRect.width] : [0, gridRect.height];
1709
+ var idx = axis.inverse ? 1 : 0;
1710
+ axis.setExtent(extent[idx], extent[1 - idx]);
1711
+ updateAxisTransform(axis, isHorizontal ? gridRect.x : gridRect.y);
1712
+ });
1713
+ }
1714
+ };
1715
+
1716
+ Grid.prototype.getAxis = function (dim, axisIndex) {
1717
+ var axesMapOnDim = this._axesMap[dim];
1718
+
1719
+ if (axesMapOnDim != null) {
1720
+ return axesMapOnDim[axisIndex || 0];
1721
+ }
1722
+ };
1723
+
1724
+ Grid.prototype.getAxes = function () {
1725
+ return this._axesList.slice();
1726
+ };
1727
+
1728
+ Grid.prototype.getCartesian = function (xAxisIndex, yAxisIndex) {
1729
+ if (xAxisIndex != null && yAxisIndex != null) {
1730
+ var key = 'x' + xAxisIndex + 'y' + yAxisIndex;
1731
+ return this._coordsMap[key];
1732
+ }
1733
+
1734
+ if (installCanvasRenderer.isObject(xAxisIndex)) {
1735
+ yAxisIndex = xAxisIndex.yAxisIndex;
1736
+ xAxisIndex = xAxisIndex.xAxisIndex;
1737
+ }
1738
+
1739
+ for (var i = 0, coordList = this._coordsList; i < coordList.length; i++) {
1740
+ if (coordList[i].getAxis('x').index === xAxisIndex || coordList[i].getAxis('y').index === yAxisIndex) {
1741
+ return coordList[i];
1742
+ }
1743
+ }
1744
+ };
1745
+
1746
+ Grid.prototype.getCartesians = function () {
1747
+ return this._coordsList.slice();
1748
+ };
1749
+ /**
1750
+ * @implements
1751
+ */
1752
+
1753
+
1754
+ Grid.prototype.convertToPixel = function (ecModel, finder, value) {
1755
+ var target = this._findConvertTarget(finder);
1756
+
1757
+ return target.cartesian ? target.cartesian.dataToPoint(value) : target.axis ? target.axis.toGlobalCoord(target.axis.dataToCoord(value)) : null;
1758
+ };
1759
+ /**
1760
+ * @implements
1761
+ */
1762
+
1763
+
1764
+ Grid.prototype.convertFromPixel = function (ecModel, finder, value) {
1765
+ var target = this._findConvertTarget(finder);
1766
+
1767
+ return target.cartesian ? target.cartesian.pointToData(value) : target.axis ? target.axis.coordToData(target.axis.toLocalCoord(value)) : null;
1768
+ };
1769
+
1770
+ Grid.prototype._findConvertTarget = function (finder) {
1771
+ var seriesModel = finder.seriesModel;
1772
+ var xAxisModel = finder.xAxisModel || seriesModel && seriesModel.getReferringComponents('xAxis', installCanvasRenderer.SINGLE_REFERRING).models[0];
1773
+ var yAxisModel = finder.yAxisModel || seriesModel && seriesModel.getReferringComponents('yAxis', installCanvasRenderer.SINGLE_REFERRING).models[0];
1774
+ var gridModel = finder.gridModel;
1775
+ var coordsList = this._coordsList;
1776
+ var cartesian;
1777
+ var axis;
1778
+
1779
+ if (seriesModel) {
1780
+ cartesian = seriesModel.coordinateSystem;
1781
+ installCanvasRenderer.indexOf(coordsList, cartesian) < 0 && (cartesian = null);
1782
+ } else if (xAxisModel && yAxisModel) {
1783
+ cartesian = this.getCartesian(xAxisModel.componentIndex, yAxisModel.componentIndex);
1784
+ } else if (xAxisModel) {
1785
+ axis = this.getAxis('x', xAxisModel.componentIndex);
1786
+ } else if (yAxisModel) {
1787
+ axis = this.getAxis('y', yAxisModel.componentIndex);
1788
+ } // Lowest priority.
1789
+ else if (gridModel) {
1790
+ var grid = gridModel.coordinateSystem;
1791
+
1792
+ if (grid === this) {
1793
+ cartesian = this._coordsList[0];
1794
+ }
1795
+ }
1796
+
1797
+ return {
1798
+ cartesian: cartesian,
1799
+ axis: axis
1800
+ };
1801
+ };
1802
+ /**
1803
+ * @implements
1804
+ */
1805
+
1806
+
1807
+ Grid.prototype.containPoint = function (point) {
1808
+ var coord = this._coordsList[0];
1809
+
1810
+ if (coord) {
1811
+ return coord.containPoint(point);
1812
+ }
1813
+ };
1814
+ /**
1815
+ * Initialize cartesian coordinate systems
1816
+ */
1817
+
1818
+
1819
+ Grid.prototype._initCartesian = function (gridModel, ecModel, api) {
1820
+ var _this = this;
1821
+
1822
+ var grid = this;
1823
+ var axisPositionUsed = {
1824
+ left: false,
1825
+ right: false,
1826
+ top: false,
1827
+ bottom: false
1828
+ };
1829
+ var axesMap = {
1830
+ x: {},
1831
+ y: {}
1832
+ };
1833
+ var axesCount = {
1834
+ x: 0,
1835
+ y: 0
1836
+ }; // Create axis
1837
+
1838
+ ecModel.eachComponent('xAxis', createAxisCreator('x'), this);
1839
+ ecModel.eachComponent('yAxis', createAxisCreator('y'), this);
1840
+
1841
+ if (!axesCount.x || !axesCount.y) {
1842
+ // Roll back when there no either x or y axis
1843
+ this._axesMap = {};
1844
+ this._axesList = [];
1845
+ return;
1846
+ }
1847
+
1848
+ this._axesMap = axesMap; // Create cartesian2d
1849
+
1850
+ installCanvasRenderer.each(axesMap.x, function (xAxis, xAxisIndex) {
1851
+ installCanvasRenderer.each(axesMap.y, function (yAxis, yAxisIndex) {
1852
+ var key = 'x' + xAxisIndex + 'y' + yAxisIndex;
1853
+ var cartesian = new Cartesian2D(key);
1854
+ cartesian.master = _this;
1855
+ cartesian.model = gridModel;
1856
+ _this._coordsMap[key] = cartesian;
1857
+
1858
+ _this._coordsList.push(cartesian);
1859
+
1860
+ cartesian.addAxis(xAxis);
1861
+ cartesian.addAxis(yAxis);
1862
+ });
1863
+ });
1864
+
1865
+ function createAxisCreator(dimName) {
1866
+ return function (axisModel, idx) {
1867
+ if (!isAxisUsedInTheGrid(axisModel, gridModel)) {
1868
+ return;
1869
+ }
1870
+
1871
+ var axisPosition = axisModel.get('position');
1872
+
1873
+ if (dimName === 'x') {
1874
+ // Fix position
1875
+ if (axisPosition !== 'top' && axisPosition !== 'bottom') {
1876
+ // Default bottom of X
1877
+ axisPosition = axisPositionUsed.bottom ? 'top' : 'bottom';
1878
+ }
1879
+ } else {
1880
+ // Fix position
1881
+ if (axisPosition !== 'left' && axisPosition !== 'right') {
1882
+ // Default left of Y
1883
+ axisPosition = axisPositionUsed.left ? 'right' : 'left';
1884
+ }
1885
+ }
1886
+
1887
+ axisPositionUsed[axisPosition] = true;
1888
+ var axis = new Axis2D(dimName, installCanvasRenderer.createScaleByModel(axisModel), [0, 0], axisModel.get('type'), axisPosition);
1889
+ var isCategory = axis.type === 'category';
1890
+ axis.onBand = isCategory && axisModel.get('boundaryGap');
1891
+ axis.inverse = axisModel.get('inverse'); // Inject axis into axisModel
1892
+
1893
+ axisModel.axis = axis; // Inject axisModel into axis
1894
+
1895
+ axis.model = axisModel; // Inject grid info axis
1896
+
1897
+ axis.grid = grid; // Index of axis, can be used as key
1898
+
1899
+ axis.index = idx;
1900
+
1901
+ grid._axesList.push(axis);
1902
+
1903
+ axesMap[dimName][idx] = axis;
1904
+ axesCount[dimName]++;
1905
+ };
1906
+ }
1907
+ };
1908
+ /**
1909
+ * Update cartesian properties from series.
1910
+ */
1911
+
1912
+
1913
+ Grid.prototype._updateScale = function (ecModel, gridModel) {
1914
+ // Reset scale
1915
+ installCanvasRenderer.each(this._axesList, function (axis) {
1916
+ axis.scale.setExtent(Infinity, -Infinity);
1917
+
1918
+ if (axis.type === 'category') {
1919
+ var categorySortInfo = axis.model.get('categorySortInfo');
1920
+ axis.scale.setSortInfo(categorySortInfo);
1921
+ }
1922
+ });
1923
+ ecModel.eachSeries(function (seriesModel) {
1924
+ if (installCanvasRenderer.isCartesian2DSeries(seriesModel)) {
1925
+ var axesModelMap = installCanvasRenderer.findAxisModels(seriesModel);
1926
+ var xAxisModel = axesModelMap.xAxisModel;
1927
+ var yAxisModel = axesModelMap.yAxisModel;
1928
+
1929
+ if (!isAxisUsedInTheGrid(xAxisModel, gridModel) || !isAxisUsedInTheGrid(yAxisModel, gridModel)) {
1930
+ return;
1931
+ }
1932
+
1933
+ var cartesian = this.getCartesian(xAxisModel.componentIndex, yAxisModel.componentIndex);
1934
+ var data = seriesModel.getData();
1935
+ var xAxis = cartesian.getAxis('x');
1936
+ var yAxis = cartesian.getAxis('y');
1937
+ unionExtent(data, xAxis);
1938
+ unionExtent(data, yAxis);
1939
+ }
1940
+ }, this);
1941
+
1942
+ function unionExtent(data, axis) {
1943
+ installCanvasRenderer.each(installCanvasRenderer.getDataDimensionsOnAxis(data, axis.dim), function (dim) {
1944
+ axis.scale.unionExtentFromData(data, dim);
1945
+ });
1946
+ }
1947
+ };
1948
+ /**
1949
+ * @param dim 'x' or 'y' or 'auto' or null/undefined
1950
+ */
1951
+
1952
+
1953
+ Grid.prototype.getTooltipAxes = function (dim) {
1954
+ var baseAxes = [];
1955
+ var otherAxes = [];
1956
+ installCanvasRenderer.each(this.getCartesians(), function (cartesian) {
1957
+ var baseAxis = dim != null && dim !== 'auto' ? cartesian.getAxis(dim) : cartesian.getBaseAxis();
1958
+ var otherAxis = cartesian.getOtherAxis(baseAxis);
1959
+ installCanvasRenderer.indexOf(baseAxes, baseAxis) < 0 && baseAxes.push(baseAxis);
1960
+ installCanvasRenderer.indexOf(otherAxes, otherAxis) < 0 && otherAxes.push(otherAxis);
1961
+ });
1962
+ return {
1963
+ baseAxes: baseAxes,
1964
+ otherAxes: otherAxes
1965
+ };
1966
+ };
1967
+
1968
+ Grid.create = function (ecModel, api) {
1969
+ var grids = [];
1970
+ ecModel.eachComponent('grid', function (gridModel, idx) {
1971
+ var grid = new Grid(gridModel, ecModel, api);
1972
+ grid.name = 'grid_' + idx; // dataSampling requires axis extent, so resize
1973
+ // should be performed in create stage.
1974
+
1975
+ grid.resize(gridModel, api, true);
1976
+ gridModel.coordinateSystem = grid;
1977
+ grids.push(grid);
1978
+ }); // Inject the coordinateSystems into seriesModel
1979
+
1980
+ ecModel.eachSeries(function (seriesModel) {
1981
+ if (!installCanvasRenderer.isCartesian2DSeries(seriesModel)) {
1982
+ return;
1983
+ }
1984
+
1985
+ var axesModelMap = installCanvasRenderer.findAxisModels(seriesModel);
1986
+ var xAxisModel = axesModelMap.xAxisModel;
1987
+ var yAxisModel = axesModelMap.yAxisModel;
1988
+ var gridModel = xAxisModel.getCoordSysModel();
1989
+
1990
+ var grid = gridModel.coordinateSystem;
1991
+ seriesModel.coordinateSystem = grid.getCartesian(xAxisModel.componentIndex, yAxisModel.componentIndex);
1992
+ });
1993
+ return grids;
1994
+ }; // For deciding which dimensions to use when creating list data
1995
+
1996
+
1997
+ Grid.dimensions = cartesian2DDimensions;
1998
+ return Grid;
1999
+ }();
2000
+ /**
2001
+ * Check if the axis is used in the specified grid.
2002
+ */
2003
+
2004
+
2005
+ function isAxisUsedInTheGrid(axisModel, gridModel) {
2006
+ return axisModel.getCoordSysModel() === gridModel;
2007
+ }
2008
+
2009
+ function fixAxisOnZero(axesMap, otherAxisDim, axis, // Key: see `getOnZeroRecordKey`
2010
+ onZeroRecords) {
2011
+ axis.getAxesOnZeroOf = function () {
2012
+ // TODO: onZero of multiple axes.
2013
+ return otherAxisOnZeroOf ? [otherAxisOnZeroOf] : [];
2014
+ }; // onZero can not be enabled in these two situations:
2015
+ // 1. When any other axis is a category axis.
2016
+ // 2. When no axis is cross 0 point.
2017
+
2018
+
2019
+ var otherAxes = axesMap[otherAxisDim];
2020
+ var otherAxisOnZeroOf;
2021
+ var axisModel = axis.model;
2022
+ var onZero = axisModel.get(['axisLine', 'onZero']);
2023
+ var onZeroAxisIndex = axisModel.get(['axisLine', 'onZeroAxisIndex']);
2024
+
2025
+ if (!onZero) {
2026
+ return;
2027
+ } // If target axis is specified.
2028
+
2029
+
2030
+ if (onZeroAxisIndex != null) {
2031
+ if (canOnZeroToAxis(otherAxes[onZeroAxisIndex])) {
2032
+ otherAxisOnZeroOf = otherAxes[onZeroAxisIndex];
2033
+ }
2034
+ } else {
2035
+ // Find the first available other axis.
2036
+ for (var idx in otherAxes) {
2037
+ if (otherAxes.hasOwnProperty(idx) && canOnZeroToAxis(otherAxes[idx]) // Consider that two Y axes on one value axis,
2038
+ // if both onZero, the two Y axes overlap.
2039
+ && !onZeroRecords[getOnZeroRecordKey(otherAxes[idx])]) {
2040
+ otherAxisOnZeroOf = otherAxes[idx];
2041
+ break;
2042
+ }
2043
+ }
2044
+ }
2045
+
2046
+ if (otherAxisOnZeroOf) {
2047
+ onZeroRecords[getOnZeroRecordKey(otherAxisOnZeroOf)] = true;
2048
+ }
2049
+
2050
+ function getOnZeroRecordKey(axis) {
2051
+ return axis.dim + '_' + axis.index;
2052
+ }
2053
+ }
2054
+
2055
+ function canOnZeroToAxis(axis) {
2056
+ return axis && axis.type !== 'category' && axis.type !== 'time' && installCanvasRenderer.ifAxisCrossZero(axis);
2057
+ }
2058
+
2059
+ function updateAxisTransform(axis, coordBase) {
2060
+ var axisExtent = axis.getExtent();
2061
+ var axisExtentSum = axisExtent[0] + axisExtent[1]; // Fast transform
2062
+
2063
+ axis.toGlobalCoord = axis.dim === 'x' ? function (coord) {
2064
+ return coord + coordBase;
2065
+ } : function (coord) {
2066
+ return axisExtentSum - coord + coordBase;
2067
+ };
2068
+ axis.toLocalCoord = axis.dim === 'x' ? function (coord) {
2069
+ return coord - coordBase;
2070
+ } : function (coord) {
2071
+ return axisExtentSum - coord + coordBase;
2072
+ };
2073
+ }
2074
+
2075
+ var inner = installCanvasRenderer.makeInner();
2076
+ function rectCoordAxisBuildSplitArea(axisView, axisGroup, axisModel, gridModel) {
2077
+ var axis = axisModel.axis;
2078
+
2079
+ if (axis.scale.isBlank()) {
2080
+ return;
2081
+ } // TODO: TYPE
2082
+
2083
+
2084
+ var splitAreaModel = axisModel.getModel('splitArea');
2085
+ var areaStyleModel = splitAreaModel.getModel('areaStyle');
2086
+ var areaColors = areaStyleModel.get('color');
2087
+ var gridRect = gridModel.coordinateSystem.getRect();
2088
+ var ticksCoords = axis.getTicksCoords({
2089
+ tickModel: splitAreaModel,
2090
+ clamp: true
2091
+ });
2092
+
2093
+ if (!ticksCoords.length) {
2094
+ return;
2095
+ } // For Making appropriate splitArea animation, the color and anid
2096
+ // should be corresponding to previous one if possible.
2097
+
2098
+
2099
+ var areaColorsLen = areaColors.length;
2100
+ var lastSplitAreaColors = inner(axisView).splitAreaColors;
2101
+ var newSplitAreaColors = installCanvasRenderer.createHashMap();
2102
+ var colorIndex = 0;
2103
+
2104
+ if (lastSplitAreaColors) {
2105
+ for (var i = 0; i < ticksCoords.length; i++) {
2106
+ var cIndex = lastSplitAreaColors.get(ticksCoords[i].tickValue);
2107
+
2108
+ if (cIndex != null) {
2109
+ colorIndex = (cIndex + (areaColorsLen - 1) * i) % areaColorsLen;
2110
+ break;
2111
+ }
2112
+ }
2113
+ }
2114
+
2115
+ var prev = axis.toGlobalCoord(ticksCoords[0].coord);
2116
+ var areaStyle = areaStyleModel.getAreaStyle();
2117
+ areaColors = installCanvasRenderer.isArray(areaColors) ? areaColors : [areaColors];
2118
+
2119
+ for (var i = 1; i < ticksCoords.length; i++) {
2120
+ var tickCoord = axis.toGlobalCoord(ticksCoords[i].coord);
2121
+ var x = void 0;
2122
+ var y = void 0;
2123
+ var width = void 0;
2124
+ var height = void 0;
2125
+
2126
+ if (axis.isHorizontal()) {
2127
+ x = prev;
2128
+ y = gridRect.y;
2129
+ width = tickCoord - x;
2130
+ height = gridRect.height;
2131
+ prev = x + width;
2132
+ } else {
2133
+ x = gridRect.x;
2134
+ y = prev;
2135
+ width = gridRect.width;
2136
+ height = tickCoord - y;
2137
+ prev = y + height;
2138
+ }
2139
+
2140
+ var tickValue = ticksCoords[i - 1].tickValue;
2141
+ tickValue != null && newSplitAreaColors.set(tickValue, colorIndex);
2142
+ axisGroup.add(new installCanvasRenderer.Rect({
2143
+ anid: tickValue != null ? 'area_' + tickValue : null,
2144
+ shape: {
2145
+ x: x,
2146
+ y: y,
2147
+ width: width,
2148
+ height: height
2149
+ },
2150
+ style: installCanvasRenderer.defaults({
2151
+ fill: areaColors[colorIndex]
2152
+ }, areaStyle),
2153
+ autoBatch: true,
2154
+ silent: true
2155
+ }));
2156
+ colorIndex = (colorIndex + 1) % areaColorsLen;
2157
+ }
2158
+
2159
+ inner(axisView).splitAreaColors = newSplitAreaColors;
2160
+ }
2161
+ function rectCoordAxisHandleRemove(axisView) {
2162
+ inner(axisView).splitAreaColors = null;
2163
+ }
2164
+
2165
+ var axisBuilderAttrs = ['axisLine', 'axisTickLabel', 'axisName'];
2166
+ var selfBuilderAttrs = ['splitArea', 'splitLine', 'minorSplitLine'];
2167
+
2168
+ var CartesianAxisView =
2169
+ /** @class */
2170
+ function (_super) {
2171
+ installCanvasRenderer.__extends(CartesianAxisView, _super);
2172
+
2173
+ function CartesianAxisView() {
2174
+ var _this = _super !== null && _super.apply(this, arguments) || this;
2175
+
2176
+ _this.type = CartesianAxisView.type;
2177
+ _this.axisPointerClass = 'CartesianAxisPointer';
2178
+ return _this;
2179
+ }
2180
+ /**
2181
+ * @override
2182
+ */
2183
+
2184
+
2185
+ CartesianAxisView.prototype.render = function (axisModel, ecModel, api, payload) {
2186
+ this.group.removeAll();
2187
+ var oldAxisGroup = this._axisGroup;
2188
+ this._axisGroup = new installCanvasRenderer.Group();
2189
+ this.group.add(this._axisGroup);
2190
+
2191
+ if (!axisModel.get('show')) {
2192
+ return;
2193
+ }
2194
+
2195
+ var gridModel = axisModel.getCoordSysModel();
2196
+ var layout = installCanvasRenderer.layout(gridModel, axisModel);
2197
+ var axisBuilder = new installCanvasRenderer.AxisBuilder(axisModel, installCanvasRenderer.extend({
2198
+ handleAutoShown: function (elementType) {
2199
+ var cartesians = gridModel.coordinateSystem.getCartesians();
2200
+
2201
+ for (var i = 0; i < cartesians.length; i++) {
2202
+ if (installCanvasRenderer.isIntervalOrLogScale(cartesians[i].getOtherAxis(axisModel.axis).scale)) {
2203
+ // Still show axis tick or axisLine if other axis is value / log
2204
+ return true;
2205
+ }
2206
+ } // Not show axisTick or axisLine if other axis is category / time
2207
+
2208
+
2209
+ return false;
2210
+ }
2211
+ }, layout));
2212
+ installCanvasRenderer.each(axisBuilderAttrs, axisBuilder.add, axisBuilder);
2213
+
2214
+ this._axisGroup.add(axisBuilder.getGroup());
2215
+
2216
+ installCanvasRenderer.each(selfBuilderAttrs, function (name) {
2217
+ if (axisModel.get([name, 'show'])) {
2218
+ axisElementBuilders[name](this, this._axisGroup, axisModel, gridModel);
2219
+ }
2220
+ }, this); // THIS is a special case for bar racing chart.
2221
+ // Update the axis label from the natural initial layout to
2222
+ // sorted layout should has no animation.
2223
+
2224
+ var isInitialSortFromBarRacing = payload && payload.type === 'changeAxisOrder' && payload.isInitSort;
2225
+
2226
+ if (!isInitialSortFromBarRacing) {
2227
+ installCanvasRenderer.groupTransition(oldAxisGroup, this._axisGroup, axisModel);
2228
+ }
2229
+
2230
+ _super.prototype.render.call(this, axisModel, ecModel, api, payload);
2231
+ };
2232
+
2233
+ CartesianAxisView.prototype.remove = function () {
2234
+ rectCoordAxisHandleRemove(this);
2235
+ };
2236
+
2237
+ CartesianAxisView.type = 'cartesianAxis';
2238
+ return CartesianAxisView;
2239
+ }(installCanvasRenderer.AxisView);
2240
+
2241
+ var axisElementBuilders = {
2242
+ splitLine: function (axisView, axisGroup, axisModel, gridModel) {
2243
+ var axis = axisModel.axis;
2244
+
2245
+ if (axis.scale.isBlank()) {
2246
+ return;
2247
+ }
2248
+
2249
+ var splitLineModel = axisModel.getModel('splitLine');
2250
+ var lineStyleModel = splitLineModel.getModel('lineStyle');
2251
+ var lineColors = lineStyleModel.get('color');
2252
+ lineColors = installCanvasRenderer.isArray(lineColors) ? lineColors : [lineColors];
2253
+ var gridRect = gridModel.coordinateSystem.getRect();
2254
+ var isHorizontal = axis.isHorizontal();
2255
+ var lineCount = 0;
2256
+ var ticksCoords = axis.getTicksCoords({
2257
+ tickModel: splitLineModel
2258
+ });
2259
+ var p1 = [];
2260
+ var p2 = [];
2261
+ var lineStyle = lineStyleModel.getLineStyle();
2262
+
2263
+ for (var i = 0; i < ticksCoords.length; i++) {
2264
+ var tickCoord = axis.toGlobalCoord(ticksCoords[i].coord);
2265
+
2266
+ if (isHorizontal) {
2267
+ p1[0] = tickCoord;
2268
+ p1[1] = gridRect.y;
2269
+ p2[0] = tickCoord;
2270
+ p2[1] = gridRect.y + gridRect.height;
2271
+ } else {
2272
+ p1[0] = gridRect.x;
2273
+ p1[1] = tickCoord;
2274
+ p2[0] = gridRect.x + gridRect.width;
2275
+ p2[1] = tickCoord;
2276
+ }
2277
+
2278
+ var colorIndex = lineCount++ % lineColors.length;
2279
+ var tickValue = ticksCoords[i].tickValue;
2280
+ var line = new installCanvasRenderer.Line({
2281
+ anid: tickValue != null ? 'line_' + ticksCoords[i].tickValue : null,
2282
+ autoBatch: true,
2283
+ shape: {
2284
+ x1: p1[0],
2285
+ y1: p1[1],
2286
+ x2: p2[0],
2287
+ y2: p2[1]
2288
+ },
2289
+ style: installCanvasRenderer.defaults({
2290
+ stroke: lineColors[colorIndex]
2291
+ }, lineStyle),
2292
+ silent: true
2293
+ });
2294
+ installCanvasRenderer.subPixelOptimizeLine(line.shape, lineStyle.lineWidth);
2295
+ axisGroup.add(line);
2296
+ }
2297
+ },
2298
+ minorSplitLine: function (axisView, axisGroup, axisModel, gridModel) {
2299
+ var axis = axisModel.axis;
2300
+ var minorSplitLineModel = axisModel.getModel('minorSplitLine');
2301
+ var lineStyleModel = minorSplitLineModel.getModel('lineStyle');
2302
+ var gridRect = gridModel.coordinateSystem.getRect();
2303
+ var isHorizontal = axis.isHorizontal();
2304
+ var minorTicksCoords = axis.getMinorTicksCoords();
2305
+
2306
+ if (!minorTicksCoords.length) {
2307
+ return;
2308
+ }
2309
+
2310
+ var p1 = [];
2311
+ var p2 = [];
2312
+ var lineStyle = lineStyleModel.getLineStyle();
2313
+
2314
+ for (var i = 0; i < minorTicksCoords.length; i++) {
2315
+ for (var k = 0; k < minorTicksCoords[i].length; k++) {
2316
+ var tickCoord = axis.toGlobalCoord(minorTicksCoords[i][k].coord);
2317
+
2318
+ if (isHorizontal) {
2319
+ p1[0] = tickCoord;
2320
+ p1[1] = gridRect.y;
2321
+ p2[0] = tickCoord;
2322
+ p2[1] = gridRect.y + gridRect.height;
2323
+ } else {
2324
+ p1[0] = gridRect.x;
2325
+ p1[1] = tickCoord;
2326
+ p2[0] = gridRect.x + gridRect.width;
2327
+ p2[1] = tickCoord;
2328
+ }
2329
+
2330
+ var line = new installCanvasRenderer.Line({
2331
+ anid: 'minor_line_' + minorTicksCoords[i][k].tickValue,
2332
+ autoBatch: true,
2333
+ shape: {
2334
+ x1: p1[0],
2335
+ y1: p1[1],
2336
+ x2: p2[0],
2337
+ y2: p2[1]
2338
+ },
2339
+ style: lineStyle,
2340
+ silent: true
2341
+ });
2342
+ installCanvasRenderer.subPixelOptimizeLine(line.shape, lineStyle.lineWidth);
2343
+ axisGroup.add(line);
2344
+ }
2345
+ }
2346
+ },
2347
+ splitArea: function (axisView, axisGroup, axisModel, gridModel) {
2348
+ rectCoordAxisBuildSplitArea(axisView, axisGroup, axisModel, gridModel);
2349
+ }
2350
+ };
2351
+
2352
+ var CartesianXAxisView =
2353
+ /** @class */
2354
+ function (_super) {
2355
+ installCanvasRenderer.__extends(CartesianXAxisView, _super);
2356
+
2357
+ function CartesianXAxisView() {
2358
+ var _this = _super !== null && _super.apply(this, arguments) || this;
2359
+
2360
+ _this.type = CartesianXAxisView.type;
2361
+ return _this;
2362
+ }
2363
+
2364
+ CartesianXAxisView.type = 'xAxis';
2365
+ return CartesianXAxisView;
2366
+ }(CartesianAxisView);
2367
+
2368
+ var CartesianYAxisView =
2369
+ /** @class */
2370
+ function (_super) {
2371
+ installCanvasRenderer.__extends(CartesianYAxisView, _super);
2372
+
2373
+ function CartesianYAxisView() {
2374
+ var _this = _super !== null && _super.apply(this, arguments) || this;
2375
+
2376
+ _this.type = CartesianXAxisView.type;
2377
+ return _this;
2378
+ }
2379
+
2380
+ CartesianYAxisView.type = 'yAxis';
2381
+ return CartesianYAxisView;
2382
+ }(CartesianAxisView);
2383
+
2384
+ var GridView =
2385
+ /** @class */
2386
+ function (_super) {
2387
+ installCanvasRenderer.__extends(GridView, _super);
2388
+
2389
+ function GridView() {
2390
+ var _this = _super !== null && _super.apply(this, arguments) || this;
2391
+
2392
+ _this.type = 'grid';
2393
+ return _this;
2394
+ }
2395
+
2396
+ GridView.prototype.render = function (gridModel, ecModel) {
2397
+ this.group.removeAll();
2398
+
2399
+ if (gridModel.get('show')) {
2400
+ this.group.add(new installCanvasRenderer.Rect({
2401
+ shape: gridModel.coordinateSystem.getRect(),
2402
+ style: installCanvasRenderer.defaults({
2403
+ fill: gridModel.get('backgroundColor')
2404
+ }, gridModel.getItemStyle()),
2405
+ silent: true,
2406
+ z2: -1
2407
+ }));
2408
+ }
2409
+ };
2410
+
2411
+ GridView.type = 'grid';
2412
+ return GridView;
2413
+ }(installCanvasRenderer.ComponentView);
2414
+
2415
+ var extraOption = {
2416
+ // gridIndex: 0,
2417
+ // gridId: '',
2418
+ offset: 0
2419
+ };
2420
+ function install$2(registers) {
2421
+ registers.registerComponentView(GridView);
2422
+ registers.registerComponentModel(GridModel);
2423
+ registers.registerCoordinateSystem('cartesian2d', Grid);
2424
+ axisModelCreator(registers, 'x', CartesianAxisModel, extraOption);
2425
+ axisModelCreator(registers, 'y', CartesianAxisModel, extraOption);
2426
+ registers.registerComponentView(CartesianXAxisView);
2427
+ registers.registerComponentView(CartesianYAxisView);
2428
+ registers.registerPreprocessor(function (option) {
2429
+ // Only create grid when need
2430
+ if (option.xAxis && option.yAxis && !option.grid) {
2431
+ option.grid = {};
2432
+ }
2433
+ });
2434
+ }
2435
+
2436
+ function install$1(registers) {
2437
+ installCanvasRenderer.use(install$2);
2438
+ installCanvasRenderer.use(installCanvasRenderer.install$2);
2439
+ }
2440
+
2441
+ var TitleModel =
2442
+ /** @class */
2443
+ function (_super) {
2444
+ installCanvasRenderer.__extends(TitleModel, _super);
2445
+
2446
+ function TitleModel() {
2447
+ var _this = _super !== null && _super.apply(this, arguments) || this;
2448
+
2449
+ _this.type = TitleModel.type;
2450
+ _this.layoutMode = {
2451
+ type: 'box',
2452
+ ignoreSize: true
2453
+ };
2454
+ return _this;
2455
+ }
2456
+
2457
+ TitleModel.type = 'title';
2458
+ TitleModel.defaultOption = {
2459
+ // zlevel: 0,
2460
+ z: 6,
2461
+ show: true,
2462
+ text: '',
2463
+ target: 'blank',
2464
+ subtext: '',
2465
+ subtarget: 'blank',
2466
+ left: 0,
2467
+ top: 0,
2468
+ backgroundColor: 'rgba(0,0,0,0)',
2469
+ borderColor: '#ccc',
2470
+ borderWidth: 0,
2471
+ padding: 5,
2472
+ itemGap: 10,
2473
+ textStyle: {
2474
+ fontSize: 18,
2475
+ fontWeight: 'bold',
2476
+ color: '#464646'
2477
+ },
2478
+ subtextStyle: {
2479
+ fontSize: 12,
2480
+ color: '#6E7079'
2481
+ }
2482
+ };
2483
+ return TitleModel;
2484
+ }(installCanvasRenderer.ComponentModel); // View
2485
+
2486
+
2487
+ var TitleView =
2488
+ /** @class */
2489
+ function (_super) {
2490
+ installCanvasRenderer.__extends(TitleView, _super);
2491
+
2492
+ function TitleView() {
2493
+ var _this = _super !== null && _super.apply(this, arguments) || this;
2494
+
2495
+ _this.type = TitleView.type;
2496
+ return _this;
2497
+ }
2498
+
2499
+ TitleView.prototype.render = function (titleModel, ecModel, api) {
2500
+ this.group.removeAll();
2501
+
2502
+ if (!titleModel.get('show')) {
2503
+ return;
2504
+ }
2505
+
2506
+ var group = this.group;
2507
+ var textStyleModel = titleModel.getModel('textStyle');
2508
+ var subtextStyleModel = titleModel.getModel('subtextStyle');
2509
+ var textAlign = titleModel.get('textAlign');
2510
+ var textVerticalAlign = installCanvasRenderer.retrieve2(titleModel.get('textBaseline'), titleModel.get('textVerticalAlign'));
2511
+ var textEl = new installCanvasRenderer.ZRText({
2512
+ style: installCanvasRenderer.createTextStyle(textStyleModel, {
2513
+ text: titleModel.get('text'),
2514
+ fill: textStyleModel.getTextColor()
2515
+ }, {
2516
+ disableBox: true
2517
+ }),
2518
+ z2: 10
2519
+ });
2520
+ var textRect = textEl.getBoundingRect();
2521
+ var subText = titleModel.get('subtext');
2522
+ var subTextEl = new installCanvasRenderer.ZRText({
2523
+ style: installCanvasRenderer.createTextStyle(subtextStyleModel, {
2524
+ text: subText,
2525
+ fill: subtextStyleModel.getTextColor(),
2526
+ y: textRect.height + titleModel.get('itemGap'),
2527
+ verticalAlign: 'top'
2528
+ }, {
2529
+ disableBox: true
2530
+ }),
2531
+ z2: 10
2532
+ });
2533
+ var link = titleModel.get('link');
2534
+ var sublink = titleModel.get('sublink');
2535
+ var triggerEvent = titleModel.get('triggerEvent', true);
2536
+ textEl.silent = !link && !triggerEvent;
2537
+ subTextEl.silent = !sublink && !triggerEvent;
2538
+
2539
+ if (link) {
2540
+ textEl.on('click', function () {
2541
+ installCanvasRenderer.windowOpen(link, '_' + titleModel.get('target'));
2542
+ });
2543
+ }
2544
+
2545
+ if (sublink) {
2546
+ subTextEl.on('click', function () {
2547
+ installCanvasRenderer.windowOpen(sublink, '_' + titleModel.get('subtarget'));
2548
+ });
2549
+ }
2550
+
2551
+ installCanvasRenderer.getECData(textEl).eventData = installCanvasRenderer.getECData(subTextEl).eventData = triggerEvent ? {
2552
+ componentType: 'title',
2553
+ componentIndex: titleModel.componentIndex
2554
+ } : null;
2555
+ group.add(textEl);
2556
+ subText && group.add(subTextEl); // If no subText, but add subTextEl, there will be an empty line.
2557
+
2558
+ var groupRect = group.getBoundingRect();
2559
+ var layoutOption = titleModel.getBoxLayoutParams();
2560
+ layoutOption.width = groupRect.width;
2561
+ layoutOption.height = groupRect.height;
2562
+ var layoutRect = installCanvasRenderer.getLayoutRect(layoutOption, {
2563
+ width: api.getWidth(),
2564
+ height: api.getHeight()
2565
+ }, titleModel.get('padding')); // Adjust text align based on position
2566
+
2567
+ if (!textAlign) {
2568
+ // Align left if title is on the left. center and right is same
2569
+ textAlign = titleModel.get('left') || titleModel.get('right'); // @ts-ignore
2570
+
2571
+ if (textAlign === 'middle') {
2572
+ textAlign = 'center';
2573
+ } // Adjust layout by text align
2574
+
2575
+
2576
+ if (textAlign === 'right') {
2577
+ layoutRect.x += layoutRect.width;
2578
+ } else if (textAlign === 'center') {
2579
+ layoutRect.x += layoutRect.width / 2;
2580
+ }
2581
+ }
2582
+
2583
+ if (!textVerticalAlign) {
2584
+ textVerticalAlign = titleModel.get('top') || titleModel.get('bottom'); // @ts-ignore
2585
+
2586
+ if (textVerticalAlign === 'center') {
2587
+ textVerticalAlign = 'middle';
2588
+ }
2589
+
2590
+ if (textVerticalAlign === 'bottom') {
2591
+ layoutRect.y += layoutRect.height;
2592
+ } else if (textVerticalAlign === 'middle') {
2593
+ layoutRect.y += layoutRect.height / 2;
2594
+ }
2595
+
2596
+ textVerticalAlign = textVerticalAlign || 'top';
2597
+ }
2598
+
2599
+ group.x = layoutRect.x;
2600
+ group.y = layoutRect.y;
2601
+ group.markRedraw();
2602
+ var alignStyle = {
2603
+ align: textAlign,
2604
+ verticalAlign: textVerticalAlign
2605
+ };
2606
+ textEl.setStyle(alignStyle);
2607
+ subTextEl.setStyle(alignStyle); // Render background
2608
+ // Get groupRect again because textAlign has been changed
2609
+
2610
+ groupRect = group.getBoundingRect();
2611
+ var padding = layoutRect.margin;
2612
+ var style = titleModel.getItemStyle(['color', 'opacity']);
2613
+ style.fill = titleModel.get('backgroundColor');
2614
+ var rect = new installCanvasRenderer.Rect({
2615
+ shape: {
2616
+ x: groupRect.x - padding[3],
2617
+ y: groupRect.y - padding[0],
2618
+ width: groupRect.width + padding[1] + padding[3],
2619
+ height: groupRect.height + padding[0] + padding[2],
2620
+ r: titleModel.get('borderRadius')
2621
+ },
2622
+ style: style,
2623
+ subPixelOptimize: true,
2624
+ silent: true
2625
+ });
2626
+ group.add(rect);
2627
+ };
2628
+
2629
+ TitleView.type = 'title';
2630
+ return TitleView;
2631
+ }(installCanvasRenderer.ComponentView);
2632
+
2633
+ function install(registers) {
2634
+ registers.registerComponentModel(TitleModel);
2635
+ registers.registerComponentView(TitleView);
2636
+ }
2637
+
2638
+ /**
2639
+ * @return label string. Not null/undefined
2640
+ */
2641
+
2642
+ function getDefaultLabel(data, dataIndex) {
2643
+ var labelDims = data.mapDimensionsAll('defaultedLabel');
2644
+ var len = labelDims.length; // Simple optimization (in lots of cases, label dims length is 1)
2645
+
2646
+ if (len === 1) {
2647
+ var rawVal = installCanvasRenderer.retrieveRawValue(data, dataIndex, labelDims[0]);
2648
+ return rawVal != null ? rawVal + '' : null;
2649
+ } else if (len) {
2650
+ var vals = [];
2651
+
2652
+ for (var i = 0; i < labelDims.length; i++) {
2653
+ vals.push(installCanvasRenderer.retrieveRawValue(data, dataIndex, labelDims[i]));
2654
+ }
2655
+
2656
+ return vals.join(' ');
2657
+ }
2658
+ }
2659
+ function getDefaultInterpolatedLabel(data, interpolatedValue) {
2660
+ var labelDims = data.mapDimensionsAll('defaultedLabel');
2661
+
2662
+ if (!installCanvasRenderer.isArray(interpolatedValue)) {
2663
+ return interpolatedValue + '';
2664
+ }
2665
+
2666
+ var vals = [];
2667
+
2668
+ for (var i = 0; i < labelDims.length; i++) {
2669
+ var dimIndex = data.getDimensionIndex(labelDims[i]);
2670
+
2671
+ if (dimIndex >= 0) {
2672
+ vals.push(interpolatedValue[dimIndex]);
2673
+ }
2674
+ }
2675
+
2676
+ return vals.join(' ');
2677
+ }
2678
+
2679
+ /*
2680
+ * Licensed to the Apache Software Foundation (ASF) under one
2681
+ * or more contributor license agreements. See the NOTICE file
2682
+ * distributed with this work for additional information
2683
+ * regarding copyright ownership. The ASF licenses this file
2684
+ * to you under the Apache License, Version 2.0 (the
2685
+ * "License"); you may not use this file except in compliance
2686
+ * with the License. You may obtain a copy of the License at
2687
+ *
2688
+ * http://www.apache.org/licenses/LICENSE-2.0
2689
+ *
2690
+ * Unless required by applicable law or agreed to in writing,
2691
+ * software distributed under the License is distributed on an
2692
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
2693
+ * KIND, either express or implied. See the License for the
2694
+ * specific language governing permissions and limitations
2695
+ * under the License.
2696
+ */
2697
+
2698
+
2699
+ /**
2700
+ * AUTO-GENERATED FILE. DO NOT MODIFY.
2701
+ */
2702
+
2703
+ /*
2704
+ * Licensed to the Apache Software Foundation (ASF) under one
2705
+ * or more contributor license agreements. See the NOTICE file
2706
+ * distributed with this work for additional information
2707
+ * regarding copyright ownership. The ASF licenses this file
2708
+ * to you under the Apache License, Version 2.0 (the
2709
+ * "License"); you may not use this file except in compliance
2710
+ * with the License. You may obtain a copy of the License at
2711
+ *
2712
+ * http://www.apache.org/licenses/LICENSE-2.0
2713
+ *
2714
+ * Unless required by applicable law or agreed to in writing,
2715
+ * software distributed under the License is distributed on an
2716
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
2717
+ * KIND, either express or implied. See the License for the
2718
+ * specific language governing permissions and limitations
2719
+ * under the License.
2720
+ */
2721
+ function isCoordinateSystemType(coordSys, type) {
2722
+ return coordSys.type === type;
2723
+ }
2724
+
2725
+ function createGridClipPath(cartesian, hasAnimation, seriesModel, done, during) {
2726
+ var rect = cartesian.getArea();
2727
+ var x = rect.x;
2728
+ var y = rect.y;
2729
+ var width = rect.width;
2730
+ var height = rect.height;
2731
+ var lineWidth = seriesModel.get(['lineStyle', 'width']) || 2; // Expand the clip path a bit to avoid the border is clipped and looks thinner
2732
+
2733
+ x -= lineWidth / 2;
2734
+ y -= lineWidth / 2;
2735
+ width += lineWidth;
2736
+ height += lineWidth; // fix: https://github.com/apache/incubator-echarts/issues/11369
2737
+
2738
+ x = Math.floor(x);
2739
+ width = Math.round(width);
2740
+ var clipPath = new installCanvasRenderer.Rect({
2741
+ shape: {
2742
+ x: x,
2743
+ y: y,
2744
+ width: width,
2745
+ height: height
2746
+ }
2747
+ });
2748
+
2749
+ if (hasAnimation) {
2750
+ var baseAxis = cartesian.getBaseAxis();
2751
+ var isHorizontal = baseAxis.isHorizontal();
2752
+ var isAxisInversed = baseAxis.inverse;
2753
+
2754
+ if (isHorizontal) {
2755
+ if (isAxisInversed) {
2756
+ clipPath.shape.x += width;
2757
+ }
2758
+
2759
+ clipPath.shape.width = 0;
2760
+ } else {
2761
+ if (!isAxisInversed) {
2762
+ clipPath.shape.y += height;
2763
+ }
2764
+
2765
+ clipPath.shape.height = 0;
2766
+ }
2767
+
2768
+ var duringCb = installCanvasRenderer.isFunction(during) ? function (percent) {
2769
+ during(percent, clipPath);
2770
+ } : null;
2771
+ installCanvasRenderer.initProps(clipPath, {
2772
+ shape: {
2773
+ width: width,
2774
+ height: height,
2775
+ x: x,
2776
+ y: y
2777
+ }
2778
+ }, seriesModel, null, done, duringCb);
2779
+ }
2780
+
2781
+ return clipPath;
2782
+ }
2783
+
2784
+ function createPolarClipPath(polar, hasAnimation, seriesModel) {
2785
+ var sectorArea = polar.getArea(); // Avoid float number rounding error for symbol on the edge of axis extent.
2786
+
2787
+ var r0 = installCanvasRenderer.round(sectorArea.r0, 1);
2788
+ var r = installCanvasRenderer.round(sectorArea.r, 1);
2789
+ var clipPath = new installCanvasRenderer.Sector({
2790
+ shape: {
2791
+ cx: installCanvasRenderer.round(polar.cx, 1),
2792
+ cy: installCanvasRenderer.round(polar.cy, 1),
2793
+ r0: r0,
2794
+ r: r,
2795
+ startAngle: sectorArea.startAngle,
2796
+ endAngle: sectorArea.endAngle,
2797
+ clockwise: sectorArea.clockwise
2798
+ }
2799
+ });
2800
+
2801
+ if (hasAnimation) {
2802
+ var isRadial = polar.getBaseAxis().dim === 'angle';
2803
+
2804
+ if (isRadial) {
2805
+ clipPath.shape.endAngle = sectorArea.startAngle;
2806
+ } else {
2807
+ clipPath.shape.r = r0;
2808
+ }
2809
+
2810
+ installCanvasRenderer.initProps(clipPath, {
2811
+ shape: {
2812
+ endAngle: sectorArea.endAngle,
2813
+ r: r
2814
+ }
2815
+ }, seriesModel);
2816
+ }
2817
+
2818
+ return clipPath;
2819
+ }
2820
+
2821
+ function createClipPath(coordSys, hasAnimation, seriesModel, done, during) {
2822
+ if (!coordSys) {
2823
+ return null;
2824
+ } else if (coordSys.type === 'polar') {
2825
+ return createPolarClipPath(coordSys, hasAnimation, seriesModel);
2826
+ } else if (coordSys.type === 'cartesian2d') {
2827
+ return createGridClipPath(coordSys, hasAnimation, seriesModel, done, during);
2828
+ }
2829
+
2830
+ return null;
2831
+ }
2832
+
2833
+ var samplers = {
2834
+ average: function (frame) {
2835
+ var sum = 0;
2836
+ var count = 0;
2837
+
2838
+ for (var i = 0; i < frame.length; i++) {
2839
+ if (!isNaN(frame[i])) {
2840
+ sum += frame[i];
2841
+ count++;
2842
+ }
2843
+ } // Return NaN if count is 0
2844
+
2845
+
2846
+ return count === 0 ? NaN : sum / count;
2847
+ },
2848
+ sum: function (frame) {
2849
+ var sum = 0;
2850
+
2851
+ for (var i = 0; i < frame.length; i++) {
2852
+ // Ignore NaN
2853
+ sum += frame[i] || 0;
2854
+ }
2855
+
2856
+ return sum;
2857
+ },
2858
+ max: function (frame) {
2859
+ var max = -Infinity;
2860
+
2861
+ for (var i = 0; i < frame.length; i++) {
2862
+ frame[i] > max && (max = frame[i]);
2863
+ } // NaN will cause illegal axis extent.
2864
+
2865
+
2866
+ return isFinite(max) ? max : NaN;
2867
+ },
2868
+ min: function (frame) {
2869
+ var min = Infinity;
2870
+
2871
+ for (var i = 0; i < frame.length; i++) {
2872
+ frame[i] < min && (min = frame[i]);
2873
+ } // NaN will cause illegal axis extent.
2874
+
2875
+
2876
+ return isFinite(min) ? min : NaN;
2877
+ },
2878
+ // TODO
2879
+ // Median
2880
+ nearest: function (frame) {
2881
+ return frame[0];
2882
+ }
2883
+ };
2884
+
2885
+ var indexSampler = function (frame) {
2886
+ return Math.round(frame.length / 2);
2887
+ };
2888
+
2889
+ function dataSample(seriesType) {
2890
+ return {
2891
+ seriesType: seriesType,
2892
+ // FIXME:TS never used, so comment it
2893
+ // modifyOutputEnd: true,
2894
+ reset: function (seriesModel, ecModel, api) {
2895
+ var data = seriesModel.getData();
2896
+ var sampling = seriesModel.get('sampling');
2897
+ var coordSys = seriesModel.coordinateSystem;
2898
+ var count = data.count(); // Only cartesian2d support down sampling. Disable it when there is few data.
2899
+
2900
+ if (count > 10 && coordSys.type === 'cartesian2d' && sampling) {
2901
+ var baseAxis = coordSys.getBaseAxis();
2902
+ var valueAxis = coordSys.getOtherAxis(baseAxis);
2903
+ var extent = baseAxis.getExtent();
2904
+ var dpr = api.getDevicePixelRatio(); // Coordinste system has been resized
2905
+
2906
+ var size = Math.abs(extent[1] - extent[0]) * (dpr || 1);
2907
+ var rate = Math.round(count / size);
2908
+
2909
+ if (isFinite(rate) && rate > 1) {
2910
+ if (sampling === 'lttb') {
2911
+ seriesModel.setData(data.lttbDownSample(data.mapDimension(valueAxis.dim), 1 / rate));
2912
+ }
2913
+
2914
+ var sampler = void 0;
2915
+
2916
+ if (installCanvasRenderer.isString(sampling)) {
2917
+ sampler = samplers[sampling];
2918
+ } else if (installCanvasRenderer.isFunction(sampling)) {
2919
+ sampler = sampling;
2920
+ }
2921
+
2922
+ if (sampler) {
2923
+ // Only support sample the first dim mapped from value axis.
2924
+ seriesModel.setData(data.downSample(data.mapDimension(valueAxis.dim), 1 / rate, sampler, indexSampler));
2925
+ }
2926
+ }
2927
+ }
2928
+ }
2929
+ };
2930
+ }
2931
+
2932
+ var ValidColorNames;
2933
+ (function (ValidColorNames) {
2934
+ ValidColorNames[ValidColorNames["aliceblue"] = 0] = "aliceblue";
2935
+ ValidColorNames[ValidColorNames["antiquewhite"] = 1] = "antiquewhite";
2936
+ ValidColorNames[ValidColorNames["aqua"] = 2] = "aqua";
2937
+ ValidColorNames[ValidColorNames["aquamarine"] = 3] = "aquamarine";
2938
+ ValidColorNames[ValidColorNames["azure"] = 4] = "azure";
2939
+ ValidColorNames[ValidColorNames["beige"] = 5] = "beige";
2940
+ ValidColorNames[ValidColorNames["bisque"] = 6] = "bisque";
2941
+ ValidColorNames[ValidColorNames["black"] = 7] = "black";
2942
+ ValidColorNames[ValidColorNames["blanchedalmond"] = 8] = "blanchedalmond";
2943
+ ValidColorNames[ValidColorNames["blue"] = 9] = "blue";
2944
+ ValidColorNames[ValidColorNames["blueviolet"] = 10] = "blueviolet";
2945
+ ValidColorNames[ValidColorNames["brown"] = 11] = "brown";
2946
+ ValidColorNames[ValidColorNames["burlywood"] = 12] = "burlywood";
2947
+ ValidColorNames[ValidColorNames["cadetblue"] = 13] = "cadetblue";
2948
+ ValidColorNames[ValidColorNames["chartreuse"] = 14] = "chartreuse";
2949
+ ValidColorNames[ValidColorNames["chocolate"] = 15] = "chocolate";
2950
+ ValidColorNames[ValidColorNames["coral"] = 16] = "coral";
2951
+ ValidColorNames[ValidColorNames["cornflowerblue"] = 17] = "cornflowerblue";
2952
+ ValidColorNames[ValidColorNames["cornsilk"] = 18] = "cornsilk";
2953
+ ValidColorNames[ValidColorNames["crimson"] = 19] = "crimson";
2954
+ ValidColorNames[ValidColorNames["cyan"] = 20] = "cyan";
2955
+ ValidColorNames[ValidColorNames["darkblue"] = 21] = "darkblue";
2956
+ ValidColorNames[ValidColorNames["darkcyan"] = 22] = "darkcyan";
2957
+ ValidColorNames[ValidColorNames["darkgoldenrod"] = 23] = "darkgoldenrod";
2958
+ ValidColorNames[ValidColorNames["darkgray"] = 24] = "darkgray";
2959
+ ValidColorNames[ValidColorNames["darkgreen"] = 25] = "darkgreen";
2960
+ ValidColorNames[ValidColorNames["darkkhaki"] = 26] = "darkkhaki";
2961
+ ValidColorNames[ValidColorNames["darkmagenta"] = 27] = "darkmagenta";
2962
+ ValidColorNames[ValidColorNames["darkolivegreen"] = 28] = "darkolivegreen";
2963
+ ValidColorNames[ValidColorNames["darkorange"] = 29] = "darkorange";
2964
+ ValidColorNames[ValidColorNames["darkorchid"] = 30] = "darkorchid";
2965
+ ValidColorNames[ValidColorNames["darkred"] = 31] = "darkred";
2966
+ ValidColorNames[ValidColorNames["darksalmon"] = 32] = "darksalmon";
2967
+ ValidColorNames[ValidColorNames["darkseagreen"] = 33] = "darkseagreen";
2968
+ ValidColorNames[ValidColorNames["darkslateblue"] = 34] = "darkslateblue";
2969
+ ValidColorNames[ValidColorNames["darkslategray"] = 35] = "darkslategray";
2970
+ ValidColorNames[ValidColorNames["darkturquoise"] = 36] = "darkturquoise";
2971
+ ValidColorNames[ValidColorNames["darkviolet"] = 37] = "darkviolet";
2972
+ ValidColorNames[ValidColorNames["deeppink"] = 38] = "deeppink";
2973
+ ValidColorNames[ValidColorNames["deepskyblue"] = 39] = "deepskyblue";
2974
+ ValidColorNames[ValidColorNames["dimgray"] = 40] = "dimgray";
2975
+ ValidColorNames[ValidColorNames["dodgerblue"] = 41] = "dodgerblue";
2976
+ ValidColorNames[ValidColorNames["firebrick"] = 42] = "firebrick";
2977
+ ValidColorNames[ValidColorNames["floralwhite"] = 43] = "floralwhite";
2978
+ ValidColorNames[ValidColorNames["forestgreen"] = 44] = "forestgreen";
2979
+ ValidColorNames[ValidColorNames["fuchsia"] = 45] = "fuchsia";
2980
+ ValidColorNames[ValidColorNames["gainsboro"] = 46] = "gainsboro";
2981
+ ValidColorNames[ValidColorNames["ghostwhite"] = 47] = "ghostwhite";
2982
+ ValidColorNames[ValidColorNames["gold"] = 48] = "gold";
2983
+ ValidColorNames[ValidColorNames["goldenrod"] = 49] = "goldenrod";
2984
+ ValidColorNames[ValidColorNames["gray"] = 50] = "gray";
2985
+ ValidColorNames[ValidColorNames["green"] = 51] = "green";
2986
+ ValidColorNames[ValidColorNames["greenyellow"] = 52] = "greenyellow";
2987
+ ValidColorNames[ValidColorNames["honeydew"] = 53] = "honeydew";
2988
+ ValidColorNames[ValidColorNames["hotpink"] = 54] = "hotpink";
2989
+ ValidColorNames[ValidColorNames["indianred"] = 55] = "indianred";
2990
+ ValidColorNames[ValidColorNames["indigo"] = 56] = "indigo";
2991
+ ValidColorNames[ValidColorNames["ivory"] = 57] = "ivory";
2992
+ ValidColorNames[ValidColorNames["khaki"] = 58] = "khaki";
2993
+ ValidColorNames[ValidColorNames["lavender"] = 59] = "lavender";
2994
+ ValidColorNames[ValidColorNames["lavenderblush"] = 60] = "lavenderblush";
2995
+ ValidColorNames[ValidColorNames["lawngreen"] = 61] = "lawngreen";
2996
+ ValidColorNames[ValidColorNames["lemonchiffon"] = 62] = "lemonchiffon";
2997
+ ValidColorNames[ValidColorNames["lightblue"] = 63] = "lightblue";
2998
+ ValidColorNames[ValidColorNames["lightcoral"] = 64] = "lightcoral";
2999
+ ValidColorNames[ValidColorNames["lightcyan"] = 65] = "lightcyan";
3000
+ ValidColorNames[ValidColorNames["lightgoldenrodyellow"] = 66] = "lightgoldenrodyellow";
3001
+ ValidColorNames[ValidColorNames["lightgrey"] = 67] = "lightgrey";
3002
+ ValidColorNames[ValidColorNames["lightgreen"] = 68] = "lightgreen";
3003
+ ValidColorNames[ValidColorNames["lightpink"] = 69] = "lightpink";
3004
+ ValidColorNames[ValidColorNames["lightsalmon"] = 70] = "lightsalmon";
3005
+ ValidColorNames[ValidColorNames["lightseagreen"] = 71] = "lightseagreen";
3006
+ ValidColorNames[ValidColorNames["lightskyblue"] = 72] = "lightskyblue";
3007
+ ValidColorNames[ValidColorNames["lightslategray"] = 73] = "lightslategray";
3008
+ ValidColorNames[ValidColorNames["lightsteelblue"] = 74] = "lightsteelblue";
3009
+ ValidColorNames[ValidColorNames["lightyellow"] = 75] = "lightyellow";
3010
+ ValidColorNames[ValidColorNames["lime"] = 76] = "lime";
3011
+ ValidColorNames[ValidColorNames["limegreen"] = 77] = "limegreen";
3012
+ ValidColorNames[ValidColorNames["linen"] = 78] = "linen";
3013
+ ValidColorNames[ValidColorNames["magenta"] = 79] = "magenta";
3014
+ ValidColorNames[ValidColorNames["maroon"] = 80] = "maroon";
3015
+ ValidColorNames[ValidColorNames["mediumaquamarine"] = 81] = "mediumaquamarine";
3016
+ ValidColorNames[ValidColorNames["mediumblue"] = 82] = "mediumblue";
3017
+ ValidColorNames[ValidColorNames["mediumorchid"] = 83] = "mediumorchid";
3018
+ ValidColorNames[ValidColorNames["mediumpurple"] = 84] = "mediumpurple";
3019
+ ValidColorNames[ValidColorNames["mediumseagreen"] = 85] = "mediumseagreen";
3020
+ ValidColorNames[ValidColorNames["mediumslateblue"] = 86] = "mediumslateblue";
3021
+ ValidColorNames[ValidColorNames["mediumspringgreen"] = 87] = "mediumspringgreen";
3022
+ ValidColorNames[ValidColorNames["mediumturquoise"] = 88] = "mediumturquoise";
3023
+ ValidColorNames[ValidColorNames["mediumvioletred"] = 89] = "mediumvioletred";
3024
+ ValidColorNames[ValidColorNames["midnightblue"] = 90] = "midnightblue";
3025
+ ValidColorNames[ValidColorNames["mintcream"] = 91] = "mintcream";
3026
+ ValidColorNames[ValidColorNames["mistyrose"] = 92] = "mistyrose";
3027
+ ValidColorNames[ValidColorNames["moccasin"] = 93] = "moccasin";
3028
+ ValidColorNames[ValidColorNames["navajowhite"] = 94] = "navajowhite";
3029
+ ValidColorNames[ValidColorNames["navy"] = 95] = "navy";
3030
+ ValidColorNames[ValidColorNames["oldlace"] = 96] = "oldlace";
3031
+ ValidColorNames[ValidColorNames["olive"] = 97] = "olive";
3032
+ ValidColorNames[ValidColorNames["olivedrab"] = 98] = "olivedrab";
3033
+ ValidColorNames[ValidColorNames["orange"] = 99] = "orange";
3034
+ ValidColorNames[ValidColorNames["orangered"] = 100] = "orangered";
3035
+ ValidColorNames[ValidColorNames["orchid"] = 101] = "orchid";
3036
+ ValidColorNames[ValidColorNames["palegoldenrod"] = 102] = "palegoldenrod";
3037
+ ValidColorNames[ValidColorNames["palegreen"] = 103] = "palegreen";
3038
+ ValidColorNames[ValidColorNames["paleturquoise"] = 104] = "paleturquoise";
3039
+ ValidColorNames[ValidColorNames["palevioletred"] = 105] = "palevioletred";
3040
+ ValidColorNames[ValidColorNames["papayawhip"] = 106] = "papayawhip";
3041
+ ValidColorNames[ValidColorNames["peachpuff"] = 107] = "peachpuff";
3042
+ ValidColorNames[ValidColorNames["peru"] = 108] = "peru";
3043
+ ValidColorNames[ValidColorNames["pink"] = 109] = "pink";
3044
+ ValidColorNames[ValidColorNames["plum"] = 110] = "plum";
3045
+ ValidColorNames[ValidColorNames["powderblue"] = 111] = "powderblue";
3046
+ ValidColorNames[ValidColorNames["purple"] = 112] = "purple";
3047
+ ValidColorNames[ValidColorNames["red"] = 113] = "red";
3048
+ ValidColorNames[ValidColorNames["rosybrown"] = 114] = "rosybrown";
3049
+ ValidColorNames[ValidColorNames["royalblue"] = 115] = "royalblue";
3050
+ ValidColorNames[ValidColorNames["saddlebrown"] = 116] = "saddlebrown";
3051
+ ValidColorNames[ValidColorNames["salmon"] = 117] = "salmon";
3052
+ ValidColorNames[ValidColorNames["sandybrown"] = 118] = "sandybrown";
3053
+ ValidColorNames[ValidColorNames["seagreen"] = 119] = "seagreen";
3054
+ ValidColorNames[ValidColorNames["seashell"] = 120] = "seashell";
3055
+ ValidColorNames[ValidColorNames["sienna"] = 121] = "sienna";
3056
+ ValidColorNames[ValidColorNames["silver"] = 122] = "silver";
3057
+ ValidColorNames[ValidColorNames["skyblue"] = 123] = "skyblue";
3058
+ ValidColorNames[ValidColorNames["slateblue"] = 124] = "slateblue";
3059
+ ValidColorNames[ValidColorNames["slategray"] = 125] = "slategray";
3060
+ ValidColorNames[ValidColorNames["snow"] = 126] = "snow";
3061
+ ValidColorNames[ValidColorNames["springgreen"] = 127] = "springgreen";
3062
+ ValidColorNames[ValidColorNames["steelblue"] = 128] = "steelblue";
3063
+ ValidColorNames[ValidColorNames["tan"] = 129] = "tan";
3064
+ ValidColorNames[ValidColorNames["teal"] = 130] = "teal";
3065
+ ValidColorNames[ValidColorNames["thistle"] = 131] = "thistle";
3066
+ ValidColorNames[ValidColorNames["tomato"] = 132] = "tomato";
3067
+ ValidColorNames[ValidColorNames["turquoise"] = 133] = "turquoise";
3068
+ ValidColorNames[ValidColorNames["violet"] = 134] = "violet";
3069
+ ValidColorNames[ValidColorNames["wheat"] = 135] = "wheat";
3070
+ ValidColorNames[ValidColorNames["white"] = 136] = "white";
3071
+ ValidColorNames[ValidColorNames["whitesmoke"] = 137] = "whitesmoke";
3072
+ ValidColorNames[ValidColorNames["yellow"] = 138] = "yellow";
3073
+ ValidColorNames[ValidColorNames["yellowgreen"] = 139] = "yellowgreen";
3074
+ })(ValidColorNames || (ValidColorNames = {}));
3075
+ function isValidColor(color) {
3076
+ const hexRegex = new RegExp('^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$');
3077
+ const isValidHex = hexRegex.test(color);
3078
+ const isValidCSSColorName = !!ValidColorNames[color];
3079
+ return isValidHex || isValidCSSColorName;
3080
+ }
3081
+ function getCSSProperty(name, containerStyles, hostElementStyles) {
3082
+ if (!name)
3083
+ return;
3084
+ let fallback;
3085
+ if (name.startsWith('var(') && name.endsWith(')')) {
3086
+ const regExp = /var\((.*)\)/g;
3087
+ const result = regExp.exec(name);
3088
+ const split = result.length >= 2 ? result[1].split(',') : [];
3089
+ name = split[0];
3090
+ fallback = split[1];
3091
+ }
3092
+ let result = containerStyles.getPropertyValue(name).trim();
3093
+ if (!result)
3094
+ result = hostElementStyles.getPropertyValue(name).trim();
3095
+ return result || fallback;
3096
+ }
3097
+ function formatValue(value, format) {
3098
+ const valueAsFloat = parseFloat(value.toString());
3099
+ if (isNaN(valueAsFloat))
3100
+ return;
3101
+ const decimals = isNaN(+format.decimals) ? 0 : +format.decimals;
3102
+ if (format.type === 'currency') {
3103
+ return Intl.NumberFormat('en-US', {
3104
+ style: 'currency',
3105
+ currency: 'USD',
3106
+ maximumFractionDigits: decimals,
3107
+ minimumFractionDigits: decimals,
3108
+ }).format(valueAsFloat);
3109
+ }
3110
+ else {
3111
+ return Intl.NumberFormat('en-US').format(valueAsFloat);
3112
+ }
3113
+ }
3114
+
3115
+ exports.createClipPath = createClipPath;
3116
+ exports.createGridClipPath = createGridClipPath;
3117
+ exports.createPolarClipPath = createPolarClipPath;
3118
+ exports.createSeriesData = createSeriesData;
3119
+ exports.dataSample = dataSample;
3120
+ exports.formatValue = formatValue;
3121
+ exports.getCSSProperty = getCSSProperty;
3122
+ exports.getDefaultInterpolatedLabel = getDefaultInterpolatedLabel;
3123
+ exports.getDefaultLabel = getDefaultLabel;
3124
+ exports.install = install$1;
3125
+ exports.install$1 = install;
3126
+ exports.isCoordinateSystemType = isCoordinateSystemType;
3127
+ exports.isValidColor = isValidColor;