@perses-dev/timeseries-chart-plugin 0.13.0 → 0.14.0-beta.2

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 (172) hide show
  1. package/__mf/js/TimeSeriesChart.b9caac04.js +7 -0
  2. package/__mf/js/async/121.fde1320e.js +2 -0
  3. package/__mf/js/async/{527.f97d1b86.js → 182.9e1e293f.js} +9 -9
  4. package/__mf/js/async/192.66c6659d.js +1 -0
  5. package/__mf/js/async/2.166bda4f.js +1 -0
  6. package/__mf/js/async/235.76fd7af2.js +1 -0
  7. package/__mf/js/async/274.e4ed32f7.js +2 -0
  8. package/__mf/js/async/319.8e262f9c.js +1 -0
  9. package/__mf/js/async/356.52455d93.js +1 -0
  10. package/__mf/js/async/384.f40367cc.js +1 -0
  11. package/__mf/js/async/392.8cb3dcaa.js +2 -0
  12. package/__mf/js/async/463.f5dc7759.js +7 -0
  13. package/__mf/js/async/{694.0fb9ee5a.js.LICENSE.txt → 463.f5dc7759.js.LICENSE.txt} +41 -1
  14. package/__mf/js/async/465.add3260a.js +1 -0
  15. package/__mf/js/async/470.beedcbcc.js +2 -0
  16. package/__mf/js/async/522.806db24f.js +22 -0
  17. package/__mf/js/async/525.8b92c616.js +37 -0
  18. package/__mf/js/async/587.828c454a.js +1 -0
  19. package/__mf/js/async/597.0c5bd6dd.js +2 -0
  20. package/__mf/js/async/612.b2f31132.js +3 -0
  21. package/__mf/js/async/616.804d525d.js +1 -0
  22. package/__mf/js/async/663.892b9ad5.js +1 -0
  23. package/__mf/js/async/700.25c7e5dd.js +1 -0
  24. package/__mf/js/async/724.f74ffa12.js +1 -0
  25. package/__mf/js/async/730.058dea58.js +2 -0
  26. package/__mf/js/async/865.cb917066.js +2 -0
  27. package/__mf/js/async/941.3bb54150.js +2 -0
  28. package/__mf/js/async/955.52ca0671.js +1 -0
  29. package/__mf/js/async/968.2dd830b3.js +1 -0
  30. package/__mf/js/async/__federation_expose_TimeSeriesChart.4ddb01e0.js +1 -0
  31. package/__mf/js/async/lib-router.ecb51f08.js +2 -0
  32. package/__mf/js/main.f55169be.js +7 -0
  33. package/lib/GeneralSettingsEditor.d.ts +2 -2
  34. package/lib/GeneralSettingsEditor.d.ts.map +1 -1
  35. package/lib/GeneralSettingsEditor.js +7 -7
  36. package/lib/GeneralSettingsEditor.js.map +1 -1
  37. package/lib/QuerySettingsEditor.d.ts +2 -2
  38. package/lib/QuerySettingsEditor.d.ts.map +1 -1
  39. package/lib/QuerySettingsEditor.js +11 -11
  40. package/lib/QuerySettingsEditor.js.map +1 -1
  41. package/lib/TimeSeriesChart.d.ts +3 -3
  42. package/lib/TimeSeriesChart.d.ts.map +1 -1
  43. package/lib/TimeSeriesChart.js +6 -5
  44. package/lib/TimeSeriesChart.js.map +1 -1
  45. package/lib/TimeSeriesChartBase.d.ts +4 -4
  46. package/lib/TimeSeriesChartBase.d.ts.map +1 -1
  47. package/lib/TimeSeriesChartBase.js +12 -12
  48. package/lib/TimeSeriesChartBase.js.map +1 -1
  49. package/lib/TimeSeriesChartPanel.d.ts +4 -4
  50. package/lib/TimeSeriesChartPanel.d.ts.map +1 -1
  51. package/lib/TimeSeriesChartPanel.js +12 -12
  52. package/lib/TimeSeriesChartPanel.js.map +1 -1
  53. package/lib/TimeSeriesExportAction.d.ts +1 -1
  54. package/lib/TimeSeriesExportAction.d.ts.map +1 -1
  55. package/lib/TimeSeriesExportAction.js +5 -5
  56. package/lib/TimeSeriesExportAction.js.map +1 -1
  57. package/lib/VisualOptionsEditor.d.ts +2 -2
  58. package/lib/VisualOptionsEditor.d.ts.map +1 -1
  59. package/lib/VisualOptionsEditor.js +4 -4
  60. package/lib/VisualOptionsEditor.js.map +1 -1
  61. package/lib/YAxisOptionsEditor.d.ts +2 -2
  62. package/lib/YAxisOptionsEditor.d.ts.map +1 -1
  63. package/lib/YAxisOptionsEditor.js +3 -3
  64. package/lib/YAxisOptionsEditor.js.map +1 -1
  65. package/lib/annotations/AnnotationTooltip.d.ts +2 -2
  66. package/lib/annotations/AnnotationTooltip.d.ts.map +1 -1
  67. package/lib/annotations/AnnotationTooltip.js +6 -6
  68. package/lib/annotations/AnnotationTooltip.js.map +1 -1
  69. package/lib/bootstrap.js +2 -2
  70. package/lib/getPluginModule.d.ts +1 -1
  71. package/lib/getPluginModule.d.ts.map +1 -1
  72. package/lib/getPluginModule.js +3 -1
  73. package/lib/getPluginModule.js.map +1 -1
  74. package/lib/index-federation.js +1 -1
  75. package/lib/index.js +9 -9
  76. package/lib/index.js.map +1 -1
  77. package/lib/setup-tests.d.ts +1 -1
  78. package/lib/setup-tests.d.ts.map +1 -1
  79. package/lib/setup-tests.js +2 -2
  80. package/lib/setup-tests.js.map +1 -1
  81. package/lib/test/mock-query-results.d.ts +1 -1
  82. package/lib/test/mock-query-results.d.ts.map +1 -1
  83. package/lib/test/mock-query-results.js.map +1 -1
  84. package/lib/time-series-chart-model.d.ts +3 -3
  85. package/lib/time-series-chart-model.d.ts.map +1 -1
  86. package/lib/time-series-chart-model.js.map +1 -1
  87. package/lib/utils/annotation.d.ts +2 -2
  88. package/lib/utils/annotation.d.ts.map +1 -1
  89. package/lib/utils/annotation.js.map +1 -1
  90. package/lib/utils/data-transform.d.ts +5 -5
  91. package/lib/utils/data-transform.d.ts.map +1 -1
  92. package/lib/utils/data-transform.js +3 -3
  93. package/lib/utils/data-transform.js.map +1 -1
  94. package/lib/utils/palette-gen.d.ts +1 -1
  95. package/lib/utils/palette-gen.d.ts.map +1 -1
  96. package/lib/utils/palette-gen.js +1 -1
  97. package/lib/utils/palette-gen.js.map +1 -1
  98. package/lib/utils/palette.js +1 -1
  99. package/lib/utils/palette.js.map +1 -1
  100. package/lib/utils/timezone-formatter.js +1 -1
  101. package/mf-manifest.json +37 -81
  102. package/mf-stats.json +39 -91
  103. package/package.json +11 -11
  104. package/__mf/js/TimeSeriesChart.42841bce.js +0 -7
  105. package/__mf/js/async/121.c3c0e54f.js +0 -2
  106. package/__mf/js/async/177.2fef2962.js +0 -1
  107. package/__mf/js/async/187.f5e8932b.js +0 -1
  108. package/__mf/js/async/192.c3dd56d5.js +0 -1
  109. package/__mf/js/async/2.60fa4a40.js +0 -1
  110. package/__mf/js/async/208.b9f374ad.js +0 -7
  111. package/__mf/js/async/208.b9f374ad.js.LICENSE.txt +0 -39
  112. package/__mf/js/async/235.d23c8ef0.js +0 -1
  113. package/__mf/js/async/274.72dfa9c8.js +0 -2
  114. package/__mf/js/async/356.8170c96d.js +0 -1
  115. package/__mf/js/async/392.b9ba5bf2.js +0 -2
  116. package/__mf/js/async/470.e09f33b7.js +0 -2
  117. package/__mf/js/async/491.85194549.js +0 -1
  118. package/__mf/js/async/518.2ac1df43.js +0 -38
  119. package/__mf/js/async/52.0d78de2b.js +0 -1
  120. package/__mf/js/async/546.5fecffa4.js +0 -3
  121. package/__mf/js/async/568.45da2c30.js +0 -1
  122. package/__mf/js/async/587.c9460696.js +0 -1
  123. package/__mf/js/async/588.0a1aa144.js +0 -1
  124. package/__mf/js/async/603.3b771310.js +0 -2
  125. package/__mf/js/async/616.79484ac8.js +0 -1
  126. package/__mf/js/async/655.2f794f77.js +0 -1
  127. package/__mf/js/async/694.0fb9ee5a.js +0 -2
  128. package/__mf/js/async/702.785cd635.js +0 -2
  129. package/__mf/js/async/71.8c6cf914.js +0 -1
  130. package/__mf/js/async/724.c45dcf5b.js +0 -1
  131. package/__mf/js/async/873.04a201bf.js +0 -1
  132. package/__mf/js/async/941.b89f8595.js +0 -2
  133. package/__mf/js/async/955.176fe200.js +0 -1
  134. package/__mf/js/async/968.2a9fb1a0.js +0 -1
  135. package/__mf/js/async/978.a9865b23.js +0 -1
  136. package/__mf/js/async/984.83bd5c6d.js +0 -22
  137. package/__mf/js/async/__federation_expose_TimeSeriesChart.0ab11cd4.js +0 -1
  138. package/__mf/js/async/lib-router.319c02cd.js +0 -2
  139. package/__mf/js/main.691eecd6.js +0 -7
  140. package/lib/cjs/GeneralSettingsEditor.js +0 -103
  141. package/lib/cjs/QuerySettingsEditor.js +0 -666
  142. package/lib/cjs/TimeSeriesChart.js +0 -50
  143. package/lib/cjs/TimeSeriesChartBase.js +0 -488
  144. package/lib/cjs/TimeSeriesChartPanel.js +0 -456
  145. package/lib/cjs/TimeSeriesExportAction.js +0 -124
  146. package/lib/cjs/VisualOptionsEditor.js +0 -161
  147. package/lib/cjs/YAxisOptionsEditor.js +0 -118
  148. package/lib/cjs/annotations/AnnotationTooltip.js +0 -370
  149. package/lib/cjs/bootstrap.js +0 -26
  150. package/lib/cjs/env.d.js +0 -14
  151. package/lib/cjs/getPluginModule.js +0 -39
  152. package/lib/cjs/index-federation.js +0 -55
  153. package/lib/cjs/index.js +0 -44
  154. package/lib/cjs/setup-tests.js +0 -19
  155. package/lib/cjs/test/mock-query-results.js +0 -403
  156. package/lib/cjs/time-series-chart-model.js +0 -225
  157. package/lib/cjs/utils/annotation.js +0 -37
  158. package/lib/cjs/utils/data-transform.js +0 -243
  159. package/lib/cjs/utils/palette-gen.js +0 -75
  160. package/lib/cjs/utils/palette.js +0 -83
  161. package/lib/cjs/utils/timezone-formatter.js +0 -48
  162. /package/__mf/css/async/{208.85c2cbf6.css → 463.85c2cbf6.css} +0 -0
  163. /package/__mf/js/async/{121.c3c0e54f.js.LICENSE.txt → 121.fde1320e.js.LICENSE.txt} +0 -0
  164. /package/__mf/js/async/{527.f97d1b86.js.LICENSE.txt → 182.9e1e293f.js.LICENSE.txt} +0 -0
  165. /package/__mf/js/async/{274.72dfa9c8.js.LICENSE.txt → 274.e4ed32f7.js.LICENSE.txt} +0 -0
  166. /package/__mf/js/async/{392.b9ba5bf2.js.LICENSE.txt → 392.8cb3dcaa.js.LICENSE.txt} +0 -0
  167. /package/__mf/js/async/{470.e09f33b7.js.LICENSE.txt → 470.beedcbcc.js.LICENSE.txt} +0 -0
  168. /package/__mf/js/async/{984.83bd5c6d.js.LICENSE.txt → 522.806db24f.js.LICENSE.txt} +0 -0
  169. /package/__mf/js/async/{603.3b771310.js.LICENSE.txt → 597.0c5bd6dd.js.LICENSE.txt} +0 -0
  170. /package/__mf/js/async/{702.785cd635.js.LICENSE.txt → 865.cb917066.js.LICENSE.txt} +0 -0
  171. /package/__mf/js/async/{941.b89f8595.js.LICENSE.txt → 941.3bb54150.js.LICENSE.txt} +0 -0
  172. /package/__mf/js/async/{lib-router.319c02cd.js.LICENSE.txt → lib-router.ecb51f08.js.LICENSE.txt} +0 -0
