@perses-dev/components 0.51.0-rc.0 → 0.51.0-rc.1

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 (146) hide show
  1. package/README.md +1 -8
  2. package/dist/EChart/EChart.d.ts.map +1 -1
  3. package/dist/EChart/EChart.js +13 -4
  4. package/dist/EChart/EChart.js.map +1 -1
  5. package/dist/TimeSeriesTooltip/index.d.ts +0 -1
  6. package/dist/TimeSeriesTooltip/index.d.ts.map +1 -1
  7. package/dist/TimeSeriesTooltip/index.js +0 -1
  8. package/dist/TimeSeriesTooltip/index.js.map +1 -1
  9. package/dist/cjs/EChart/EChart.js +11 -2
  10. package/dist/cjs/TimeSeriesTooltip/index.js +0 -1
  11. package/dist/cjs/context/ChartsProvider.js +3 -1
  12. package/dist/cjs/index.js +0 -7
  13. package/dist/cjs/test-utils/theme.js +1 -0
  14. package/dist/cjs/utils/axis.js +3 -18
  15. package/dist/cjs/utils/format.js +0 -21
  16. package/dist/context/ChartsProvider.d.ts +2 -0
  17. package/dist/context/ChartsProvider.d.ts.map +1 -1
  18. package/dist/context/ChartsProvider.js +3 -1
  19. package/dist/context/ChartsProvider.js.map +1 -1
  20. package/dist/index.d.ts +0 -7
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +0 -7
  23. package/dist/index.js.map +1 -1
  24. package/dist/model/graph.d.ts +0 -1
  25. package/dist/model/graph.d.ts.map +1 -1
  26. package/dist/model/graph.js.map +1 -1
  27. package/dist/test-utils/theme.d.ts.map +1 -1
  28. package/dist/test-utils/theme.js +1 -0
  29. package/dist/test-utils/theme.js.map +1 -1
  30. package/dist/utils/axis.d.ts +0 -4
  31. package/dist/utils/axis.d.ts.map +1 -1
  32. package/dist/utils/axis.js +0 -9
  33. package/dist/utils/axis.js.map +1 -1
  34. package/dist/utils/chart-actions.d.ts +0 -2
  35. package/dist/utils/chart-actions.d.ts.map +1 -1
  36. package/dist/utils/chart-actions.js.map +1 -1
  37. package/dist/utils/format.d.ts +0 -1
  38. package/dist/utils/format.d.ts.map +1 -1
  39. package/dist/utils/format.js +0 -20
  40. package/dist/utils/format.js.map +1 -1
  41. package/package.json +2 -7
  42. package/dist/BarChart/BarChart.d.ts +0 -16
  43. package/dist/BarChart/BarChart.d.ts.map +0 -1
  44. package/dist/BarChart/BarChart.js +0 -134
  45. package/dist/BarChart/BarChart.js.map +0 -1
  46. package/dist/BarChart/index.d.ts +0 -2
  47. package/dist/BarChart/index.d.ts.map +0 -1
  48. package/dist/BarChart/index.js +0 -15
  49. package/dist/BarChart/index.js.map +0 -1
  50. package/dist/GaugeChart/GaugeChart.d.ts +0 -23
  51. package/dist/GaugeChart/GaugeChart.d.ts.map +0 -1
  52. package/dist/GaugeChart/GaugeChart.js +0 -214
  53. package/dist/GaugeChart/GaugeChart.js.map +0 -1
  54. package/dist/GaugeChart/index.d.ts +0 -2
  55. package/dist/GaugeChart/index.d.ts.map +0 -1
  56. package/dist/GaugeChart/index.js +0 -15
  57. package/dist/GaugeChart/index.js.map +0 -1
  58. package/dist/LineChart/LineChart.d.ts +0 -22
  59. package/dist/LineChart/LineChart.d.ts.map +0 -1
  60. package/dist/LineChart/LineChart.js +0 -266
  61. package/dist/LineChart/LineChart.js.map +0 -1
  62. package/dist/LineChart/index.d.ts +0 -2
  63. package/dist/LineChart/index.d.ts.map +0 -1
  64. package/dist/LineChart/index.js +0 -15
  65. package/dist/LineChart/index.js.map +0 -1
  66. package/dist/PieChart/PieChart.d.ts +0 -14
  67. package/dist/PieChart/PieChart.d.ts.map +0 -1
  68. package/dist/PieChart/PieChart.js +0 -92
  69. package/dist/PieChart/PieChart.js.map +0 -1
  70. package/dist/PieChart/index.d.ts +0 -2
  71. package/dist/PieChart/index.d.ts.map +0 -1
  72. package/dist/PieChart/index.js +0 -15
  73. package/dist/PieChart/index.js.map +0 -1
  74. package/dist/StatChart/StatChart.d.ts +0 -21
  75. package/dist/StatChart/StatChart.d.ts.map +0 -1
  76. package/dist/StatChart/StatChart.js +0 -189
  77. package/dist/StatChart/StatChart.js.map +0 -1
  78. package/dist/StatChart/calculateFontSize.d.ts +0 -16
  79. package/dist/StatChart/calculateFontSize.d.ts.map +0 -1
  80. package/dist/StatChart/calculateFontSize.js +0 -49
  81. package/dist/StatChart/calculateFontSize.js.map +0 -1
  82. package/dist/StatChart/index.d.ts +0 -2
  83. package/dist/StatChart/index.d.ts.map +0 -1
  84. package/dist/StatChart/index.js +0 -15
  85. package/dist/StatChart/index.js.map +0 -1
  86. package/dist/StatChart/utils/formatStatChartValue.d.ts +0 -3
  87. package/dist/StatChart/utils/formatStatChartValue.d.ts.map +0 -1
  88. package/dist/StatChart/utils/formatStatChartValue.js +0 -26
  89. package/dist/StatChart/utils/formatStatChartValue.js.map +0 -1
  90. package/dist/StatusHistoryChart/StatusHistoryChart.d.ts +0 -27
  91. package/dist/StatusHistoryChart/StatusHistoryChart.d.ts.map +0 -1
  92. package/dist/StatusHistoryChart/StatusHistoryChart.js +0 -132
  93. package/dist/StatusHistoryChart/StatusHistoryChart.js.map +0 -1
  94. package/dist/StatusHistoryChart/StatusHistoryTooltip.d.ts +0 -13
  95. package/dist/StatusHistoryChart/StatusHistoryTooltip.d.ts.map +0 -1
  96. package/dist/StatusHistoryChart/StatusHistoryTooltip.js +0 -47
  97. package/dist/StatusHistoryChart/StatusHistoryTooltip.js.map +0 -1
  98. package/dist/StatusHistoryChart/get-formatted-axis-label.d.ts +0 -2
  99. package/dist/StatusHistoryChart/get-formatted-axis-label.d.ts.map +0 -1
  100. package/dist/StatusHistoryChart/get-formatted-axis-label.js +0 -41
  101. package/dist/StatusHistoryChart/get-formatted-axis-label.js.map +0 -1
  102. package/dist/StatusHistoryChart/index.d.ts +0 -3
  103. package/dist/StatusHistoryChart/index.d.ts.map +0 -1
  104. package/dist/StatusHistoryChart/index.js +0 -16
  105. package/dist/StatusHistoryChart/index.js.map +0 -1
  106. package/dist/StatusHistoryChart/utils/get-color.d.ts +0 -6
  107. package/dist/StatusHistoryChart/utils/get-color.d.ts.map +0 -1
  108. package/dist/StatusHistoryChart/utils/get-color.js +0 -100
  109. package/dist/StatusHistoryChart/utils/get-color.js.map +0 -1
  110. package/dist/StatusHistoryChart/utils/get-tooltip-position.d.ts +0 -3
  111. package/dist/StatusHistoryChart/utils/get-tooltip-position.d.ts.map +0 -1
  112. package/dist/StatusHistoryChart/utils/get-tooltip-position.js +0 -27
  113. package/dist/StatusHistoryChart/utils/get-tooltip-position.js.map +0 -1
  114. package/dist/TimeChart/TimeChart.d.ts +0 -24
  115. package/dist/TimeChart/TimeChart.d.ts.map +0 -1
  116. package/dist/TimeChart/TimeChart.js +0 -394
  117. package/dist/TimeChart/TimeChart.js.map +0 -1
  118. package/dist/TimeChart/index.d.ts +0 -2
  119. package/dist/TimeChart/index.d.ts.map +0 -1
  120. package/dist/TimeChart/index.js +0 -15
  121. package/dist/TimeChart/index.js.map +0 -1
  122. package/dist/TimeSeriesTooltip/LineChartTooltip.d.ts +0 -21
  123. package/dist/TimeSeriesTooltip/LineChartTooltip.d.ts.map +0 -1
  124. package/dist/TimeSeriesTooltip/LineChartTooltip.js +0 -101
  125. package/dist/TimeSeriesTooltip/LineChartTooltip.js.map +0 -1
  126. package/dist/cjs/BarChart/BarChart.js +0 -142
  127. package/dist/cjs/BarChart/index.js +0 -30
  128. package/dist/cjs/GaugeChart/GaugeChart.js +0 -227
  129. package/dist/cjs/GaugeChart/index.js +0 -30
  130. package/dist/cjs/LineChart/LineChart.js +0 -274
  131. package/dist/cjs/LineChart/index.js +0 -30
  132. package/dist/cjs/PieChart/PieChart.js +0 -100
  133. package/dist/cjs/PieChart/index.js +0 -30
  134. package/dist/cjs/StatChart/StatChart.js +0 -202
  135. package/dist/cjs/StatChart/calculateFontSize.js +0 -55
  136. package/dist/cjs/StatChart/index.js +0 -30
  137. package/dist/cjs/StatChart/utils/formatStatChartValue.js +0 -34
  138. package/dist/cjs/StatusHistoryChart/StatusHistoryChart.js +0 -140
  139. package/dist/cjs/StatusHistoryChart/StatusHistoryTooltip.js +0 -55
  140. package/dist/cjs/StatusHistoryChart/get-formatted-axis-label.js +0 -48
  141. package/dist/cjs/StatusHistoryChart/index.js +0 -31
  142. package/dist/cjs/StatusHistoryChart/utils/get-color.js +0 -125
  143. package/dist/cjs/StatusHistoryChart/utils/get-tooltip-position.js +0 -35
  144. package/dist/cjs/TimeChart/TimeChart.js +0 -407
  145. package/dist/cjs/TimeChart/index.js +0 -30
  146. package/dist/cjs/TimeSeriesTooltip/LineChartTooltip.js +0 -114
