@perses-dev/components 0.15.0 → 0.17.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 (138) hide show
  1. package/dist/LineChart/LineChart.d.ts +3 -2
  2. package/dist/LineChart/LineChart.d.ts.map +1 -1
  3. package/dist/LineChart/LineChart.js +6 -16
  4. package/dist/LineChart/LineChart.js.map +1 -1
  5. package/dist/LineChart/utils.d.ts +18 -0
  6. package/dist/LineChart/utils.d.ts.map +1 -1
  7. package/dist/LineChart/utils.js +35 -9
  8. package/dist/LineChart/utils.js.map +1 -1
  9. package/dist/OptionsEditorLayout/OptionsEditorColumn.d.ts +13 -0
  10. package/dist/OptionsEditorLayout/OptionsEditorColumn.d.ts.map +1 -0
  11. package/dist/OptionsEditorLayout/OptionsEditorColumn.js +28 -0
  12. package/dist/OptionsEditorLayout/OptionsEditorColumn.js.map +1 -0
  13. package/dist/OptionsEditorLayout/OptionsEditorControl.d.ts +5 -0
  14. package/dist/OptionsEditorLayout/OptionsEditorControl.d.ts.map +1 -0
  15. package/dist/OptionsEditorLayout/OptionsEditorControl.js +50 -0
  16. package/dist/OptionsEditorLayout/OptionsEditorControl.js.map +1 -0
  17. package/dist/OptionsEditorLayout/OptionsEditorGrid.d.ts +13 -0
  18. package/dist/OptionsEditorLayout/OptionsEditorGrid.d.ts.map +1 -0
  19. package/dist/OptionsEditorLayout/OptionsEditorGrid.js +26 -0
  20. package/dist/OptionsEditorLayout/OptionsEditorGrid.js.map +1 -0
  21. package/dist/OptionsEditorLayout/OptionsEditorGroup.d.ts +13 -0
  22. package/dist/OptionsEditorLayout/OptionsEditorGroup.d.ts.map +1 -0
  23. package/dist/OptionsEditorLayout/OptionsEditorGroup.js +36 -0
  24. package/dist/OptionsEditorLayout/OptionsEditorGroup.js.map +1 -0
  25. package/dist/OptionsEditorLayout/index.d.ts +5 -0
  26. package/dist/OptionsEditorLayout/index.d.ts.map +1 -0
  27. package/dist/OptionsEditorLayout/index.js +18 -0
  28. package/dist/OptionsEditorLayout/index.js.map +1 -0
  29. package/dist/Tooltip/SeriesInfo.d.ts +1 -0
  30. package/dist/Tooltip/SeriesInfo.d.ts.map +1 -1
  31. package/dist/Tooltip/SeriesInfo.js +3 -3
  32. package/dist/Tooltip/SeriesInfo.js.map +1 -1
  33. package/dist/Tooltip/Tooltip.d.ts +2 -1
  34. package/dist/Tooltip/Tooltip.d.ts.map +1 -1
  35. package/dist/Tooltip/Tooltip.js +2 -2
  36. package/dist/Tooltip/Tooltip.js.map +1 -1
  37. package/dist/Tooltip/TooltipContent.d.ts.map +1 -1
  38. package/dist/Tooltip/TooltipContent.js +2 -1
  39. package/dist/Tooltip/TooltipContent.js.map +1 -1
  40. package/dist/Tooltip/focused-series.d.ts +4 -3
  41. package/dist/Tooltip/focused-series.d.ts.map +1 -1
  42. package/dist/Tooltip/focused-series.js +6 -3
  43. package/dist/Tooltip/focused-series.js.map +1 -1
  44. package/dist/Tooltip/focused-series.test.js +20 -2
  45. package/dist/Tooltip/focused-series.test.js.map +1 -1
  46. package/dist/UnitSelector/UnitSelector.d.ts +8 -0
  47. package/dist/UnitSelector/UnitSelector.d.ts.map +1 -0
  48. package/dist/UnitSelector/UnitSelector.js +112 -0
  49. package/dist/UnitSelector/UnitSelector.js.map +1 -0
  50. package/dist/UnitSelector/UnitSelector.test.d.ts +2 -0
  51. package/dist/UnitSelector/UnitSelector.test.d.ts.map +1 -0
  52. package/dist/UnitSelector/UnitSelector.test.js +211 -0
  53. package/dist/UnitSelector/UnitSelector.test.js.map +1 -0
  54. package/dist/UnitSelector/index.d.ts +2 -0
  55. package/dist/UnitSelector/index.d.ts.map +1 -0
  56. package/dist/UnitSelector/index.js +15 -0
  57. package/dist/UnitSelector/index.js.map +1 -0
  58. package/dist/YAxisLabel.d.ts +8 -0
  59. package/dist/YAxisLabel.d.ts.map +1 -0
  60. package/dist/YAxisLabel.js +39 -0
  61. package/dist/YAxisLabel.js.map +1 -0
  62. package/dist/cjs/LineChart/LineChart.js +5 -15
  63. package/dist/cjs/LineChart/utils.js +23 -1
  64. package/dist/cjs/OptionsEditorLayout/OptionsEditorColumn.js +32 -0
  65. package/dist/cjs/OptionsEditorLayout/OptionsEditorControl.js +61 -0
  66. package/dist/cjs/OptionsEditorLayout/OptionsEditorGrid.js +29 -0
  67. package/dist/cjs/OptionsEditorLayout/OptionsEditorGroup.js +40 -0
  68. package/dist/cjs/OptionsEditorLayout/index.js +31 -0
  69. package/dist/cjs/Tooltip/SeriesInfo.js +3 -3
  70. package/dist/cjs/Tooltip/Tooltip.js +2 -2
  71. package/dist/cjs/Tooltip/TooltipContent.js +2 -1
  72. package/dist/cjs/Tooltip/focused-series.js +6 -3
  73. package/dist/cjs/Tooltip/focused-series.test.js +20 -2
  74. package/dist/cjs/UnitSelector/UnitSelector.js +118 -0
  75. package/dist/cjs/UnitSelector/UnitSelector.test.js +218 -0
  76. package/dist/cjs/UnitSelector/index.js +28 -0
  77. package/dist/cjs/YAxisLabel.js +45 -0
  78. package/dist/cjs/index.js +5 -2
  79. package/dist/cjs/model/units/bytes.js +60 -0
  80. package/dist/cjs/model/units/constants.js +23 -0
  81. package/dist/cjs/model/units/decimal.js +67 -0
  82. package/dist/cjs/model/units/index.js +30 -0
  83. package/dist/cjs/model/units/percent.js +64 -0
  84. package/dist/cjs/model/units/time.js +138 -0
  85. package/dist/cjs/model/units/types.js +28 -0
  86. package/dist/cjs/model/units/units.js +104 -0
  87. package/dist/cjs/utils/component-ids.js +31 -0
  88. package/dist/cjs/utils/index.js +1 -0
  89. package/dist/index.d.ts +5 -2
  90. package/dist/index.d.ts.map +1 -1
  91. package/dist/index.js +5 -2
  92. package/dist/index.js.map +1 -1
  93. package/dist/model/units/bytes.d.ts +12 -0
  94. package/dist/model/units/bytes.d.ts.map +1 -0
  95. package/dist/model/units/bytes.js +48 -0
  96. package/dist/model/units/bytes.js.map +1 -0
  97. package/dist/model/units/constants.d.ts +2 -0
  98. package/dist/model/units/constants.d.ts.map +1 -0
  99. package/dist/model/units/constants.js +17 -0
  100. package/dist/model/units/constants.js.map +1 -0
  101. package/dist/model/units/decimal.d.ts +24 -0
  102. package/dist/model/units/decimal.d.ts.map +1 -0
  103. package/dist/model/units/decimal.js +59 -0
  104. package/dist/model/units/decimal.js.map +1 -0
  105. package/dist/model/units/index.d.ts +4 -0
  106. package/dist/model/units/index.d.ts.map +1 -0
  107. package/dist/model/units/index.js +17 -0
  108. package/dist/model/units/index.js.map +1 -0
  109. package/dist/model/units/percent.d.ts +12 -0
  110. package/dist/model/units/percent.d.ts.map +1 -0
  111. package/dist/model/units/percent.js +51 -0
  112. package/dist/model/units/percent.js.map +1 -0
  113. package/dist/model/units/time.d.ts +11 -0
  114. package/dist/model/units/time.d.ts.map +1 -0
  115. package/dist/model/units/time.js +125 -0
  116. package/dist/model/units/time.js.map +1 -0
  117. package/dist/model/units/types.d.ts +38 -0
  118. package/dist/model/units/types.d.ts.map +1 -0
  119. package/dist/model/units/types.js +22 -0
  120. package/dist/model/units/types.js.map +1 -0
  121. package/dist/model/units/units.d.ts +40 -0
  122. package/dist/model/units/units.d.ts.map +1 -0
  123. package/dist/model/units/units.js +83 -0
  124. package/dist/model/units/units.js.map +1 -0
  125. package/dist/utils/component-ids.d.ts +8 -0
  126. package/dist/utils/component-ids.d.ts.map +1 -0
  127. package/dist/utils/component-ids.js +27 -0
  128. package/dist/utils/component-ids.js.map +1 -0
  129. package/dist/utils/index.d.ts +1 -0
  130. package/dist/utils/index.d.ts.map +1 -1
  131. package/dist/utils/index.js +1 -0
  132. package/dist/utils/index.js.map +1 -1
  133. package/package.json +2 -2
  134. package/dist/cjs/model/units.js +0 -203
  135. package/dist/model/units.d.ts +0 -36
  136. package/dist/model/units.d.ts.map +0 -1
  137. package/dist/model/units.js +0 -196
  138. package/dist/model/units.js.map +0 -1