@@ -1,225 +0,0 @@
1
- // Copyright The Perses Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- "use strict";
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
17
- function _export(target, all) {
18
- for(var name in all)Object.defineProperty(target, name, {
19
- enumerable: true,
20
- get: Object.getOwnPropertyDescriptor(all, name).get
21
- });
22
- }
23
- _export(exports, {
24
- get DEFAULT_AREA_OPACITY () {
25
- return DEFAULT_AREA_OPACITY;
26
- },
27
- get DEFAULT_CONNECT_NULLS () {
28
- return DEFAULT_CONNECT_NULLS;
29
- },
30
- get DEFAULT_DISPLAY () {
31
- return DEFAULT_DISPLAY;
32
- },
33
- get DEFAULT_FORMAT () {
34
- return DEFAULT_FORMAT;
35
- },
36
- get DEFAULT_LINE_STYLE () {
37
- return DEFAULT_LINE_STYLE;
38
- },
39
- get DEFAULT_LINE_WIDTH () {
40
- return DEFAULT_LINE_WIDTH;
41
- },
42
- get DEFAULT_POINT_RADIUS () {
43
- return DEFAULT_POINT_RADIUS;
44
- },
45
- get DEFAULT_VISUAL () {
46
- return DEFAULT_VISUAL;
47
- },
48
- get DEFAULT_Y_AXIS () {
49
- return DEFAULT_Y_AXIS;
50
- },
51
- get LINE_STYLE_CONFIG () {
52
- return LINE_STYLE_CONFIG;
53
- },
54
- get LOG_BASE_CONFIG () {
55
- return LOG_BASE_CONFIG;
56
- },
57
- get LOG_BASE_OPTIONS () {
58
- return LOG_BASE_OPTIONS;
59
- },
60
- get NEGATIVE_MIN_VALUE_MULTIPLIER () {
61
- return NEGATIVE_MIN_VALUE_MULTIPLIER;
62
- },
63
- get OPACITY_CONFIG () {
64
- return OPACITY_CONFIG;
65
- },
66
- get POINT_SIZE_OFFSET () {
67
- return POINT_SIZE_OFFSET;
68
- },
69
- get POSITIVE_MIN_VALUE_MULTIPLIER () {
70
- return POSITIVE_MIN_VALUE_MULTIPLIER;
71
- },
72
- get STACK_CONFIG () {
73
- return STACK_CONFIG;
74
- },
75
- get STACK_OPTIONS () {
76
- return STACK_OPTIONS;
77
- },
78
- get THRESHOLD_PLOT_INTERVAL () {
79
- return THRESHOLD_PLOT_INTERVAL;
80
- },
81
- get VISUAL_CONFIG () {
82
- return VISUAL_CONFIG;
83
- },
84
- get Y_AXIS_CONFIG () {
85
- return Y_AXIS_CONFIG;
86
- },
87
- get createInitialTimeSeriesChartOptions () {
88
- return createInitialTimeSeriesChartOptions;
89
- }
90
- });
91
- const DEFAULT_FORMAT = {
92
- unit: 'decimal',
93
- shortValues: true
94
- };
95
- const DEFAULT_Y_AXIS = {
96
- show: true,
97
- label: '',
98
- format: DEFAULT_FORMAT,
99
- min: undefined,
100
- max: undefined,
101
- logBase: undefined
102
- };
103
- const Y_AXIS_CONFIG = {
104
- show: {
105
- label: 'Show'
106
- },
107
- label: {
108
- label: 'Label'
109
- },
110
- unit: {
111
- label: 'Unit'
112
- },
113
- min: {
114
- label: 'Min'
115
- },
116
- max: {
117
- label: 'Max'
118
- },
119
- logBase: {
120
- label: 'Log Base'
121
- }
122
- };
123
- const DEFAULT_DISPLAY = 'line';
124
- const DEFAULT_LINE_WIDTH = 1.25;
125
- const DEFAULT_LINE_STYLE = 'solid';
126
- const DEFAULT_AREA_OPACITY = 0;
127
- const POINT_SIZE_OFFSET = 1.5;
128
- const DEFAULT_POINT_RADIUS = DEFAULT_LINE_WIDTH + POINT_SIZE_OFFSET;
129
- const DEFAULT_CONNECT_NULLS = false;
130
- const DEFAULT_VISUAL = {
131
- display: DEFAULT_DISPLAY,
132
- lineWidth: DEFAULT_LINE_WIDTH,
133
- lineStyle: DEFAULT_LINE_STYLE,
134
- areaOpacity: DEFAULT_AREA_OPACITY,
135
- pointRadius: DEFAULT_POINT_RADIUS,
136
- connectNulls: DEFAULT_CONNECT_NULLS
137
- };
138
- const THRESHOLD_PLOT_INTERVAL = 15;
139
- const VISUAL_CONFIG = {
140
- lineWidth: {
141
- label: 'Line Width',
142
- testId: 'slider-line-width',
143
- min: 0.25,
144
- max: 3,
145
- step: 0.25
146
- },
147
- lineStyle: {
148
- label: 'Line Style'
149
- },
150
- pointRadius: {
151
- label: 'Point Radius',
152
- testId: 'slider-point-radius',
153
- min: 0,
154
- max: 6,
155
- step: 0.25
156
- },
157
- areaOpacity: {
158
- label: 'Area Opacity',
159
- testId: 'slider-area-opacity',
160
- min: 0,
161
- max: 1,
162
- step: 0.05
163
- },
164
- stack: {
165
- label: 'Stack Series'
166
- },
167
- connectNulls: {
168
- label: 'Connect Nulls'
169
- }
170
- };
171
- const STACK_CONFIG = {
172
- none: {
173
- label: 'None'
174
- },
175
- all: {
176
- label: 'All'
177
- }
178
- };
179
- const STACK_OPTIONS = Object.entries(STACK_CONFIG).map(([id, config])=>{
180
- return {
181
- id: id,
182
- ...config
183
- };
184
- });
185
- const LINE_STYLE_CONFIG = {
186
- solid: {
187
- label: 'Solid'
188
- },
189
- dashed: {
190
- label: 'Dashes'
191
- },
192
- dotted: {
193
- label: 'Dots'
194
- }
195
- };
196
- const OPACITY_CONFIG = {
197
- label: 'Opacity',
198
- testId: 'slider-opacity',
199
- min: 0,
200
- max: 1,
201
- step: 0.05
202
- };
203
- const LOG_BASE_CONFIG = {
204
- none: {
205
- label: 'None',
206
- log: undefined
207
- },
208
- '2': {
209
- label: '2',
210
- log: 2
211
- },
212
- '10': {
213
- label: '10',
214
- log: 10
215
- }
216
- };
217
- const LOG_BASE_OPTIONS = Object.entries(LOG_BASE_CONFIG).map(([id, config])=>({
218
- id: id,
219
- ...config
220
- }));
221
- const POSITIVE_MIN_VALUE_MULTIPLIER = 0.8;
222
- const NEGATIVE_MIN_VALUE_MULTIPLIER = 1.2;
223
- function createInitialTimeSeriesChartOptions() {
224
- return {};
225
- }
@@ -1,37 +0,0 @@
1
- // Copyright The Perses Authors
2
- // Licensed under the Apache License, Version 2.0 (the \"License\");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an \"AS IS\" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- "use strict";
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
17
- Object.defineProperty(exports, "convertAnnotationToTimeSeriesAnnotation", {
18
- enumerable: true,
19
- get: function() {
20
- return convertAnnotationToTimeSeriesAnnotation;
21
- }
22
- });
23
- function convertAnnotationToTimeSeriesAnnotation(annotations) {
24
- const result = [];
25
- for (const annotation of annotations){
26
- for (const item of annotation.data){
27
- if (annotation.definition.display.hidden) {
28
- continue;
29
- }
30
- result.push({
31
- ...annotation.definition.display,
32
- ...item
33
- });
34
- }
35
- }
36
- return result;
37
- }
@@ -1,243 +0,0 @@
1
- // Copyright The Perses Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- "use strict";
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
17
- function _export(target, all) {
18
- for(var name in all)Object.defineProperty(target, name, {
19
- enumerable: true,
20
- get: Object.getOwnPropertyDescriptor(all, name).get
21
- });
22
- }
23
- _export(exports, {
24
- get BLUR_FADEOUT_OPACITY () {
25
- return BLUR_FADEOUT_OPACITY;
26
- },
27
- get EMPTY_GRAPH_DATA () {
28
- return EMPTY_GRAPH_DATA;
29
- },
30
- get HIDE_DATAPOINTS_LIMIT () {
31
- return HIDE_DATAPOINTS_LIMIT;
32
- },
33
- get convertPanelYAxis () {
34
- return convertPanelYAxis;
35
- },
36
- get convertPercentThreshold () {
37
- return convertPercentThreshold;
38
- },
39
- get getCommonTimeScaleForQueries () {
40
- return getCommonTimeScaleForQueries;
41
- },
42
- get getThresholdSeries () {
43
- return getThresholdSeries;
44
- },
45
- get getTimeSeries () {
46
- return getTimeSeries;
47
- },
48
- get roundDown () {
49
- return roundDown;
50
- }
51
- });
52
- const _components = require("@perses-dev/components");
53
- const _timeserieschartmodel = require("../time-series-chart-model");
54
- const EMPTY_GRAPH_DATA = {
55
- timeSeries: [],
56
- xAxis: [],
57
- legendItems: []
58
- };
59
- const HIDE_DATAPOINTS_LIMIT = 70;
60
- const BLUR_FADEOUT_OPACITY = 0.5;
61
- function getCommonTimeScaleForQueries(queries) {
62
- const seriesData = queries.map((query)=>query.data);
63
- return (0, _components.getCommonTimeScale)(seriesData);
64
- }
65
- function getTimeSeries(id, datasetIndex, formattedName, visual, timeScale, paletteColor, querySettings, yAxisIndex) {
66
- const lineWidth = visual.lineWidth ?? _timeserieschartmodel.DEFAULT_LINE_WIDTH;
67
- const pointRadius = visual.pointRadius ?? _timeserieschartmodel.DEFAULT_POINT_RADIUS;
68
- const shouldStack = querySettings?.stack !== undefined ? querySettings.stack : visual.stack === 'all';
69
- // Shows datapoint symbols when selected time range is roughly 15 minutes or less
70
- const minuteMs = 60000;
71
- let showPoints = timeScale.rangeMs <= minuteMs * 15;
72
- // Allows overriding default behavior and opt-in to always show all symbols (can hurt performance)
73
- if (visual.showPoints === 'always') {
74
- showPoints = true;
75
- }
76
- if (visual.display === 'bar') {
77
- const series = {
78
- type: 'bar',
79
- id: id,
80
- datasetIndex,
81
- name: formattedName,
82
- color: paletteColor,
83
- stack: shouldStack ? 'all' : undefined,
84
- yAxisIndex: yAxisIndex,
85
- label: {
86
- show: false
87
- }
88
- };
89
- return series;
90
- }
91
- const series = {
92
- type: 'line',
93
- id: id,
94
- datasetIndex,
95
- name: formattedName,
96
- connectNulls: visual.connectNulls ?? _timeserieschartmodel.DEFAULT_CONNECT_NULLS,
97
- color: paletteColor,
98
- stack: shouldStack ? 'all' : undefined,
99
- yAxisIndex: yAxisIndex,
100
- sampling: 'lttb',
101
- progressiveThreshold: _components.OPTIMIZED_MODE_SERIES_LIMIT,
102
- showSymbol: showPoints,
103
- showAllSymbol: true,
104
- symbolSize: pointRadius,
105
- lineStyle: {
106
- width: lineWidth,
107
- type: querySettings?.lineStyle ?? visual.lineStyle
108
- },
109
- areaStyle: {
110
- opacity: querySettings?.areaOpacity ?? visual.areaOpacity ?? _timeserieschartmodel.DEFAULT_AREA_OPACITY
111
- },
112
- // https://echarts.apache.org/en/option.html#series-line.emphasis
113
- emphasis: {
114
- focus: 'series',
115
- disabled: visual.areaOpacity !== undefined && visual.areaOpacity > 0,
116
- lineStyle: {
117
- width: lineWidth + 1,
118
- opacity: 1,
119
- type: visual.lineStyle
120
- }
121
- },
122
- blur: {
123
- lineStyle: {
124
- width: lineWidth,
125
- opacity: BLUR_FADEOUT_OPACITY,
126
- type: visual.lineStyle
127
- }
128
- }
129
- };
130
- return series;
131
- }
132
- function getThresholdSeries(name, threshold, seriesIndex) {
133
- return {
134
- type: 'line',
135
- name: name,
136
- id: name,
137
- datasetId: name,
138
- datasetIndex: seriesIndex,
139
- color: threshold.color,
140
- label: {
141
- show: false
142
- },
143
- lineStyle: {
144
- type: 'dashed',
145
- width: 2
146
- },
147
- emphasis: {
148
- focus: 'series',
149
- lineStyle: {
150
- width: 2.5
151
- }
152
- },
153
- blur: {
154
- lineStyle: {
155
- opacity: BLUR_FADEOUT_OPACITY
156
- }
157
- }
158
- };
159
- }
160
- function convertPercentThreshold(percent, data, max, min) {
161
- const percentDecimal = percent / 100;
162
- const adjustedMax = max ?? findMax(data);
163
- const adjustedMin = min ?? 0;
164
- const total = adjustedMax - adjustedMin;
165
- return percentDecimal * total + adjustedMin;
166
- }
167
- function findMax(data) {
168
- let max = 0;
169
- if (data.length && data[0] !== undefined && data[0]?.values) {
170
- data.forEach((series)=>{
171
- series.values.forEach((valueTuple)=>{
172
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
173
- const [_, value] = valueTuple;
174
- // Use the absolute value so percent thresholds compute correctly against
175
- // negated series (e.g. when `querySettings[].negativeY` is enabled).
176
- if (typeof value === 'number' && Math.abs(value) > max) {
177
- max = Math.abs(value);
178
- }
179
- });
180
- });
181
- } else {
182
- data.forEach((series)=>{
183
- if (series.data !== undefined) {
184
- series.data.forEach((value)=>{
185
- if (typeof value === 'number' && Math.abs(value) > max) {
186
- max = Math.abs(value);
187
- }
188
- });
189
- }
190
- });
191
- }
192
- return max;
193
- }
194
- function convertPanelYAxis(inputAxis = {}) {
195
- // Determine the appropriate min value based on scale type and user input
196
- let minValue;
197
- if (inputAxis.logBase !== undefined) {
198
- // For logarithmic scales without explicit min:
199
- // Let ECharts auto-calculate the range based on data to avoid issues with
200
- // function-based calculations which can result in improper ranges (e.g., 1-10)
201
- minValue = undefined;
202
- } else if (inputAxis?.min !== undefined) {
203
- // User explicitly set a min value - use it for both linear and log scales
204
- minValue = inputAxis.min;
205
- } else {
206
- // For linear scales without explicit min:
207
- // Use dynamic calculation with padding for better visualization
208
- // https://echarts.apache.org/en/option.html#yAxis.min
209
- minValue = (value)=>{
210
- if (value.min >= 0 && value.min <= 1) {
211
- // Helps with PercentDecimal units, or datasets that return 0 or 1 booleans
212
- return 0;
213
- }
214
- // Note: We can tweak the MULTIPLIER constants if we want
215
- // TODO: Experiment with using a padding that is based on the difference between max value and min value
216
- if (value.min > 0) {
217
- return roundDown(value.min * _timeserieschartmodel.POSITIVE_MIN_VALUE_MULTIPLIER);
218
- } else {
219
- return roundDown(value.min * _timeserieschartmodel.NEGATIVE_MIN_VALUE_MULTIPLIER);
220
- }
221
- };
222
- }
223
- // Build the yAxis configuration
224
- const yAxis = {
225
- show: inputAxis?.show ?? _timeserieschartmodel.DEFAULT_Y_AXIS.show,
226
- min: minValue,
227
- max: inputAxis?.max
228
- };
229
- // Apply logarithmic scale settings if requested
230
- if (inputAxis.logBase !== undefined) {
231
- return {
232
- ...yAxis,
233
- type: 'log',
234
- logBase: inputAxis.logBase
235
- };
236
- }
237
- return yAxis;
238
- }
239
- function roundDown(num) {
240
- const magnitude = Math.floor(Math.log10(Math.abs(num)));
241
- const firstDigit = Math.floor(num / Math.pow(10, magnitude));
242
- return firstDigit * Math.pow(10, magnitude);
243
- }
@@ -1,75 +0,0 @@
1
- // Copyright The Perses Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- "use strict";
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
17
- function _export(target, all) {
18
- for(var name in all)Object.defineProperty(target, name, {
19
- enumerable: true,
20
- get: Object.getOwnPropertyDescriptor(all, name).get
21
- });
22
- }
23
- _export(exports, {
24
- get getAutoPaletteColor () {
25
- return getAutoPaletteColor;
26
- },
27
- get getCategoricalPaletteColor () {
28
- return getCategoricalPaletteColor;
29
- },
30
- get getConsistentSeriesNameColor () {
31
- return getConsistentSeriesNameColor;
32
- },
33
- get getSeriesColor () {
34
- return getSeriesColor;
35
- }
36
- });
37
- const _palette = require("./palette");
38
- function getSeriesColor(props) {
39
- const { categoricalPalette, visual, muiPrimaryColor, seriesName, seriesIndex, querySettings, queryHasMultipleResults } = props;
40
- // Use color overrides defined in query settings in priority, if applicable
41
- if (querySettings) {
42
- if (querySettings.colorMode === 'fixed' && querySettings.colorValue) {
43
- return querySettings.colorValue;
44
- } else if (querySettings.colorMode === 'fixed-single' && !queryHasMultipleResults && querySettings.colorValue) {
45
- return querySettings.colorValue;
46
- }
47
- }
48
- // Fallback is unlikely to set unless echarts theme palette in charts theme provider is undefined.
49
- const fallbackColor = Array.isArray(categoricalPalette) && categoricalPalette[0] ? categoricalPalette[0] // Needed since echarts color property isn't always an array.
50
- : muiPrimaryColor;
51
- // Explicit way to always cycle through classical palette instead of changing when based on number of series.
52
- if (visual.palette?.mode === 'categorical') {
53
- return getCategoricalPaletteColor(categoricalPalette, seriesIndex, fallbackColor);
54
- }
55
- return getAutoPaletteColor(seriesName, fallbackColor);
56
- }
57
- function getAutoPaletteColor(name, fallbackColor) {
58
- // corresponds to 'Auto' in palette.kind for generative color palette
59
- const generatedColor = getConsistentSeriesNameColor(name);
60
- return generatedColor ?? fallbackColor;
61
- }
62
- function getCategoricalPaletteColor(palette, seriesIndex, fallbackColor) {
63
- if (palette === undefined) {
64
- return fallbackColor;
65
- }
66
- // Loop through predefined static color palette
67
- const paletteTotalColors = palette.length ?? 1;
68
- const paletteIndex = seriesIndex % paletteTotalColors;
69
- // fallback color comes from echarts theme
70
- const seriesColor = palette[paletteIndex] ?? fallbackColor;
71
- return seriesColor;
72
- }
73
- function getConsistentSeriesNameColor(inputString) {
74
- return (0, _palette.getConsistentColor)(inputString, inputString.toLowerCase().includes('error'));
75
- }
@@ -1,83 +0,0 @@
1
- // Copyright The Perses Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- "use strict";
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
17
- function _export(target, all) {
18
- for(var name in all)Object.defineProperty(target, name, {
19
- enumerable: true,
20
- get: Object.getOwnPropertyDescriptor(all, name).get
21
- });
22
- }
23
- _export(exports, {
24
- get getConsistentCategoricalColor () {
25
- return getConsistentCategoricalColor;
26
- },
27
- get getConsistentColor () {
28
- return getConsistentColor;
29
- }
30
- });
31
- const _colorhash = /*#__PURE__*/ _interop_require_default(require("color-hash"));
32
- function _interop_require_default(obj) {
33
- return obj && obj.__esModule ? obj : {
34
- default: obj
35
- };
36
- }
37
- // Valid hue values are 0 to 360 and can be adjusted to control the generated colors.
38
- // More info: https://github.com/zenozeng/color-hash#custom-hue
39
- // Picked min of 20 and max of 360 to exclude common threshold colors (red).
40
- // Items with "error" in them will always be generated as red.
41
- const ERROR_HUE_CUTOFF = 20;
42
- const colorGenerator = new _colorhash.default({
43
- hue: {
44
- min: ERROR_HUE_CUTOFF,
45
- max: 360
46
- }
47
- });
48
- const redColorGenerator = new _colorhash.default({
49
- hue: {
50
- min: 0,
51
- max: ERROR_HUE_CUTOFF
52
- }
53
- });
54
- function computeConsistentColor(name, error) {
55
- const [hue, saturation, lightness] = error ? redColorGenerator.hsl(name) : colorGenerator.hsl(name);
56
- const saturationPercent = `${(saturation * 100).toFixed(0)}%`;
57
- const lightnessPercent = `${(lightness * 100).toFixed(0)}%`;
58
- return `hsla(${hue.toFixed(2)},${saturationPercent},${lightnessPercent},0.9)`;
59
- }
60
- // To check whether a color has already been generated for a given string.
61
- // TODO: Predefined color aliases will be defined here
62
- const colorLookup = {};
63
- function getConsistentColor(name, error) {
64
- const key = `${name}_____${error}`;
65
- let value = colorLookup[key];
66
- if (!value) {
67
- value = computeConsistentColor(name, error);
68
- colorLookup[key] = value;
69
- }
70
- return value;
71
- }
72
- function getConsistentCategoricalColor(name, error, categoricalPalette, errorPalette) {
73
- const palette = error ? errorPalette : categoricalPalette;
74
- if (palette.length === 0) {
75
- console.warn('getConsistentCategoricalColor() called with empty color palette, fallback to #000');
76
- return '#000';
77
- }
78
- let hash = 0;
79
- for(let i = 0; i < name.length; i++){
80
- hash = name.charCodeAt(i) + ((hash << 5) - hash);
81
- }
82
- return palette[Math.abs(hash) % palette.length] ?? '#000';
83
- }