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