@@ -0,0 +1,211 @@
1
+ // Copyright 2022 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 { render, screen } from '@testing-library/react';
15
+ import userEvent from '@testing-library/user-event';
16
+ import { UnitSelector } from './UnitSelector';
17
+ describe('UnitSelector', ()=>{
18
+ const renderUnitSelector = (value, onChange = jest.fn())=>{
19
+ render(/*#__PURE__*/ _jsx("div", {
20
+ children: /*#__PURE__*/ _jsx(UnitSelector, {
21
+ value: value,
22
+ onChange: onChange
23
+ })
24
+ }));
25
+ };
26
+ const getUnitSelector = ()=>{
27
+ return screen.getByRole('combobox', {
28
+ name: 'Units'
29
+ });
30
+ };
31
+ const getDecimalSelector = ()=>{
32
+ return screen.getByRole('combobox', {
33
+ name: 'Decimal'
34
+ });
35
+ };
36
+ const getAbbreviateSwitch = ()=>{
37
+ return screen.getByRole('checkbox', {
38
+ name: 'Abbreviate'
39
+ });
40
+ };
41
+ it('can change the unit kind by clicking', ()=>{
42
+ const onChange = jest.fn();
43
+ renderUnitSelector({
44
+ kind: 'Minutes'
45
+ }, onChange);
46
+ const unitSelector = getUnitSelector();
47
+ userEvent.click(unitSelector);
48
+ const decimalOption = screen.getByRole('option', {
49
+ name: 'Decimal'
50
+ });
51
+ userEvent.click(decimalOption);
52
+ expect(onChange).toHaveBeenCalledWith({
53
+ kind: 'Decimal'
54
+ });
55
+ });
56
+ it('can change the unit kind using a keyboard', ()=>{
57
+ const onChange = jest.fn();
58
+ renderUnitSelector({
59
+ kind: 'Bytes'
60
+ }, onChange);
61
+ const unitSelector = getUnitSelector();
62
+ // Note that this tab order can change depending on the type because the
63
+ // abbreviate comes first and is disabled in some cases.
64
+ userEvent.tab();
65
+ expect(unitSelector).toHaveFocus();
66
+ userEvent.clear(unitSelector);
67
+ userEvent.keyboard('years');
68
+ screen.getByRole('option', {
69
+ name: 'Years'
70
+ });
71
+ userEvent.keyboard('{arrowup}{enter}');
72
+ expect(onChange).toHaveBeenCalledWith({
73
+ kind: 'Years'
74
+ });
75
+ });
76
+ it('can change the decimal places by clicking', ()=>{
77
+ const onChange = jest.fn();
78
+ renderUnitSelector({
79
+ kind: 'Decimal',
80
+ decimal_places: 0,
81
+ abbreviate: true
82
+ }, onChange);
83
+ userEvent.click(getDecimalSelector());
84
+ const decimalOption = screen.getByRole('option', {
85
+ name: '1'
86
+ });
87
+ userEvent.click(decimalOption);
88
+ expect(onChange).toHaveBeenCalledWith({
89
+ kind: 'Decimal',
90
+ decimal_places: 1,
91
+ abbreviate: true
92
+ });
93
+ });
94
+ it('can change the decimal places using a keyboard', ()=>{
95
+ const onChange = jest.fn();
96
+ renderUnitSelector({
97
+ kind: 'Percent'
98
+ }, onChange);
99
+ const decimalSelector = getDecimalSelector();
100
+ userEvent.tab();
101
+ userEvent.tab();
102
+ expect(decimalSelector).toHaveFocus();
103
+ userEvent.clear(decimalSelector);
104
+ userEvent.keyboard('3');
105
+ screen.getByRole('option', {
106
+ name: '3'
107
+ });
108
+ userEvent.keyboard('{arrowup}{enter}');
109
+ expect(onChange).toHaveBeenCalledWith({
110
+ kind: 'Percent',
111
+ decimal_places: 3
112
+ });
113
+ });
114
+ it('can change abbreviate by clicking', ()=>{
115
+ const onChange = jest.fn();
116
+ renderUnitSelector({
117
+ kind: 'Decimal',
118
+ decimal_places: 3,
119
+ abbreviate: true
120
+ }, onChange);
121
+ userEvent.click(getAbbreviateSwitch());
122
+ expect(onChange).toHaveBeenCalledWith({
123
+ kind: 'Decimal',
124
+ decimal_places: 3,
125
+ abbreviate: false
126
+ });
127
+ });
128
+ it('can change abbreviate using a keyboard', ()=>{
129
+ const onChange = jest.fn();
130
+ renderUnitSelector({
131
+ kind: 'Decimal',
132
+ decimal_places: 0
133
+ }, onChange);
134
+ userEvent.tab();
135
+ userEvent.keyboard('{space}');
136
+ expect(onChange).toHaveBeenCalledWith({
137
+ kind: 'Decimal',
138
+ decimal_places: 0,
139
+ abbreviate: true
140
+ });
141
+ });
142
+ describe('with a time unit selected', ()=>{
143
+ it('does not allow the user to modify the decimal places', ()=>{
144
+ renderUnitSelector({
145
+ kind: 'Hours'
146
+ });
147
+ expect(getDecimalSelector()).toBeDisabled();
148
+ });
149
+ it('does not allow the user to set abbreviate', ()=>{
150
+ renderUnitSelector({
151
+ kind: 'Minutes'
152
+ });
153
+ expect(getAbbreviateSwitch()).toBeDisabled();
154
+ });
155
+ });
156
+ describe('with a percent unit selected', ()=>{
157
+ it('allows the user to modify the decimal places', ()=>{
158
+ renderUnitSelector({
159
+ kind: 'Percent'
160
+ });
161
+ expect(getDecimalSelector()).toBeEnabled();
162
+ });
163
+ it('does not allow the user to set abbreviate', ()=>{
164
+ renderUnitSelector({
165
+ kind: 'PercentDecimal'
166
+ });
167
+ expect(getAbbreviateSwitch()).toBeDisabled();
168
+ });
169
+ });
170
+ describe('with a decimal unit selected', ()=>{
171
+ it('allows the user to modify the decimal places', ()=>{
172
+ renderUnitSelector({
173
+ kind: 'Decimal'
174
+ });
175
+ expect(getDecimalSelector()).toBeEnabled();
176
+ });
177
+ it('allows the user to set abbreviate', ()=>{
178
+ renderUnitSelector({
179
+ kind: 'Decimal'
180
+ });
181
+ expect(getAbbreviateSwitch()).toBeEnabled();
182
+ });
183
+ });
184
+ describe('with a bytes unit selected', ()=>{
185
+ it('allows the user to modify the decimal places', ()=>{
186
+ renderUnitSelector({
187
+ kind: 'Bytes'
188
+ });
189
+ expect(getDecimalSelector()).toBeEnabled();
190
+ });
191
+ it('does not allow the user to set abbreviate', ()=>{
192
+ renderUnitSelector({
193
+ kind: 'Bytes'
194
+ });
195
+ expect(getAbbreviateSwitch()).toBeDisabled();
196
+ });
197
+ });
198
+ it('should not show an option for disabled units', ()=>{
199
+ const onChange = jest.fn();
200
+ renderUnitSelector({
201
+ kind: 'Decimal'
202
+ }, onChange);
203
+ userEvent.click(getUnitSelector());
204
+ const percentShorthandOption = screen.queryByRole('option', {
205
+ name: '%'
206
+ });
207
+ expect(percentShorthandOption).not.toBeInTheDocument();
208
+ });
209
+ });
210
+
211
+ //# sourceMappingURL=UnitSelector.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/UnitSelector/UnitSelector.test.tsx"],"sourcesContent":["// Copyright 2022 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 { render, screen } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport { UnitOptions } from '../model';\nimport { UnitSelector } from './UnitSelector';\n\ndescribe('UnitSelector', () => {\n const renderUnitSelector = (value: UnitOptions, onChange = jest.fn()) => {\n render(\n <div>\n <UnitSelector value={value} onChange={onChange} />\n </div>\n );\n };\n\n const getUnitSelector = () => {\n return screen.getByRole('combobox', { name: 'Units' });\n };\n\n const getDecimalSelector = () => {\n return screen.getByRole('combobox', { name: 'Decimal' });\n };\n\n const getAbbreviateSwitch = () => {\n return screen.getByRole('checkbox', { name: 'Abbreviate' });\n };\n\n it('can change the unit kind by clicking', () => {\n const onChange = jest.fn();\n renderUnitSelector({ kind: 'Minutes' }, onChange);\n\n const unitSelector = getUnitSelector();\n userEvent.click(unitSelector);\n const decimalOption = screen.getByRole('option', {\n name: 'Decimal',\n });\n userEvent.click(decimalOption);\n\n expect(onChange).toHaveBeenCalledWith({\n kind: 'Decimal',\n });\n });\n\n it('can change the unit kind using a keyboard', () => {\n const onChange = jest.fn();\n renderUnitSelector({ kind: 'Bytes' }, onChange);\n\n const unitSelector = getUnitSelector();\n // Note that this tab order can change depending on the type because the\n // abbreviate comes first and is disabled in some cases.\n userEvent.tab();\n expect(unitSelector).toHaveFocus();\n\n userEvent.clear(unitSelector);\n userEvent.keyboard('years');\n screen.getByRole('option', {\n name: 'Years',\n });\n\n userEvent.keyboard('{arrowup}{enter}');\n\n expect(onChange).toHaveBeenCalledWith({\n kind: 'Years',\n });\n });\n\n it('can change the decimal places by clicking', () => {\n const onChange = jest.fn();\n renderUnitSelector({ kind: 'Decimal', decimal_places: 0, abbreviate: true }, onChange);\n\n userEvent.click(getDecimalSelector());\n const decimalOption = screen.getByRole('option', {\n name: '1',\n });\n userEvent.click(decimalOption);\n\n expect(onChange).toHaveBeenCalledWith({\n kind: 'Decimal',\n decimal_places: 1,\n abbreviate: true,\n });\n });\n\n it('can change the decimal places using a keyboard', () => {\n const onChange = jest.fn();\n renderUnitSelector({ kind: 'Percent' }, onChange);\n\n const decimalSelector = getDecimalSelector();\n userEvent.tab();\n userEvent.tab();\n expect(decimalSelector).toHaveFocus();\n\n userEvent.clear(decimalSelector);\n userEvent.keyboard('3');\n screen.getByRole('option', {\n name: '3',\n });\n\n userEvent.keyboard('{arrowup}{enter}');\n\n expect(onChange).toHaveBeenCalledWith({\n kind: 'Percent',\n decimal_places: 3,\n });\n });\n\n it('can change abbreviate by clicking', () => {\n const onChange = jest.fn();\n renderUnitSelector({ kind: 'Decimal', decimal_places: 3, abbreviate: true }, onChange);\n\n userEvent.click(getAbbreviateSwitch());\n\n expect(onChange).toHaveBeenCalledWith({\n kind: 'Decimal',\n decimal_places: 3,\n abbreviate: false,\n });\n });\n\n it('can change abbreviate using a keyboard', () => {\n const onChange = jest.fn();\n renderUnitSelector({ kind: 'Decimal', decimal_places: 0 }, onChange);\n\n userEvent.tab();\n userEvent.keyboard('{space}');\n\n expect(onChange).toHaveBeenCalledWith({\n kind: 'Decimal',\n decimal_places: 0,\n abbreviate: true,\n });\n });\n\n describe('with a time unit selected', () => {\n it('does not allow the user to modify the decimal places', () => {\n renderUnitSelector({ kind: 'Hours' });\n expect(getDecimalSelector()).toBeDisabled();\n });\n\n it('does not allow the user to set abbreviate', () => {\n renderUnitSelector({ kind: 'Minutes' });\n expect(getAbbreviateSwitch()).toBeDisabled();\n });\n });\n\n describe('with a percent unit selected', () => {\n it('allows the user to modify the decimal places', () => {\n renderUnitSelector({ kind: 'Percent' });\n expect(getDecimalSelector()).toBeEnabled();\n });\n\n it('does not allow the user to set abbreviate', () => {\n renderUnitSelector({ kind: 'PercentDecimal' });\n expect(getAbbreviateSwitch()).toBeDisabled();\n });\n });\n\n describe('with a decimal unit selected', () => {\n it('allows the user to modify the decimal places', () => {\n renderUnitSelector({ kind: 'Decimal' });\n expect(getDecimalSelector()).toBeEnabled();\n });\n\n it('allows the user to set abbreviate', () => {\n renderUnitSelector({ kind: 'Decimal' });\n expect(getAbbreviateSwitch()).toBeEnabled();\n });\n });\n\n describe('with a bytes unit selected', () => {\n it('allows the user to modify the decimal places', () => {\n renderUnitSelector({ kind: 'Bytes' });\n expect(getDecimalSelector()).toBeEnabled();\n });\n\n it('does not allow the user to set abbreviate', () => {\n renderUnitSelector({ kind: 'Bytes' });\n expect(getAbbreviateSwitch()).toBeDisabled();\n });\n });\n\n it('should not show an option for disabled units', () => {\n const onChange = jest.fn();\n renderUnitSelector({ kind: 'Decimal' }, onChange);\n\n userEvent.click(getUnitSelector());\n const percentShorthandOption = screen.queryByRole('option', {\n name: '%',\n });\n expect(percentShorthandOption).not.toBeInTheDocument();\n });\n});\n"],"names":["render","screen","userEvent","UnitSelector","describe","renderUnitSelector","value","onChange","jest","fn","div","getUnitSelector","getByRole","name","getDecimalSelector","getAbbreviateSwitch","it","kind","unitSelector","click","decimalOption","expect","toHaveBeenCalledWith","tab","toHaveFocus","clear","keyboard","decimal_places","abbreviate","decimalSelector","toBeDisabled","toBeEnabled","percentShorthandOption","queryByRole","not","toBeInTheDocument"],"mappings":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AkB,EAAE,CAAC,CAACiB,WAAW,EAAE,CAAC;QAC7C,CAAC,CAAC,CAAC;QAEHf,EAAE,CAAC,2CAA2C,EAAE,IAAM;YACpDX,kBAAkB,CAAC;gBAAEY,IAAI,EAAE,OAAO;aAAE,CAAC,CAAC;YACtCI,MAAM,CAACN,mBAAmB,EAAE,CAAC,CAACe,YAAY,EAAE,CAAC;QAC/C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEHd,EAAE,CAAC,8CAA8C,EAAE,IAAM;QACvD,MAAMT,QAAQ,GAAGC,IAAI,CAACC,EAAE,EAAE,AAAC;QAC3BJ,kBAAkB,CAAC;YAAEY,IAAI,EAAE,SAAS;SAAE,EAAEV,QAAQ,CAAC,CAAC;QAElDL,SAAS,CAACiB,KAAK,CAACR,eAAe,EAAE,CAAC,CAAC;QACnC,MAAMqB,sBAAsB,GAAG/B,MAAM,CAACgC,WAAW,CAAC,QAAQ,EAAE;YAC1DpB,IAAI,EAAE,GAAG;SACV,CAAC,AAAC;QACHQ,MAAM,CAACW,sBAAsB,CAAC,CAACE,GAAG,CAACC,iBAAiB,EAAE,CAAC;IACzD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './UnitSelector';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/UnitSelector/index.ts"],"names":[],"mappings":"AAaA,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,15 @@
1
+ // Copyright 2022 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 './UnitSelector';
14
+
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/UnitSelector/index.ts"],"sourcesContent":["// Copyright 2022 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 './UnitSelector';\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,gBAAgB,CAAC"}
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ interface YAxisLabelProps {
3
+ name: string;
4
+ height: number;
5
+ }
6
+ export declare function YAxisLabel({ name, height }: YAxisLabelProps): JSX.Element;
7
+ export {};
8
+ //# sourceMappingURL=YAxisLabel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"YAxisLabel.d.ts","sourceRoot":"","sources":["../src/YAxisLabel.tsx"],"names":[],"mappings":";AAeA,UAAU,eAAe;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,UAAU,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,eAAe,eA0B3D"}
@@ -0,0 +1,39 @@
1
+ // Copyright 2022 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 { Box, Typography } from '@mui/material';
15
+ export function YAxisLabel({ name , height }) {
16
+ return /*#__PURE__*/ _jsx(Box, {
17
+ sx: {
18
+ display: 'inline-block',
19
+ maxWidth: height,
20
+ position: 'absolute',
21
+ top: '45%',
22
+ transform: 'translateX(-50%) rotate(-90deg)',
23
+ transformOrigin: 'top',
24
+ textAlign: 'center',
25
+ zIndex: 1
26
+ },
27
+ children: /*#__PURE__*/ _jsx(Typography, {
28
+ variant: "body1",
29
+ sx: {
30
+ whiteSpace: 'nowrap',
31
+ overflow: 'hidden',
32
+ textOverflow: 'ellipsis'
33
+ },
34
+ children: name
35
+ })
36
+ });
37
+ }
38
+
39
+ //# sourceMappingURL=YAxisLabel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/YAxisLabel.tsx"],"sourcesContent":["// Copyright 2022 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 { Box, Typography } from '@mui/material';\n\ninterface YAxisLabelProps {\n name: string;\n height: number;\n}\n\nexport function YAxisLabel({ name, height }: YAxisLabelProps) {\n return (\n <Box\n sx={{\n display: 'inline-block',\n maxWidth: height, // allows rotated text to truncate instead of causing overlap\n position: 'absolute',\n top: '45%',\n transform: 'translateX(-50%) rotate(-90deg)',\n transformOrigin: 'top',\n textAlign: 'center',\n zIndex: 1,\n }}\n >\n <Typography\n variant=\"body1\"\n sx={{\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n }}\n >\n {name}\n </Typography>\n </Box>\n );\n}\n"],"names":["Box","Typography","YAxisLabel","name","height","sx","display","maxWidth","position","top","transform","transformOrigin","textAlign","zIndex","variant","whiteSpace","overflow","textOverflow"],"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;AAAA,SAASA,GAAG,EAAEC,UAAU,QAAQ,eAAe,CAAC;AAOhD,OAAO,SAASC,UAAU,CAAC,EAAEC,IAAI,CAAA,EAAEC,MAAM,CAAA,EAAmB,EAAE;IAC5D,qBACE,KAACJ,GAAG;QACFK,EAAE,EAAE;YACFC,OAAO,EAAE,cAAc;YACvBC,QAAQ,EAAEH,MAAM;YAChBI,QAAQ,EAAE,UAAU;YACpBC,GAAG,EAAE,KAAK;YACVC,SAAS,EAAE,iCAAiC;YAC5CC,eAAe,EAAE,KAAK;YACtBC,SAAS,EAAE,QAAQ;YACnBC,MAAM,EAAE,CAAC;SACV;kBAED,cAAA,KAACZ,UAAU;YACTa,OAAO,EAAC,OAAO;YACfT,EAAE,EAAE;gBACFU,UAAU,EAAE,QAAQ;gBACpBC,QAAQ,EAAE,QAAQ;gBAClBC,YAAY,EAAE,UAAU;aACzB;sBAEAd,IAAI;UACM;MACT,CACN;AACJ,CAAC"}
@@ -28,7 +28,6 @@ const _components = require("echarts/components");
28
28
  const _renderers = require("echarts/renderers");