@@ -1,214 +0,0 @@
1
- // Copyright 2023 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
- import { jsx as _jsx } from "react/jsx-runtime";
14
- import { formatValue, useDeepMemo } from '@perses-dev/core';
15
- import { use } from 'echarts/core';
16
- import { GaugeChart as EChartsGaugeChart } from 'echarts/charts';
17
- import { GridComponent, TitleComponent, TooltipComponent } from 'echarts/components';
18
- import { CanvasRenderer } from 'echarts/renderers';
19
- import { useChartsTheme } from '../context';
20
- import { EChart } from '../EChart';
21
- use([
22
- EChartsGaugeChart,
23
- GridComponent,
24
- TitleComponent,
25
- TooltipComponent,
26
- CanvasRenderer
27
- ]);
28
- const PROGRESS_WIDTH = 16;
29
- // adjusts when to show pointer icon
30
- const GAUGE_SMALL_BREAKPOINT = 170;
31
- export function GaugeChart(props) {
32
- const { width, height, data, format, axisLine, max } = props;
33
- const chartsTheme = useChartsTheme();
34
- // useDeepMemo ensures value size util does not rerun everytime you hover on the chart
35
- const option = useDeepMemo(()=>{
36
- if (data.value === undefined) return chartsTheme.noDataOption;
37
- // adjusts fontSize depending on number of characters
38
- const valueSizeClamp = getResponsiveValueSize(data.value, format, width, height);
39
- return {
40
- title: {
41
- show: false
42
- },
43
- tooltip: {
44
- show: false
45
- },
46
- series: [
47
- {
48
- type: 'gauge',
49
- center: [
50
- '50%',
51
- '65%'
52
- ],
53
- radius: '86%',
54
- startAngle: 200,
55
- endAngle: -20,
56
- min: 0,
57
- max,
58
- silent: true,
59
- progress: {
60
- show: true,
61
- width: PROGRESS_WIDTH,
62
- itemStyle: {
63
- color: 'auto'
64
- }
65
- },
66
- pointer: {
67
- show: false
68
- },
69
- axisLine: {
70
- lineStyle: {
71
- color: [
72
- [
73
- 1,
74
- 'rgba(127,127,127,0.35)'
75
- ]
76
- ],
77
- width: PROGRESS_WIDTH
78
- }
79
- },
80
- axisTick: {
81
- show: false,
82
- distance: 0
83
- },
84
- splitLine: {
85
- show: false
86
- },
87
- axisLabel: {
88
- show: false,
89
- distance: -18,
90
- color: '#999',
91
- fontSize: 12
92
- },
93
- anchor: {
94
- show: false
95
- },
96
- title: {
97
- show: false
98
- },
99
- detail: {
100
- show: false
101
- },
102
- data: [
103
- {
104
- value: data.value
105
- }
106
- ]
107
- },
108
- {
109
- type: 'gauge',
110
- center: [
111
- '50%',
112
- '65%'
113
- ],
114
- radius: '100%',
115
- startAngle: 200,
116
- endAngle: -20,
117
- min: 0,
118
- max,
119
- pointer: {
120
- show: true,
121
- // pointer hidden for small panels, path taken from ex: https://echarts.apache.org/examples/en/editor.html?c=gauge-grade
122
- icon: width > GAUGE_SMALL_BREAKPOINT ? 'path://M12.8,0.7l12,40.1H0.7L12.8,0.7z' : 'none',
123
- length: 10,
124
- width: 5,
125
- offsetCenter: [
126
- 0,
127
- '-49%'
128
- ],
129
- itemStyle: {
130
- color: 'auto'
131
- }
132
- },
133
- axisLine,
134
- axisTick: {
135
- show: false
136
- },
137
- splitLine: {
138
- show: false
139
- },
140
- axisLabel: {
141
- show: false
142
- },
143
- detail: {
144
- show: true,
145
- width: '60%',
146
- borderRadius: 8,
147
- offsetCenter: [
148
- 0,
149
- '-9%'
150
- ],
151
- color: 'inherit',
152
- fontSize: valueSizeClamp,
153
- formatter: data.value === null ? // at this level because the `formatter` function argument is `NaN`
154
- // when the value is `null`, making it difficult to differentiate
155
- // `null` from a true `NaN` case.
156
- ()=>'null' : (value)=>{
157
- return formatValue(value, format);
158
- }
159
- },
160
- data: [
161
- {
162
- value: data.value,
163
- name: data.label,
164
- // TODO: new UX for series names, create separate React component or reuse ListLegendItem
165
- // https://echarts.apache.org/en/option.html#series-gauge.data.title
166
- title: {
167
- show: true,
168
- color: chartsTheme.echartsTheme.textStyle?.color ?? 'inherit',
169
- offsetCenter: [
170
- 0,
171
- '55%'
172
- ],
173
- overflow: 'truncate',
174
- fontSize: 12,
175
- width: width * 0.8
176
- }
177
- }
178
- ]
179
- }
180
- ]
181
- };
182
- }, [
183
- data,
184
- width,
185
- height,
186
- chartsTheme,
187
- format,
188
- axisLine,
189
- max
190
- ]);
191
- return /*#__PURE__*/ _jsx(EChart, {
192
- sx: {
193
- width: width,
194
- height: height,
195
- padding: `${chartsTheme.container.padding.default}px`
196
- },
197
- option: option,
198
- theme: chartsTheme.echartsTheme
199
- });
200
- }
201
- /**
202
- * Responsive font size depending on number of characters, clamp used
203
- * to ensure size stays within given range
204
- */ export function getResponsiveValueSize(value, format, width, height) {
205
- const MIN_SIZE = 3;
206
- const MAX_SIZE = 24;
207
- const SIZE_MULTIPLIER = 0.7;
208
- const formattedValue = typeof value === 'number' ? formatValue(value, format) : `${value}`;
209
- const valueCharacters = formattedValue.length ?? 2;
210
- const valueSize = Math.min(width, height) / valueCharacters * SIZE_MULTIPLIER;
211
- return `clamp(${MIN_SIZE}px, ${valueSize}px, ${MAX_SIZE}px)`;
212
- }
213
-
214
- //# sourceMappingURL=GaugeChart.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/GaugeChart/GaugeChart.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { formatValue, useDeepMemo, FormatOptions } from '@perses-dev/core';\nimport { use, EChartsCoreOption } from 'echarts/core';\nimport { GaugeChart as EChartsGaugeChart, GaugeSeriesOption } from 'echarts/charts';\nimport { GridComponent, TitleComponent, TooltipComponent } from 'echarts/components';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport { ReactElement } from 'react';\nimport { useChartsTheme } from '../context';\nimport { EChart } from '../EChart';\n\nuse([EChartsGaugeChart, GridComponent, TitleComponent, TooltipComponent, CanvasRenderer]);\n\nconst PROGRESS_WIDTH = 16;\n\n// adjusts when to show pointer icon\nconst GAUGE_SMALL_BREAKPOINT = 170;\n\nexport type GaugeChartValue = number | null | undefined;\n\nexport type GaugeSeries = {\n value: GaugeChartValue;\n label: string;\n};\n\nexport interface GaugeChartProps {\n width: number;\n height: number;\n data: GaugeSeries;\n format: FormatOptions;\n axisLine: GaugeSeriesOption['axisLine'];\n max?: number;\n}\n\nexport function GaugeChart(props: GaugeChartProps): ReactElement {\n const { width, height, data, format, axisLine, max } = props;\n const chartsTheme = useChartsTheme();\n\n // useDeepMemo ensures value size util does not rerun everytime you hover on the chart\n const option: EChartsCoreOption = useDeepMemo(() => {\n if (data.value === undefined) return chartsTheme.noDataOption;\n\n // adjusts fontSize depending on number of characters\n const valueSizeClamp = getResponsiveValueSize(data.value, format, width, height);\n\n return {\n title: {\n show: false,\n },\n tooltip: {\n show: false,\n },\n series: [\n {\n type: 'gauge',\n center: ['50%', '65%'],\n radius: '86%',\n startAngle: 200,\n endAngle: -20,\n min: 0,\n max,\n silent: true,\n progress: {\n show: true,\n width: PROGRESS_WIDTH,\n itemStyle: {\n color: 'auto',\n },\n },\n pointer: {\n show: false,\n },\n axisLine: {\n lineStyle: {\n color: [[1, 'rgba(127,127,127,0.35)']], // TODO (sjcobb): use future chart theme colors\n width: PROGRESS_WIDTH,\n },\n },\n axisTick: {\n show: false,\n distance: 0,\n },\n splitLine: {\n show: false,\n },\n axisLabel: {\n show: false,\n distance: -18,\n color: '#999',\n fontSize: 12,\n },\n anchor: {\n show: false,\n },\n title: {\n show: false,\n },\n detail: {\n show: false,\n },\n data: [\n {\n value: data.value,\n },\n ],\n },\n {\n type: 'gauge',\n center: ['50%', '65%'],\n radius: '100%',\n startAngle: 200,\n endAngle: -20,\n min: 0,\n max,\n pointer: {\n show: true,\n // pointer hidden for small panels, path taken from ex: https://echarts.apache.org/examples/en/editor.html?c=gauge-grade\n icon: width > GAUGE_SMALL_BREAKPOINT ? 'path://M12.8,0.7l12,40.1H0.7L12.8,0.7z' : 'none',\n length: 10,\n width: 5,\n offsetCenter: [0, '-49%'],\n itemStyle: {\n color: 'auto',\n },\n },\n axisLine,\n axisTick: {\n show: false,\n },\n splitLine: {\n show: false,\n },\n axisLabel: {\n show: false,\n },\n detail: {\n show: true,\n width: '60%',\n borderRadius: 8,\n offsetCenter: [0, '-9%'],\n color: 'inherit', // allows value color to match active threshold color\n fontSize: valueSizeClamp,\n formatter:\n data.value === null\n ? // We use a different function when we *know* the value is null\n // at this level because the `formatter` function argument is `NaN`\n // when the value is `null`, making it difficult to differentiate\n // `null` from a true `NaN` case.\n (): string => 'null'\n : (value: number): string | undefined => {\n return formatValue(value, format);\n },\n },\n data: [\n {\n value: data.value,\n name: data.label,\n // TODO: new UX for series names, create separate React component or reuse ListLegendItem\n // https://echarts.apache.org/en/option.html#series-gauge.data.title\n title: {\n show: true,\n color: chartsTheme.echartsTheme.textStyle?.color ?? 'inherit', // series name font color\n offsetCenter: [0, '55%'],\n overflow: 'truncate',\n fontSize: 12,\n width: width * 0.8,\n },\n },\n ],\n },\n ],\n };\n }, [data, width, height, chartsTheme, format, axisLine, max]);\n\n return (\n <EChart\n sx={{\n width: width,\n height: height,\n padding: `${chartsTheme.container.padding.default}px`,\n }}\n option={option}\n theme={chartsTheme.echartsTheme}\n />\n );\n}\n\n/**\n * Responsive font size depending on number of characters, clamp used\n * to ensure size stays within given range\n */\nexport function getResponsiveValueSize(\n value: number | null,\n format: FormatOptions,\n width: number,\n height: number\n): string {\n const MIN_SIZE = 3;\n const MAX_SIZE = 24;\n const SIZE_MULTIPLIER = 0.7;\n const formattedValue = typeof value === 'number' ? formatValue(value, format) : `${value}`;\n const valueCharacters = formattedValue.length ?? 2;\n const valueSize = (Math.min(width, height) / valueCharacters) * SIZE_MULTIPLIER;\n return `clamp(${MIN_SIZE}px, ${valueSize}px, ${MAX_SIZE}px)`;\n}\n"],"names":["formatValue","useDeepMemo","use","GaugeChart","EChartsGaugeChart","GridComponent","TitleComponent","TooltipComponent","CanvasRenderer","useChartsTheme","EChart","PROGRESS_WIDTH","GAUGE_SMALL_BREAKPOINT","props","width","height","data","format","axisLine","max","chartsTheme","option","value","undefined","noDataOption","valueSizeClamp","getResponsiveValueSize","title","show","tooltip","series","type","center","radius","startAngle","endAngle","min","silent","progress","itemStyle","color","pointer","lineStyle","axisTick","distance","splitLine","axisLabel","fontSize","anchor","detail","icon","length","offsetCenter","borderRadius","formatter","name","label","echartsTheme","textStyle","overflow","sx","padding","container","default","theme","MIN_SIZE","MAX_SIZE","SIZE_MULTIPLIER","formattedValue","valueCharacters","valueSize","Math"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,WAAW,EAAEC,WAAW,QAAuB,mBAAmB;AAC3E,SAASC,GAAG,QAA2B,eAAe;AACtD,SAASC,cAAcC,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AAG;QAACE;QAAMF;QAAOC;QAAQK;QAAaH;QAAQC;QAAUC;KAAI;IAE5D,qBACE,KAACT;QACCkD,IAAI;YACF9C,OAAOA;YACPC,QAAQA;YACR8C,SAAS,GAAGzC,YAAY0C,SAAS,CAACD,OAAO,CAACE,OAAO,CAAC,EAAE,CAAC;QACvD;QACA1C,QAAQA;QACR2C,OAAO5C,YAAYqC,YAAY;;AAGrC;AAEA;;;CAGC,GACD,OAAO,SAAS/B,uBACdJ,KAAoB,EACpBL,MAAqB,EACrBH,KAAa,EACbC,MAAc;IAEd,MAAMkD,WAAW;IACjB,MAAMC,WAAW;IACjB,MAAMC,kBAAkB;IACxB,MAAMC,iBAAiB,OAAO9C,UAAU,WAAWtB,YAAYsB,OAAOL,UAAU,GAAGK,OAAO;IAC1F,MAAM+C,kBAAkBD,eAAejB,MAAM,IAAI;IACjD,MAAMmB,YAAY,AAACC,KAAKnC,GAAG,CAACtB,OAAOC,UAAUsD,kBAAmBF;IAChE,OAAO,CAAC,MAAM,EAAEF,SAAS,IAAI,EAAEK,UAAU,IAAI,EAAEJ,SAAS,GAAG,CAAC;AAC9D"}
@@ -1,2 +0,0 @@
1
- export * from './GaugeChart';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/GaugeChart/index.ts"],"names":[],"mappings":"AAaA,cAAc,cAAc,CAAC"}
@@ -1,15 +0,0 @@
1
- // Copyright 2023 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
- export * from './GaugeChart';
14
-
15
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/GaugeChart/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './GaugeChart';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,eAAe"}
@@ -1,22 +0,0 @@
1
- import { MouseEvent } from 'react';
2
- import { FormatOptions } from '@perses-dev/core';
3
- import type { EChartsCoreOption, GridComponentOption, LegendComponentOption, YAXisComponentOption } from 'echarts';
4
- import { EChartsDataFormat, ChartInstance } from '../model';
5
- import { TooltipConfig } from '../TimeSeriesTooltip';
6
- import { ZoomEventData } from '../utils';
7
- export interface LineChartProps {
8
- height: number;
9
- data: EChartsDataFormat;
10
- yAxis?: YAXisComponentOption;
11
- format?: FormatOptions;
12
- grid?: GridComponentOption;
13
- legend?: LegendComponentOption;
14
- tooltipConfig?: TooltipConfig;
15
- noDataVariant?: 'chart' | 'message';
16
- syncGroup?: string;
17
- onDataZoom?: (e: ZoomEventData) => void;
18
- onDoubleClick?: (e: MouseEvent) => void;
19
- __experimentalEChartsOptionsOverride?: (options: EChartsCoreOption) => EChartsCoreOption;
20
- }
21
- export declare const LineChart: import("react").ForwardRefExoticComponent<LineChartProps & import("react").RefAttributes<ChartInstance>>;
22
- //# sourceMappingURL=LineChart.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LineChart.d.ts","sourceRoot":"","sources":["../../src/LineChart/LineChart.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAc,UAAU,EAAkD,MAAM,OAAO,CAAC;AAC/F,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,KAAK,EACV,iBAAiB,EACjB,mBAAmB,EAEnB,qBAAqB,EACrB,oBAAoB,EAErB,MAAM,SAAS,CAAC;AAgBjB,OAAO,EAAE,iBAAiB,EAA0B,aAAa,EAAE,MAAM,UAAU,CAAC;AAEpF,OAAO,EAAuC,aAAa,EAA0B,MAAM,sBAAsB,CAAC;AAClH,OAAO,EAOL,aAAa,EACd,MAAM,UAAU,CAAC;AAgBlB,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,iBAAiB,CAAC;IACxB,KAAK,CAAC,EAAE,oBAAoB,CAAC;IAC7B,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAC3B,MAAM,CAAC,EAAE,qBAAqB,CAAC;IAC/B,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,aAAa,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;IACxC,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;IACxC,oCAAoC,CAAC,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,iBAAiB,CAAC;CAC1F;AAED,eAAO,MAAM,SAAS,0GAmPpB,CAAC"}
@@ -1,266 +0,0 @@
1
- // Copyright 2023 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
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
- import { forwardRef, useImperativeHandle, useMemo, useRef, useState } from 'react';
15
- import { Box } from '@mui/material';
16
- import { use } from 'echarts/core';
17
- import { LineChart as EChartsLineChart } from 'echarts/charts';
18
- import { GridComponent, DataZoomComponent, MarkAreaComponent, MarkLineComponent, MarkPointComponent, TitleComponent, ToolboxComponent, TooltipComponent, LegendComponent } from 'echarts/components';
19
- import { CanvasRenderer } from 'echarts/renderers';
20
- import { EChart } from '../EChart';
21
- import { useChartsTheme, useTimeZone } from '../context';
22
- import { LineChartTooltip, DEFAULT_TOOLTIP_CONFIG } from '../TimeSeriesTooltip';
23
- import { clearHighlightedSeries, enableDataZoom, getDateRange, getFormattedDate, getFormattedAxis, restoreChart } from '../utils';
24
- use([
25
- EChartsLineChart,
26
- GridComponent,
27
- DataZoomComponent,
28
- MarkAreaComponent,
29
- MarkLineComponent,
30
- MarkPointComponent,
31
- TitleComponent,
32
- ToolboxComponent,
33
- TooltipComponent,
34
- LegendComponent,
35
- CanvasRenderer
36
- ]);
37
- export const LineChart = /*#__PURE__*/ forwardRef(function LineChart({ height, data, yAxis, format, grid, legend, tooltipConfig = DEFAULT_TOOLTIP_CONFIG, noDataVariant = 'message', syncGroup, onDataZoom, onDoubleClick, __experimentalEChartsOptionsOverride }, ref) {
38
- const chartsTheme = useChartsTheme();
39
- const chartRef = useRef();
40
- const [showTooltip, setShowTooltip] = useState(true);
41
- const [tooltipPinnedCoords, setTooltipPinnedCoords] = useState(null);
42
- const { timeZone } = useTimeZone();
43
- const [isDragging, setIsDragging] = useState(false);
44
- const [startX, setStartX] = useState(0);
45
- useImperativeHandle(ref, ()=>{
46
- return {
47
- highlightSeries ({ id }) {
48
- if (!chartRef.current) {
49
- // when chart undef, do not highlight series when hovering over legend
50
- return;
51
- }
52
- chartRef.current.dispatchAction({
53
- type: 'highlight',
54
- seriesId: id
55
- });
56
- },
57
- clearHighlightedSeries: ()=>{
58
- if (!chartRef.current) {
59
- // when chart undef, do not clear highlight series
60
- return;
61
- }
62
- clearHighlightedSeries(chartRef.current);
63
- }
64
- };
65
- }, []);
66
- const handleEvents = useMemo(()=>{
67
- return {
68
- datazoom: (params)=>{
69
- if (onDataZoom === undefined) {
70
- setTimeout(()=>{
71
- // workaround so unpin happens after click event
72
- setTooltipPinnedCoords(null);
73
- }, 10);
74
- }
75
- if (onDataZoom === undefined || params.batch[0] === undefined) return;
76
- const startIndex = params.batch[0].startValue ?? 0;
77
- const endIndex = params.batch[0].endValue ?? data.xAxis.length - 1;
78
- const xAxisStartValue = data.xAxis[startIndex];
79
- const xAxisEndValue = data.xAxis[endIndex];
80
- if (xAxisStartValue !== undefined && xAxisEndValue !== undefined) {
81
- const zoomEvent = {
82
- start: xAxisStartValue,
83
- end: xAxisEndValue,
84
- startIndex,
85
- endIndex
86
- };
87
- onDataZoom(zoomEvent);
88
- }
89
- }
90
- };
91
- }, [
92
- data,
93
- onDataZoom,
94
- setTooltipPinnedCoords
95
- ]);
96
- if (chartRef.current !== undefined) {
97
- enableDataZoom(chartRef.current);
98
- }
99
- const { noDataOption } = chartsTheme;
100
- const option = useMemo(()=>{
101
- if (data.timeSeries === undefined) return {};
102
- // The "chart" `noDataVariant` is only used when the `timeSeries` is an
103
- // empty array because a `null` value will throw an error.
104
- if (data.timeSeries === null || data.timeSeries.length === 0 && noDataVariant === 'message') return noDataOption;
105
- const rangeMs = data.rangeMs ?? getDateRange(data.xAxis);
106
- const option = {
107
- series: data.timeSeries,
108
- xAxis: {
109
- type: 'category',
110
- data: data.xAxis,
111
- max: data.xAxisMax,
112
- axisLabel: {
113
- formatter: (value)=>{
114
- return getFormattedDate(value, rangeMs, timeZone);
115
- }
116
- }
117
- },
118
- yAxis: getFormattedAxis(yAxis, format),
119
- animation: false,
120
- tooltip: {
121
- show: true,
122
- trigger: 'axis',
123
- showContent: false
124
- },
125
- // https://echarts.apache.org/en/option.html#axisPointer
126
- axisPointer: {
127
- type: 'line',
128
- z: 0,
129
- triggerEmphasis: false,
130
- triggerTooltip: false,
131
- snap: true
132
- },
133
- toolbox: {
134
- feature: {
135
- dataZoom: {
136
- icon: null,
137
- yAxisIndex: 'none'
138
- }
139
- }
140
- },
141
- grid,
142
- legend
143
- };
144
- if (__experimentalEChartsOptionsOverride) {
145
- return __experimentalEChartsOptionsOverride(option);
146
- }
147
- return option;
148
- }, [
149
- data,
150
- yAxis,
151
- format,
152
- grid,
153
- legend,
154
- noDataOption,
155
- timeZone,
156
- __experimentalEChartsOptionsOverride,
157
- noDataVariant
158
- ]);
159
- return /*#__PURE__*/ _jsxs(Box, {
160
- style: {
161
- height
162
- },
163
- onClick: (e)=>{
164
- // Pin and unpin when clicking on chart canvas but not tooltip text.
165
- if (tooltipConfig.enablePinning && e.target instanceof HTMLCanvasElement) {
166
- setTooltipPinnedCoords((current)=>{
167
- if (current === null) {
168
- return {
169
- page: {
170
- x: e.pageX,
171
- y: e.pageY
172
- },
173
- client: {
174
- x: e.clientX,
175
- y: e.clientY
176
- },
177
- plotCanvas: {
178
- x: e.nativeEvent.offsetX,
179
- y: e.nativeEvent.offsetY
180
- },
181
- target: e.target
182
- };
183
- } else {
184
- return null;
185
- }
186
- });
187
- }
188
- },
189
- onMouseDown: (e)=>{
190
- const { clientX } = e;
191
- setIsDragging(true);
192
- setStartX(clientX);
193
- },
194
- onMouseMove: (e)=>{
195
- // Allow clicking inside tooltip to copy labels.
196
- if (!(e.target instanceof HTMLCanvasElement)) {
197
- return;
198
- }
199
- const { clientX } = e;
200
- if (isDragging) {
201
- const deltaX = clientX - startX;
202
- if (deltaX > 0) {
203
- // Hide tooltip when user drags to zoom.
204
- setShowTooltip(false);
205
- }
206
- }
207
- },
208
- onMouseUp: ()=>{
209
- setIsDragging(false);
210
- setStartX(0);
211
- setShowTooltip(true);
212
- },
213
- onMouseLeave: ()=>{
214
- if (tooltipPinnedCoords === null) {
215
- setShowTooltip(false);
216
- }
217
- if (chartRef.current !== undefined) {
218
- clearHighlightedSeries(chartRef.current);
219
- }
220
- },
221
- onMouseEnter: ()=>{
222
- setShowTooltip(true);
223
- if (chartRef.current !== undefined) {
224
- enableDataZoom(chartRef.current);
225
- }
226
- },
227
- onDoubleClick: (e)=>{
228
- setTooltipPinnedCoords(null);
229
- // either dispatch ECharts restore action to return to orig state or allow consumer to define behavior
230
- if (onDoubleClick === undefined) {
231
- if (chartRef.current !== undefined) {
232
- restoreChart(chartRef.current);
233
- }
234
- } else {
235
- onDoubleClick(e);
236
- }
237
- },
238
- children: [
239
- showTooltip === true && option.tooltip?.showContent === false && tooltipConfig.hidden !== true && /*#__PURE__*/ _jsx(LineChartTooltip, {
240
- chartRef: chartRef,
241
- chartData: data,
242
- wrapLabels: tooltipConfig.wrapLabels,
243
- enablePinning: tooltipConfig.enablePinning,
244
- pinnedPos: tooltipPinnedCoords,
245
- format: format,
246
- onUnpinClick: ()=>{
247
- setTooltipPinnedCoords(null);
248
- },
249
- containerId: chartsTheme.tooltipPortalContainerId
250
- }),
251
- /*#__PURE__*/ _jsx(EChart, {
252
- sx: {
253
- width: '100%',
254
- height: '100%'
255
- },
256
- option: option,
257
- theme: chartsTheme.echartsTheme,
258
- onEvents: handleEvents,
259
- _instance: chartRef,
260
- syncGroup: syncGroup
261
- })
262
- ]
263
- });
264
- });
265
-
266
- //# sourceMappingURL=LineChart.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/LineChart/LineChart.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { forwardRef, MouseEvent, useImperativeHandle, useMemo, useRef, useState } from 'react';\nimport { FormatOptions } from '@perses-dev/core';\nimport { Box } from '@mui/material';\nimport type {\n EChartsCoreOption,\n GridComponentOption,\n LineSeriesOption,\n LegendComponentOption,\n YAXisComponentOption,\n TooltipComponentOption,\n} from 'echarts';\nimport { ECharts as EChartsInstance, use } from 'echarts/core';\nimport { LineChart as EChartsLineChart } from 'echarts/charts';\nimport {\n GridComponent,\n DataZoomComponent,\n MarkAreaComponent,\n MarkLineComponent,\n MarkPointComponent,\n TitleComponent,\n ToolboxComponent,\n TooltipComponent,\n LegendComponent,\n} from 'echarts/components';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport { EChart, OnEventsType } from '../EChart';\nimport { EChartsDataFormat, ChartInstanceFocusOpts, ChartInstance } from '../model';\nimport { useChartsTheme, useTimeZone } from '../context';\nimport { CursorCoordinates, LineChartTooltip, TooltipConfig, DEFAULT_TOOLTIP_CONFIG } from '../TimeSeriesTooltip';\nimport {\n clearHighlightedSeries,\n enableDataZoom,\n getDateRange,\n getFormattedDate,\n getFormattedAxis,\n restoreChart,\n ZoomEventData,\n} from '../utils';\n\nuse([\n EChartsLineChart,\n GridComponent,\n DataZoomComponent,\n MarkAreaComponent,\n MarkLineComponent,\n MarkPointComponent,\n TitleComponent,\n ToolboxComponent,\n TooltipComponent,\n LegendComponent,\n CanvasRenderer,\n]);\n\nexport interface LineChartProps {\n height: number;\n data: EChartsDataFormat;\n yAxis?: YAXisComponentOption;\n format?: FormatOptions;\n grid?: GridComponentOption;\n legend?: LegendComponentOption;\n tooltipConfig?: TooltipConfig;\n noDataVariant?: 'chart' | 'message';\n syncGroup?: string;\n onDataZoom?: (e: ZoomEventData) => void;\n onDoubleClick?: (e: MouseEvent) => void;\n __experimentalEChartsOptionsOverride?: (options: EChartsCoreOption) => EChartsCoreOption;\n}\n\nexport const LineChart = forwardRef<ChartInstance, LineChartProps>(function LineChart(\n {\n height,\n data,\n yAxis,\n format,\n grid,\n legend,\n tooltipConfig = DEFAULT_TOOLTIP_CONFIG,\n noDataVariant = 'message',\n syncGroup,\n onDataZoom,\n onDoubleClick,\n __experimentalEChartsOptionsOverride,\n },\n ref\n) {\n const chartsTheme = useChartsTheme();\n const chartRef = useRef<EChartsInstance>();\n const [showTooltip, setShowTooltip] = useState<boolean>(true);\n const [tooltipPinnedCoords, setTooltipPinnedCoords] = useState<CursorCoordinates | null>(null);\n const { timeZone } = useTimeZone();\n\n const [isDragging, setIsDragging] = useState(false);\n const [startX, setStartX] = useState(0);\n\n useImperativeHandle(ref, () => {\n return {\n highlightSeries({ id }: ChartInstanceFocusOpts): void {\n if (!chartRef.current) {\n // when chart undef, do not highlight series when hovering over legend\n return;\n }\n\n chartRef.current.dispatchAction({ type: 'highlight', seriesId: id });\n },\n clearHighlightedSeries: (): void => {\n if (!chartRef.current) {\n // when chart undef, do not clear highlight series\n return;\n }\n clearHighlightedSeries(chartRef.current);\n },\n };\n }, []);\n\n const handleEvents: OnEventsType<LineSeriesOption['data'] | unknown> = useMemo(() => {\n return {\n datazoom: (params): void => {\n if (onDataZoom === undefined) {\n setTimeout(() => {\n // workaround so unpin happens after click event\n setTooltipPinnedCoords(null);\n }, 10);\n }\n if (onDataZoom === undefined || params.batch[0] === undefined) return;\n const startIndex = params.batch[0].startValue ?? 0;\n const endIndex = params.batch[0].endValue ?? data.xAxis.length - 1;\n const xAxisStartValue = data.xAxis[startIndex];\n const xAxisEndValue = data.xAxis[endIndex];\n\n if (xAxisStartValue !== undefined && xAxisEndValue !== undefined) {\n const zoomEvent: ZoomEventData = {\n start: xAxisStartValue,\n end: xAxisEndValue,\n startIndex,\n endIndex,\n };\n onDataZoom(zoomEvent);\n }\n },\n };\n }, [data, onDataZoom, setTooltipPinnedCoords]);\n\n if (chartRef.current !== undefined) {\n enableDataZoom(chartRef.current);\n }\n\n const { noDataOption } = chartsTheme;\n\n const option: EChartsCoreOption = useMemo(() => {\n if (data.timeSeries === undefined) return {};\n\n // The \"chart\" `noDataVariant` is only used when the `timeSeries` is an\n // empty array because a `null` value will throw an error.\n if (data.timeSeries === null || (data.timeSeries.length === 0 && noDataVariant === 'message')) return noDataOption;\n\n const rangeMs = data.rangeMs ?? getDateRange(data.xAxis);\n\n const option: EChartsCoreOption = {\n series: data.timeSeries,\n xAxis: {\n type: 'category',\n data: data.xAxis,\n max: data.xAxisMax,\n axisLabel: {\n formatter: (value: number) => {\n return getFormattedDate(value, rangeMs, timeZone);\n },\n },\n },\n yAxis: getFormattedAxis(yAxis, format),\n animation: false,\n tooltip: {\n show: true,\n trigger: 'axis',\n showContent: false, // echarts tooltip content hidden since we use custom tooltip instead\n },\n // https://echarts.apache.org/en/option.html#axisPointer\n axisPointer: {\n type: 'line',\n z: 0, // ensure point symbol shows on top of dashed line\n triggerEmphasis: false, // https://github.com/apache/echarts/issues/18495\n triggerTooltip: false,\n snap: true,\n },\n toolbox: {\n feature: {\n dataZoom: {\n icon: null, // https://stackoverflow.com/a/67684076/17575201\n yAxisIndex: 'none',\n },\n },\n },\n grid,\n legend,\n };\n\n if (__experimentalEChartsOptionsOverride) {\n return __experimentalEChartsOptionsOverride(option);\n }\n return option;\n }, [data, yAxis, format, grid, legend, noDataOption, timeZone, __experimentalEChartsOptionsOverride, noDataVariant]);\n\n return (\n <Box\n style={{ height }}\n onClick={(e) => {\n // Pin and unpin when clicking on chart canvas but not tooltip text.\n if (tooltipConfig.enablePinning && e.target instanceof HTMLCanvasElement) {\n setTooltipPinnedCoords((current) => {\n if (current === null) {\n return {\n page: {\n x: e.pageX,\n y: e.pageY,\n },\n client: {\n x: e.clientX,\n y: e.clientY,\n },\n plotCanvas: {\n x: e.nativeEvent.offsetX,\n y: e.nativeEvent.offsetY,\n },\n target: e.target,\n };\n } else {\n return null;\n }\n });\n }\n }}\n onMouseDown={(e) => {\n const { clientX } = e;\n setIsDragging(true);\n setStartX(clientX);\n }}\n onMouseMove={(e) => {\n // Allow clicking inside tooltip to copy labels.\n if (!(e.target instanceof HTMLCanvasElement)) {\n return;\n }\n const { clientX } = e;\n if (isDragging) {\n const deltaX = clientX - startX;\n if (deltaX > 0) {\n // Hide tooltip when user drags to zoom.\n setShowTooltip(false);\n }\n }\n }}\n onMouseUp={() => {\n setIsDragging(false);\n setStartX(0);\n setShowTooltip(true);\n }}\n onMouseLeave={() => {\n if (tooltipPinnedCoords === null) {\n setShowTooltip(false);\n }\n if (chartRef.current !== undefined) {\n clearHighlightedSeries(chartRef.current);\n }\n }}\n onMouseEnter={() => {\n setShowTooltip(true);\n if (chartRef.current !== undefined) {\n enableDataZoom(chartRef.current);\n }\n }}\n onDoubleClick={(e) => {\n setTooltipPinnedCoords(null);\n // either dispatch ECharts restore action to return to orig state or allow consumer to define behavior\n if (onDoubleClick === undefined) {\n if (chartRef.current !== undefined) {\n restoreChart(chartRef.current);\n }\n } else {\n onDoubleClick(e);\n }\n }}\n >\n {/* Allows overrides prop to hide custom tooltip and use the ECharts option.tooltip instead */}\n {showTooltip === true &&\n (option.tooltip as TooltipComponentOption)?.showContent === false &&\n tooltipConfig.hidden !== true && (\n <LineChartTooltip\n chartRef={chartRef}\n chartData={data}\n wrapLabels={tooltipConfig.wrapLabels}\n enablePinning={tooltipConfig.enablePinning}\n pinnedPos={tooltipPinnedCoords}\n format={format}\n onUnpinClick={() => {\n setTooltipPinnedCoords(null);\n }}\n containerId={chartsTheme.tooltipPortalContainerId}\n />\n )}\n <EChart\n sx={{\n width: '100%',\n height: '100%',\n }}\n option={option}\n theme={chartsTheme.echartsTheme}\n onEvents={handleEvents}\n _instance={chartRef}\n syncGroup={syncGroup}\n />\n </Box>\n );\n});\n"],"names":["forwardRef","useImperativeHandle","useMemo","useRef","useState","Box","use","LineChart","EChartsLineChart","GridComponent","DataZoomComponent","MarkAreaComponent","MarkLineComponent","MarkPointComponent","TitleComponent","ToolboxComponent","TooltipComponent","LegendComponent","CanvasRenderer","EChart","useChartsTheme","useTimeZone","LineChartTooltip","DEFAULT_TOOLTIP_CONFIG","clearHighlightedSeries","enableDataZoom","getDateRange","getFormattedDate","getFormattedAxis","restoreChart","height","data","yAxis","format","grid","legend","tooltipConfig","noDataVariant","syncGroup","onDataZoom","onDoubleClick","__experimentalEChartsOptionsOverride","ref","chartsTheme","chartRef","showTooltip","setShowTooltip","tooltipPinnedCoords","setTooltipPinnedCoords","timeZone","isDragging","setIsDragging","startX","setStartX","highlightSeries","id","current","dispatchAction","type","seriesId","handleEvents","datazoom","params","undefined","setTimeout","batch","startIndex","startValue","endIndex","endValue","xAxis","length","xAxisStartValue","xAxisEndValue","zoomEvent","start","end","noDataOption","option","timeSeries","rangeMs","series","max","xAxisMax","axisLabel","formatter","value","animation","tooltip","show","trigger","showContent","axisPointer","z","triggerEmphasis","triggerTooltip","snap","toolbox","feature","dataZoom","icon","yAxisIndex","style","onClick","e","enablePinning","target","HTMLCanvasElement","page","x","pageX","y","pageY","client","clientX","clientY","plotCanvas","nativeEvent","offsetX","offsetY","onMouseDown","onMouseMove","deltaX","onMouseUp","onMouseLeave","onMouseEnter","hidden","chartData","wrapLabels","pinnedPos","onUnpinClick","containerId","tooltipPortalContainerId","sx","width","theme","echartsTheme","onEvents","_instance"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,UAAU,EAAcC,mBAAmB,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAE/F,SAASC,GAAG,QAAQ,gBAAgB;AASpC,SAAqCC,GAAG,QAAQ,eAAe;AAC/D,SAASC,aAAaC,gBAAgB,QAAQ,iBAAiB;AAC/D,SACEC,aAAa,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;oBACPxG,QAAQ;gBACV;gBACAgD,QAAQA;gBACRyD,OAAO5F,YAAY6F,YAAY;gBAC/BC,UAAU7E;gBACV8E,WAAW9F;gBACXN,WAAWA;;;;AAInB,GAAG"}
@@ -1,2 +0,0 @@
1
- export * from './LineChart';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/LineChart/index.ts"],"names":[],"mappings":"AAaA,cAAc,aAAa,CAAC"}
@@ -1,15 +0,0 @@
1
- // Copyright 2023 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
- export * from './LineChart';
14
-
15
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/LineChart/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './LineChart';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,cAAc"}
@@ -1,14 +0,0 @@
1
- import { LegendComponentOption } from 'echarts/components';
2
- import { ReactElement } from 'react';
3
- export interface PieChartData {
4
- name: string;
5
- value: number | null;
6
- }
7
- export interface PieChartProps {
8
- width: number;
9
- height: number;
10
- data: PieChartData[] | null;
11
- legend?: LegendComponentOption;
12
- }
13
- export declare function PieChart(props: PieChartProps): ReactElement;
14
- //# sourceMappingURL=PieChart.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PieChart.d.ts","sourceRoot":"","sources":["../../src/PieChart/PieChart.tsx"],"names":[],"mappings":"AAeA,OAAO,EAKL,qBAAqB,EACtB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAQrC,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC;IAC5B,MAAM,CAAC,EAAE,qBAAqB,CAAC;CAChC;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,YAAY,CA2D3D"}