29
29
  const _echart = require("../EChart");
30
30
  const _graph = require("../model/graph");
31
- const _units = require("../model/units");
32
31
  const _chartsThemeProvider = require("../context/ChartsThemeProvider");
33
32
  const _tooltip = require("../Tooltip/Tooltip");
34
33
  const _utils = require("./utils");
@@ -46,7 +45,7 @@ const _utils = require("./utils");
46
45
  _components.VisualMapComponent,
47
46
  _renderers.CanvasRenderer
48
47
  ]);
49
- function LineChart({ height , data , unit , grid , legend , visualMap , onDataZoom , onDoubleClick }) {
48
+ function LineChart({ height , data , yAxis , unit , grid , legend , visualMap , onDataZoom , onDoubleClick }) {
50
49
  const chartsTheme = (0, _chartsThemeProvider.useChartsTheme)();
51
50
  const chartRef = (0, _react.useRef)();
52
51
  const [showTooltip, setShowTooltip] = (0, _react.useState)(true);
@@ -132,18 +131,7 @@ function LineChart({ height , data , unit , grid , legend , visualMap , onDataZo
132
131
  }
133
132
  }
134
133
  },
135
- yAxis: {
136
- type: 'value',
137
- boundaryGap: [
138
- 0,
139
- '10%'
140
- ],
141
- axisLabel: {
142
- formatter: (value)=>{
143
- return (0, _units.formatValue)(value, unit);
144
- }
145
- }
146
- },
134
+ yAxis: (0, _utils.getYAxes)(yAxis, unit),
147
135
  animation: false,
148
136
  tooltip: {
149
137
  show: showPointsOnHover,
@@ -168,6 +156,7 @@ function LineChart({ height , data , unit , grid , legend , visualMap , onDataZo
168
156
  return option;
169
157
  }, [
170
158
  data,
159
+ yAxis,
171
160
  grid,
172
161
  legend,
173
162
  visualMap
@@ -187,7 +176,8 @@ function LineChart({ height , data , unit , grid , legend , visualMap , onDataZo
187
176
  chartRef: chartRef,
188
177
  chartData: data,
189
178
  wrapLabels: true,
190
- pinTooltip: pinTooltip
179
+ pinTooltip: pinTooltip,
180
+ unit: unit
191
181
  }),
192
182
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_echart.EChart, {
193
183
  sx: {
@@ -24,8 +24,11 @@ _export(exports, {
24
24
  enableDataZoom: ()=>enableDataZoom,
25
25
  restoreChart: ()=>restoreChart,
26
26
  getDateRange: ()=>getDateRange,
27
- getFormattedDate: ()=>getFormattedDate
27
+ getFormattedDate: ()=>getFormattedDate,
28
+ getYAxes: ()=>getYAxes
28
29
  });
30
+ const _lodashEs = require("lodash-es");
31
+ const _model = require("../model");
29
32
  function enableDataZoom(chart) {
30
33
  const chartModel = chart['_model'];
31
34
  if (chartModel === undefined) return;
@@ -41,6 +44,7 @@ function enableDataZoom(chart) {
41
44
  }
42
45
  }
43
46
  function restoreChart(chart) {
47
+ // TODO: support incremental unzoom instead of restore to original state
44
48
  chart.dispatchAction({
45
49
  type: 'restore'
46
50
  });
@@ -70,3 +74,21 @@ function getFormattedDate(value, rangeMs) {
70
74
  // remove comma when month / day present
71
75
  return DATE_FORMAT.format(value).replace(/, /g, ' ');
72
76
  }
77
+ function getYAxes(yAxis, unit) {
78
+ // TODO: support alternate yAxis that shows on right side
79
+ const Y_AXIS_DEFAULT = {
80
+ type: 'value',
81
+ boundaryGap: [
82
+ 0,
83
+ '10%'
84
+ ],
85
+ axisLabel: {
86
+ formatter: (value)=>{
87
+ return (0, _model.formatValue)(value, unit);
88
+ }
89
+ }
90
+ };
91
+ return [
92
+ (0, _lodashEs.merge)(Y_AXIS_DEFAULT, yAxis)
93
+ ];
94
+ }
@@ -0,0 +1,32 @@
1
+ // Copyright 2022 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, "OptionsEditorColumn", {
18
+ enumerable: true,
19
+ get: ()=>OptionsEditorColumn
20
+ });
21
+ const _jsxRuntime = require("react/jsx-runtime");
22
+ const _material = require("@mui/material");
23
+ const OptionsEditorColumn = ({ children })=>{
24
+ return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
25
+ item: true,
26
+ xs: 4,
27
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Stack, {
28
+ spacing: 3,
29
+ children: children
30
+ })
31
+ });
32
+ };
@@ -0,0 +1,61 @@
1
+ // Copyright 2022 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, "OptionsEditorControl", {
18
+ enumerable: true,
19
+ get: ()=>OptionsEditorControl
20
+ });
21
+ const _jsxRuntime = require("react/jsx-runtime");
22
+ const _material = require("@mui/material");
23
+ const _react = /*#__PURE__*/ _interopRequireDefault(require("react"));
24
+ const _utils = require("../utils");
25
+ function _interopRequireDefault(obj) {
26
+ return obj && obj.__esModule ? obj : {
27
+ default: obj
28
+ };
29
+ }
30
+ const OptionsEditorControl = ({ label , control })=>{
31
+ // Make sure we have a unique ID we can use for associating labels and
32
+ // controls for a11y.
33
+ const generatedControlId = (0, _utils.useId)('EditorSectionControl');
34
+ const controlId = `${generatedControlId}-control`;
35
+ const controlProps = {
36
+ id: controlId
37
+ };
38
+ return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.FormControl, {
39
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
40
+ direction: "row",
41
+ alignItems: "center",
42
+ justifyContent: "space-between",
43
+ children: [
44
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.FormLabel, {
45
+ htmlFor: controlId,
46
+ children: label
47
+ }),
48
+ /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
49
+ sx: {
50
+ width: '160px',
51
+ textAlign: 'right'
52
+ },
53
+ children: [
54
+ " ",
55
+ /*#__PURE__*/ _react.default.cloneElement(control, controlProps)
56
+ ]
57
+ })
58
+ ]
59
+ })
60
+ });
61
+ };
@@ -0,0 +1,29 @@
1
+ // Copyright 2022 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, "OptionsEditorGrid", {
18
+ enumerable: true,
19
+ get: ()=>OptionsEditorGrid
20
+ });
21
+ const _jsxRuntime = require("react/jsx-runtime");
22
+ const _material = require("@mui/material");
23
+ const OptionsEditorGrid = ({ children })=>{
24
+ return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
25
+ container: true,
26
+ spacing: 8,
27
+ children: children
28
+ });
29
+ };
@@ -0,0 +1,40 @@
1
+ // Copyright 2022 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, "OptionsEditorGroup", {
18
+ enumerable: true,
19
+ get: ()=>OptionsEditorGroup
20
+ });
21
+ const _jsxRuntime = require("react/jsx-runtime");
22
+ const _material = require("@mui/material");
23
+ const OptionsEditorGroup = ({ title , children })=>{
24
+ return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
25
+ children: [
26
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
27
+ variant: "overline",
28
+ component: "h4",
29
+ borderBottom: 1,
30
+ borderColor: "grey.300",
31
+ marginBottom: (theme)=>theme.spacing(1),
32
+ children: title
33
+ }),
34
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Stack, {
35
+ spacing: 1,
36
+ children: children
37
+ })
38
+ ]
39
+ });
40
+ };
@@ -0,0 +1,31 @@
1
+ // Copyright 2022 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
+ _exportStar(require("./OptionsEditorColumn"), exports);
18
+ _exportStar(require("./OptionsEditorControl"), exports);
19
+ _exportStar(require("./OptionsEditorGrid"), exports);
20
+ _exportStar(require("./OptionsEditorGroup"), exports);
21
+ function _exportStar(from, to) {
22
+ Object.keys(from).forEach(function(k) {
23
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
24
+ enumerable: true,
25
+ get: function() {
26
+ return from[k];
27
+ }
28
+ });
29
+ });
30
+ return from;
31
+ }
@@ -23,7 +23,7 @@ const _material = require("@mui/material");
23
23
  const _seriesMarker = require("./SeriesMarker");
24
24
  const _tooltipModel = require("./tooltip-model");
25
25
  function SeriesInfo(props) {
26
- const { seriesName , y , markerColor , totalSeries , wrapLabels } = props;
26
+ const { seriesName , formattedY , markerColor , totalSeries , wrapLabels } = props;
27
27
  // TODO (sjcobb): regex to remove __name__, improve series labels
28
28
  const formattedSeriesLabels = seriesName.replace(/[{}"]/g, '');
29
29
  if (totalSeries === 1) {
@@ -56,7 +56,7 @@ function SeriesInfo(props) {
56
56
  fontWeight: 700,
57
57
  paddingLeft: '2px'
58
58
  }),
59
- children: y
59
+ children: formattedY
60
60
  })
61
61
  ]
62
62
  })
@@ -142,7 +142,7 @@ function SeriesInfo(props) {
142
142
  textAlign: 'right',
143
143
  verticalAlign: 'top'
144
144
  },
145
- children: y
145
+ children: formattedY
146
146
  })
147
147
  ]
148
148
  });