@react-magma/charts 13.0.0 → 13.0.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.
- package/dist/charts.js +2450 -1
- package/dist/charts.js.map +1 -1
- package/dist/charts.modern.module.js +2428 -1
- package/dist/charts.modern.module.js.map +1 -1
- package/dist/charts.umd.js +49165 -1
- package/dist/charts.umd.js.map +1 -1
- package/dist/components/CarbonChart/CarbonChart.d.ts +2 -1
- package/dist/components/CarbonChart/CarbonChartArea.stories.d.ts +310 -0
- package/dist/components/CarbonChart/CarbonChartAreaStacked.stories.d.ts +136 -0
- package/dist/components/CarbonChart/CarbonChartBar.stories.d.ts +214 -0
- package/dist/components/CarbonChart/CarbonChartBarFloating.stories.d.ts +82 -0
- package/dist/components/CarbonChart/CarbonChartBarGrouped.stories.d.ts +234 -0
- package/dist/components/CarbonChart/CarbonChartBarStacked.stories.d.ts +266 -0
- package/dist/components/CarbonChart/CarbonChartBoxplot.stories.d.ts +53 -0
- package/dist/components/CarbonChart/CarbonChartBubble.stories.d.ts +196 -0
- package/dist/components/CarbonChart/CarbonChartBullet.stories.d.ts +35 -0
- package/dist/components/CarbonChart/CarbonChartCombo.stories.d.ts +580 -0
- package/dist/components/CarbonChart/CarbonChartDonut.stories.d.ts +120 -0
- package/dist/components/CarbonChart/CarbonChartGauge.stories.d.ts +43 -0
- package/dist/components/CarbonChart/CarbonChartHistogram.stories.d.ts +89 -0
- package/dist/components/CarbonChart/CarbonChartLine.stories.d.ts +577 -0
- package/dist/components/CarbonChart/CarbonChartLollipop.stories.d.ts +55 -0
- package/dist/components/CarbonChart/CarbonChartMeter.stories.d.ts +127 -0
- package/dist/components/CarbonChart/CarbonChartPie.stories.d.ts +101 -0
- package/dist/components/CarbonChart/CarbonChartRadar.stories.d.ts +98 -0
- package/dist/components/CarbonChart/CarbonChartScatter.stories.d.ts +173 -0
- package/dist/components/CarbonChart/CarbonChartSparkline.stories.d.ts +51 -0
- package/dist/components/CarbonChart/CarbonChartStep.stories.d.ts +38 -0
- package/dist/components/LineChart/Chart.d.ts +27 -0
- package/dist/components/LineChart/ChartDataTable.d.ts +17 -0
- package/dist/components/LineChart/CustomAxisComponent.d.ts +3 -0
- package/dist/components/LineChart/CustomPointComponent.d.ts +17 -0
- package/dist/components/LineChart/DataTable.d.ts +5 -0
- package/dist/components/LineChart/GraphTooltip.d.ts +3 -0
- package/dist/components/LineChart/LegendButton.d.ts +6 -0
- package/dist/components/LineChart/LineChart.d.ts +67 -0
- package/dist/components/LineChart/LineChart.stories.d.ts +113 -0
- package/dist/components/LineChart/index.d.ts +1 -0
- package/dist/components/LineChart/magma-charts.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/package.json +28 -26
- package/src/components/CarbonChart/CarbonChart.test.js +506 -0
- package/src/components/CarbonChart/CarbonChart.tsx +53 -57
- package/src/components/CarbonChart/CarbonChartArea.stories.tsx +1 -1
- package/src/components/CarbonChart/CarbonChartAreaStacked.stories.tsx +1 -1
- package/src/components/CarbonChart/CarbonChartBar.stories.tsx +1 -1
- package/src/components/CarbonChart/CarbonChartBarFloating.stories.tsx +1 -1
- package/src/components/CarbonChart/CarbonChartBarGrouped.stories.tsx +1 -1
- package/src/components/CarbonChart/CarbonChartBarStacked.stories.tsx +1 -1
- package/src/components/CarbonChart/CarbonChartBoxplot.stories.tsx +1 -1
- package/src/components/CarbonChart/CarbonChartBubble.stories.tsx +1 -1
- package/src/components/CarbonChart/CarbonChartBullet.stories.tsx +1 -1
- package/src/components/CarbonChart/CarbonChartCombo.stories.tsx +1 -1
- package/src/components/CarbonChart/CarbonChartDonut.stories.tsx +1 -1
- package/src/components/CarbonChart/CarbonChartGauge.stories.tsx +1 -1
- package/src/components/CarbonChart/CarbonChartHistogram.stories.tsx +1 -1
- package/src/components/CarbonChart/CarbonChartLine.stories.tsx +1 -1
- package/src/components/CarbonChart/CarbonChartLollipop.stories.tsx +1 -1
- package/src/components/CarbonChart/CarbonChartMeter.stories.tsx +1 -1
- package/src/components/CarbonChart/CarbonChartPie.stories.tsx +1 -1
- package/src/components/CarbonChart/CarbonChartRadar.stories.tsx +1 -1
- package/src/components/CarbonChart/CarbonChartScatter.stories.tsx +1 -1
- package/src/components/CarbonChart/CarbonChartSparkline.stories.tsx +1 -1
- package/src/components/CarbonChart/CarbonChartStep.stories.tsx +1 -1
- package/src/components/CarbonChart/carbon-charts.css +24931 -0
- package/src/components/LineChart/Chart.tsx +241 -0
- package/src/components/LineChart/ChartDataTable.test.js +165 -0
- package/src/components/LineChart/ChartDataTable.tsx +135 -0
- package/src/components/LineChart/CustomAxisComponent.tsx +30 -0
- package/src/components/LineChart/CustomPointComponent.tsx +93 -0
- package/src/components/LineChart/DataTable.tsx +57 -0
- package/src/components/LineChart/GraphTooltip.tsx +100 -0
- package/src/components/LineChart/LegendButton.tsx +77 -0
- package/src/components/LineChart/LineChart.stories.tsx +399 -0
- package/src/components/LineChart/LineChart.test.js +501 -0
- package/src/components/LineChart/LineChart.tsx +669 -0
- package/src/components/LineChart/index.ts +1 -0
- package/src/components/LineChart/magma-charts.ts +279 -0
- package/src/components/LineChart/test/exampleChartData.js +289 -0
- package/src/index.ts +1 -0
- package/dist/components/CarbonChart/CarbonChart.test.d.ts +0 -1
- package/dist/components/CarbonChart/embeddedStyles.d.ts +0 -1
- package/src/components/CarbonChart/embeddedStyles.ts +0 -24880
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import { render } from '@testing-library/react';
|
|
4
|
+
import { ThemeContext, magma } from 'react-magma-dom';
|
|
4
5
|
|
|
5
6
|
import { CarbonChart, CarbonChartType } from '.';
|
|
6
7
|
|
|
@@ -73,4 +74,509 @@ describe('CarbonChart', () => {
|
|
|
73
74
|
|
|
74
75
|
expect(getByTestId(testId)).toBeInTheDocument();
|
|
75
76
|
});
|
|
77
|
+
|
|
78
|
+
describe('Magma Theme Values Applied to Styles', () => {
|
|
79
|
+
it('should apply theme.colors.neutral700 to data table cells', () => {
|
|
80
|
+
const testId = 'table-color-test';
|
|
81
|
+
const { getByTestId } = render(
|
|
82
|
+
<ThemeContext.Provider value={magma}>
|
|
83
|
+
<CarbonChart
|
|
84
|
+
testId={testId}
|
|
85
|
+
dataSet={dataSet}
|
|
86
|
+
options={chartOptions}
|
|
87
|
+
type={CarbonChartType.bar}
|
|
88
|
+
/>
|
|
89
|
+
</ThemeContext.Provider>
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
const wrapper = getByTestId(testId);
|
|
93
|
+
|
|
94
|
+
// CarbonChartWrapper applies theme.colors.neutral700 to .cds--data-table td
|
|
95
|
+
expect(wrapper).toHaveStyleRule('color', magma.colors.neutral700, {
|
|
96
|
+
target: '.cds--data-table td',
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('should apply theme.colors.primary for button background in non-inverse mode', () => {
|
|
101
|
+
const testId = 'button-color-test';
|
|
102
|
+
const { getByTestId } = render(
|
|
103
|
+
<ThemeContext.Provider value={magma}>
|
|
104
|
+
<CarbonChart
|
|
105
|
+
testId={testId}
|
|
106
|
+
dataSet={dataSet}
|
|
107
|
+
options={chartOptions}
|
|
108
|
+
type={CarbonChartType.bar}
|
|
109
|
+
isInverse={false}
|
|
110
|
+
/>
|
|
111
|
+
</ThemeContext.Provider>
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
const wrapper = getByTestId(testId);
|
|
115
|
+
|
|
116
|
+
// CarbonChartWrapper applies theme.colors.primary to .cds--btn--primary
|
|
117
|
+
expect(wrapper).toHaveStyleRule('background', magma.colors.primary, {
|
|
118
|
+
target: '.chart-holder .cds--btn--primary',
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it('should apply theme.colors.tertiary500 for button background when isInverse is true', () => {
|
|
123
|
+
const testId = 'button-inverse-test';
|
|
124
|
+
const { getByTestId } = render(
|
|
125
|
+
<ThemeContext.Provider value={magma}>
|
|
126
|
+
<CarbonChart
|
|
127
|
+
testId={testId}
|
|
128
|
+
dataSet={dataSet}
|
|
129
|
+
options={chartOptions}
|
|
130
|
+
type={CarbonChartType.bar}
|
|
131
|
+
isInverse
|
|
132
|
+
/>
|
|
133
|
+
</ThemeContext.Provider>
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
const wrapper = getByTestId(testId);
|
|
137
|
+
|
|
138
|
+
// CarbonChartWrapper applies theme.colors.tertiary500 to .cds--btn--primary when inverse
|
|
139
|
+
expect(wrapper).toHaveStyleRule('background', magma.colors.tertiary500, {
|
|
140
|
+
target: '.chart-holder .cds--btn--primary',
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('should apply theme.colors.primary700 for inverse table header background', () => {
|
|
145
|
+
const testId = 'table-inverse-test';
|
|
146
|
+
const { getByTestId } = render(
|
|
147
|
+
<ThemeContext.Provider value={magma}>
|
|
148
|
+
<CarbonChart
|
|
149
|
+
testId={testId}
|
|
150
|
+
dataSet={dataSet}
|
|
151
|
+
options={chartOptions}
|
|
152
|
+
type={CarbonChartType.bar}
|
|
153
|
+
isInverse
|
|
154
|
+
/>
|
|
155
|
+
</ThemeContext.Provider>
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
const wrapper = getByTestId(testId);
|
|
159
|
+
|
|
160
|
+
// CarbonChartWrapper applies theme.colors.primary700 to table header when inverse
|
|
161
|
+
expect(wrapper).toHaveStyleRule(
|
|
162
|
+
'background',
|
|
163
|
+
`${magma.colors.primary700}!important`,
|
|
164
|
+
{
|
|
165
|
+
target: '.cds--data-table thead tr th',
|
|
166
|
+
}
|
|
167
|
+
);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it('should apply theme.colors.neutral100 for inverse text color', () => {
|
|
171
|
+
const testId = 'text-inverse-test';
|
|
172
|
+
const { getByTestId } = render(
|
|
173
|
+
<ThemeContext.Provider value={magma}>
|
|
174
|
+
<CarbonChart
|
|
175
|
+
testId={testId}
|
|
176
|
+
dataSet={dataSet}
|
|
177
|
+
options={chartOptions}
|
|
178
|
+
type={CarbonChartType.bar}
|
|
179
|
+
isInverse
|
|
180
|
+
/>
|
|
181
|
+
</ThemeContext.Provider>
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
const wrapper = getByTestId(testId);
|
|
185
|
+
|
|
186
|
+
// CarbonChartWrapper applies theme.colors.neutral100 to text when inverse
|
|
187
|
+
expect(wrapper).toHaveStyleRule('color', magma.colors.neutral100, {
|
|
188
|
+
target: 'p',
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
it('should apply theme.bodyFont to chart text elements', () => {
|
|
193
|
+
const testId = 'font-test';
|
|
194
|
+
const { getByTestId } = render(
|
|
195
|
+
<ThemeContext.Provider value={magma}>
|
|
196
|
+
<CarbonChart
|
|
197
|
+
testId={testId}
|
|
198
|
+
dataSet={dataSet}
|
|
199
|
+
options={chartOptions}
|
|
200
|
+
type={CarbonChartType.bar}
|
|
201
|
+
/>
|
|
202
|
+
</ThemeContext.Provider>
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
const wrapper = getByTestId(testId);
|
|
206
|
+
|
|
207
|
+
// CarbonChartWrapper applies theme.bodyFont to various text elements
|
|
208
|
+
expect(wrapper).toHaveStyleRule(
|
|
209
|
+
'font-family',
|
|
210
|
+
`${magma.bodyFont}!important`,
|
|
211
|
+
{
|
|
212
|
+
target: 'p',
|
|
213
|
+
}
|
|
214
|
+
);
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it('should apply theme.typeScale.size02.fontSize to tooltip text', () => {
|
|
218
|
+
const testId = 'font-size-test';
|
|
219
|
+
const { getByTestId } = render(
|
|
220
|
+
<ThemeContext.Provider value={magma}>
|
|
221
|
+
<CarbonChart
|
|
222
|
+
testId={testId}
|
|
223
|
+
dataSet={dataSet}
|
|
224
|
+
options={chartOptions}
|
|
225
|
+
type={CarbonChartType.bar}
|
|
226
|
+
/>
|
|
227
|
+
</ThemeContext.Provider>
|
|
228
|
+
);
|
|
229
|
+
|
|
230
|
+
const wrapper = getByTestId(testId);
|
|
231
|
+
|
|
232
|
+
// CarbonChartWrapper applies theme.typeScale.size02.fontSize to tooltips
|
|
233
|
+
expect(wrapper).toHaveStyleRule(
|
|
234
|
+
'font-size',
|
|
235
|
+
magma.typeScale.size02.fontSize,
|
|
236
|
+
{
|
|
237
|
+
target: '.cds--cc--tooltip .content-box .datapoint-tooltip p',
|
|
238
|
+
}
|
|
239
|
+
);
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
it('should apply theme.typeScale.size03.fontSize to legend text', () => {
|
|
243
|
+
const testId = 'legend-font-test';
|
|
244
|
+
const { getByTestId } = render(
|
|
245
|
+
<ThemeContext.Provider value={magma}>
|
|
246
|
+
<CarbonChart
|
|
247
|
+
testId={testId}
|
|
248
|
+
dataSet={dataSet}
|
|
249
|
+
options={chartOptions}
|
|
250
|
+
type={CarbonChartType.bar}
|
|
251
|
+
/>
|
|
252
|
+
</ThemeContext.Provider>
|
|
253
|
+
);
|
|
254
|
+
|
|
255
|
+
const wrapper = getByTestId(testId);
|
|
256
|
+
|
|
257
|
+
// CarbonChartWrapper applies theme.typeScale.size03.fontSize to legend
|
|
258
|
+
expect(wrapper).toHaveStyleRule(
|
|
259
|
+
'font-size',
|
|
260
|
+
magma.typeScale.size03.fontSize,
|
|
261
|
+
{
|
|
262
|
+
target: 'div.cds--cc--legend div.legend-item p',
|
|
263
|
+
}
|
|
264
|
+
);
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
it('should apply theme.borderRadius to modal container', () => {
|
|
268
|
+
const testId = 'border-radius-test';
|
|
269
|
+
const { getByTestId } = render(
|
|
270
|
+
<ThemeContext.Provider value={magma}>
|
|
271
|
+
<CarbonChart
|
|
272
|
+
testId={testId}
|
|
273
|
+
dataSet={dataSet}
|
|
274
|
+
options={chartOptions}
|
|
275
|
+
type={CarbonChartType.bar}
|
|
276
|
+
/>
|
|
277
|
+
</ThemeContext.Provider>
|
|
278
|
+
);
|
|
279
|
+
|
|
280
|
+
const wrapper = getByTestId(testId);
|
|
281
|
+
|
|
282
|
+
// CarbonChartWrapper applies theme.borderRadius in clip-path
|
|
283
|
+
expect(wrapper).toHaveStyleRule(
|
|
284
|
+
'clip-path',
|
|
285
|
+
`inset(0% 0% 0% 0% round ${magma.borderRadius})`,
|
|
286
|
+
{
|
|
287
|
+
target: '.cds--modal-container',
|
|
288
|
+
}
|
|
289
|
+
);
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
it('should apply theme.colors.focus for focus outline', () => {
|
|
293
|
+
const testId = 'focus-color-test';
|
|
294
|
+
const { getByTestId } = render(
|
|
295
|
+
<ThemeContext.Provider value={magma}>
|
|
296
|
+
<CarbonChart
|
|
297
|
+
testId={testId}
|
|
298
|
+
dataSet={dataSet}
|
|
299
|
+
options={chartOptions}
|
|
300
|
+
type={CarbonChartType.bar}
|
|
301
|
+
/>
|
|
302
|
+
</ThemeContext.Provider>
|
|
303
|
+
);
|
|
304
|
+
|
|
305
|
+
const wrapper = getByTestId(testId);
|
|
306
|
+
|
|
307
|
+
// CarbonChartWrapper applies theme.colors.focus to outline
|
|
308
|
+
expect(wrapper).toHaveStyleRule(
|
|
309
|
+
'outline',
|
|
310
|
+
`2px solid ${magma.colors.focus}!important`,
|
|
311
|
+
{
|
|
312
|
+
target: '.chart-holder *:focus',
|
|
313
|
+
}
|
|
314
|
+
);
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
it('should apply theme.colors.focusInverse for focus outline when isInverse is true', () => {
|
|
318
|
+
const testId = 'focus-inverse-test';
|
|
319
|
+
const { getByTestId } = render(
|
|
320
|
+
<ThemeContext.Provider value={magma}>
|
|
321
|
+
<CarbonChart
|
|
322
|
+
testId={testId}
|
|
323
|
+
dataSet={dataSet}
|
|
324
|
+
options={chartOptions}
|
|
325
|
+
type={CarbonChartType.bar}
|
|
326
|
+
isInverse
|
|
327
|
+
/>
|
|
328
|
+
</ThemeContext.Provider>
|
|
329
|
+
);
|
|
330
|
+
|
|
331
|
+
const wrapper = getByTestId(testId);
|
|
332
|
+
|
|
333
|
+
// CarbonChartWrapper applies theme.colors.focusInverse to outline when inverse
|
|
334
|
+
expect(wrapper).toHaveStyleRule(
|
|
335
|
+
'outline',
|
|
336
|
+
`2px solid ${magma.colors.focusInverse}!important`,
|
|
337
|
+
{
|
|
338
|
+
target: '.chart-holder *:focus',
|
|
339
|
+
}
|
|
340
|
+
);
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
it('should apply theme.spaceScale.spacing05 to legend checkbox dimensions', () => {
|
|
344
|
+
const testId = 'spacing-test';
|
|
345
|
+
const { getByTestId } = render(
|
|
346
|
+
<ThemeContext.Provider value={magma}>
|
|
347
|
+
<CarbonChart
|
|
348
|
+
testId={testId}
|
|
349
|
+
dataSet={dataSet}
|
|
350
|
+
options={chartOptions}
|
|
351
|
+
type={CarbonChartType.bar}
|
|
352
|
+
/>
|
|
353
|
+
</ThemeContext.Provider>
|
|
354
|
+
);
|
|
355
|
+
|
|
356
|
+
const wrapper = getByTestId(testId);
|
|
357
|
+
|
|
358
|
+
// CarbonChartWrapper applies theme.spaceScale.spacing05 to checkbox width
|
|
359
|
+
expect(wrapper).toHaveStyleRule('width', magma.spaceScale.spacing05, {
|
|
360
|
+
target: 'div.cds--cc--legend div.legend-item div.checkbox',
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
// And height
|
|
364
|
+
expect(wrapper).toHaveStyleRule('height', magma.spaceScale.spacing05, {
|
|
365
|
+
target: 'div.cds--cc--legend div.legend-item div.checkbox',
|
|
366
|
+
});
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
it('should apply theme.colors.neutral900 to legend checkbox background when isInverse', () => {
|
|
370
|
+
const testId = 'legend-bg-inverse-test';
|
|
371
|
+
const { getByTestId } = render(
|
|
372
|
+
<ThemeContext.Provider value={magma}>
|
|
373
|
+
<CarbonChart
|
|
374
|
+
testId={testId}
|
|
375
|
+
dataSet={dataSet}
|
|
376
|
+
options={chartOptions}
|
|
377
|
+
type={CarbonChartType.bar}
|
|
378
|
+
isInverse
|
|
379
|
+
/>
|
|
380
|
+
</ThemeContext.Provider>
|
|
381
|
+
);
|
|
382
|
+
|
|
383
|
+
const wrapper = getByTestId(testId);
|
|
384
|
+
|
|
385
|
+
// CarbonChartWrapper applies theme.colors.neutral900 to checkbox background when inverse
|
|
386
|
+
expect(wrapper).toHaveStyleRule('background', magma.colors.neutral900, {
|
|
387
|
+
target: 'div.cds--cc--legend div.legend-item div.checkbox',
|
|
388
|
+
});
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
it('should apply theme.colors.neutral100 to legend checkbox background in normal mode', () => {
|
|
392
|
+
const testId = 'legend-bg-test';
|
|
393
|
+
const { getByTestId } = render(
|
|
394
|
+
<ThemeContext.Provider value={magma}>
|
|
395
|
+
<CarbonChart
|
|
396
|
+
testId={testId}
|
|
397
|
+
dataSet={dataSet}
|
|
398
|
+
options={chartOptions}
|
|
399
|
+
type={CarbonChartType.bar}
|
|
400
|
+
isInverse={false}
|
|
401
|
+
/>
|
|
402
|
+
</ThemeContext.Provider>
|
|
403
|
+
);
|
|
404
|
+
|
|
405
|
+
const wrapper = getByTestId(testId);
|
|
406
|
+
|
|
407
|
+
// CarbonChartWrapper applies theme.colors.neutral100 to checkbox background
|
|
408
|
+
expect(wrapper).toHaveStyleRule('background', magma.colors.neutral100, {
|
|
409
|
+
target: 'div.cds--cc--legend div.legend-item div.checkbox',
|
|
410
|
+
});
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
it('should apply theme.colors.neutral100 to modal header background in normal mode', () => {
|
|
414
|
+
const testId = 'modal-header-test';
|
|
415
|
+
const { getByTestId } = render(
|
|
416
|
+
<ThemeContext.Provider value={magma}>
|
|
417
|
+
<CarbonChart
|
|
418
|
+
testId={testId}
|
|
419
|
+
dataSet={dataSet}
|
|
420
|
+
options={chartOptions}
|
|
421
|
+
type={CarbonChartType.bar}
|
|
422
|
+
isInverse={false}
|
|
423
|
+
/>
|
|
424
|
+
</ThemeContext.Provider>
|
|
425
|
+
);
|
|
426
|
+
|
|
427
|
+
const wrapper = getByTestId(testId);
|
|
428
|
+
|
|
429
|
+
// CarbonChartWrapper applies theme.colors.neutral100 to modal header background
|
|
430
|
+
expect(wrapper).toHaveStyleRule('background', magma.colors.neutral100, {
|
|
431
|
+
target: '.chart-holder .cds--modal-header',
|
|
432
|
+
});
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
it('should apply theme.colors.primary600 to modal header background when isInverse', () => {
|
|
436
|
+
const testId = 'modal-header-inverse-test';
|
|
437
|
+
const { getByTestId } = render(
|
|
438
|
+
<ThemeContext.Provider value={magma}>
|
|
439
|
+
<CarbonChart
|
|
440
|
+
testId={testId}
|
|
441
|
+
dataSet={dataSet}
|
|
442
|
+
options={chartOptions}
|
|
443
|
+
type={CarbonChartType.bar}
|
|
444
|
+
isInverse
|
|
445
|
+
/>
|
|
446
|
+
</ThemeContext.Provider>
|
|
447
|
+
);
|
|
448
|
+
|
|
449
|
+
const wrapper = getByTestId(testId);
|
|
450
|
+
|
|
451
|
+
// CarbonChartWrapper applies theme.colors.primary600 to modal header when inverse
|
|
452
|
+
expect(wrapper).toHaveStyleRule('background', magma.colors.primary600, {
|
|
453
|
+
target: '.chart-holder .cds--modal-header',
|
|
454
|
+
});
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
it('should apply font-weight 600 to modal header heading', () => {
|
|
458
|
+
const testId = 'modal-heading-test';
|
|
459
|
+
const { getByTestId } = render(
|
|
460
|
+
<ThemeContext.Provider value={magma}>
|
|
461
|
+
<CarbonChart
|
|
462
|
+
testId={testId}
|
|
463
|
+
dataSet={dataSet}
|
|
464
|
+
options={chartOptions}
|
|
465
|
+
type={CarbonChartType.bar}
|
|
466
|
+
/>
|
|
467
|
+
</ThemeContext.Provider>
|
|
468
|
+
);
|
|
469
|
+
|
|
470
|
+
const wrapper = getByTestId(testId);
|
|
471
|
+
|
|
472
|
+
// CarbonChartWrapper applies font-weight to modal header heading
|
|
473
|
+
expect(wrapper).toHaveStyleRule('font-weight', '600', {
|
|
474
|
+
target: '.chart-holder .cds--modal-header__heading',
|
|
475
|
+
});
|
|
476
|
+
});
|
|
477
|
+
|
|
478
|
+
it('should apply theme.colors.neutral100 to modal footer background in normal mode', () => {
|
|
479
|
+
const testId = 'modal-footer-test';
|
|
480
|
+
const { getByTestId } = render(
|
|
481
|
+
<ThemeContext.Provider value={magma}>
|
|
482
|
+
<CarbonChart
|
|
483
|
+
testId={testId}
|
|
484
|
+
dataSet={dataSet}
|
|
485
|
+
options={chartOptions}
|
|
486
|
+
type={CarbonChartType.bar}
|
|
487
|
+
isInverse={false}
|
|
488
|
+
/>
|
|
489
|
+
</ThemeContext.Provider>
|
|
490
|
+
);
|
|
491
|
+
|
|
492
|
+
const wrapper = getByTestId(testId);
|
|
493
|
+
|
|
494
|
+
// CarbonChartWrapper applies theme.colors.neutral100 to modal footer background
|
|
495
|
+
expect(wrapper).toHaveStyleRule(
|
|
496
|
+
'background',
|
|
497
|
+
`${magma.colors.neutral100}!important`,
|
|
498
|
+
{
|
|
499
|
+
target: '.cds--modal-footer.cds--modal-footer',
|
|
500
|
+
}
|
|
501
|
+
);
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
it('should apply theme.colors.primary600 to modal footer background when isInverse', () => {
|
|
505
|
+
const testId = 'modal-footer-inverse-test';
|
|
506
|
+
const { getByTestId } = render(
|
|
507
|
+
<ThemeContext.Provider value={magma}>
|
|
508
|
+
<CarbonChart
|
|
509
|
+
testId={testId}
|
|
510
|
+
dataSet={dataSet}
|
|
511
|
+
options={chartOptions}
|
|
512
|
+
type={CarbonChartType.bar}
|
|
513
|
+
isInverse
|
|
514
|
+
/>
|
|
515
|
+
</ThemeContext.Provider>
|
|
516
|
+
);
|
|
517
|
+
|
|
518
|
+
const wrapper = getByTestId(testId);
|
|
519
|
+
|
|
520
|
+
// CarbonChartWrapper applies theme.colors.primary600 to modal footer when inverse
|
|
521
|
+
expect(wrapper).toHaveStyleRule(
|
|
522
|
+
'background',
|
|
523
|
+
`${magma.colors.primary600}!important`,
|
|
524
|
+
{
|
|
525
|
+
target: '.cds--modal-footer.cds--modal-footer',
|
|
526
|
+
}
|
|
527
|
+
);
|
|
528
|
+
});
|
|
529
|
+
|
|
530
|
+
it('should apply theme.colors.neutral300 border to modal header in normal mode', () => {
|
|
531
|
+
const testId = 'modal-header-border-test';
|
|
532
|
+
const { getByTestId } = render(
|
|
533
|
+
<ThemeContext.Provider value={magma}>
|
|
534
|
+
<CarbonChart
|
|
535
|
+
testId={testId}
|
|
536
|
+
dataSet={dataSet}
|
|
537
|
+
options={chartOptions}
|
|
538
|
+
type={CarbonChartType.bar}
|
|
539
|
+
isInverse={false}
|
|
540
|
+
/>
|
|
541
|
+
</ThemeContext.Provider>
|
|
542
|
+
);
|
|
543
|
+
|
|
544
|
+
const wrapper = getByTestId(testId);
|
|
545
|
+
|
|
546
|
+
// CarbonChartWrapper applies theme.colors.neutral300 border to modal header
|
|
547
|
+
expect(wrapper).toHaveStyleRule(
|
|
548
|
+
'border-bottom',
|
|
549
|
+
`1px solid ${magma.colors.neutral300}`,
|
|
550
|
+
{
|
|
551
|
+
target: '.chart-holder .cds--modal-header',
|
|
552
|
+
}
|
|
553
|
+
);
|
|
554
|
+
});
|
|
555
|
+
|
|
556
|
+
it('should apply theme.colors.neutral300 border to modal footer in normal mode', () => {
|
|
557
|
+
const testId = 'modal-footer-border-test';
|
|
558
|
+
const { getByTestId } = render(
|
|
559
|
+
<ThemeContext.Provider value={magma}>
|
|
560
|
+
<CarbonChart
|
|
561
|
+
testId={testId}
|
|
562
|
+
dataSet={dataSet}
|
|
563
|
+
options={chartOptions}
|
|
564
|
+
type={CarbonChartType.bar}
|
|
565
|
+
isInverse={false}
|
|
566
|
+
/>
|
|
567
|
+
</ThemeContext.Provider>
|
|
568
|
+
);
|
|
569
|
+
|
|
570
|
+
const wrapper = getByTestId(testId);
|
|
571
|
+
|
|
572
|
+
// CarbonChartWrapper applies theme.colors.neutral300 border to modal footer
|
|
573
|
+
expect(wrapper).toHaveStyleRule(
|
|
574
|
+
'border-top',
|
|
575
|
+
`1px solid ${magma.colors.neutral300}`,
|
|
576
|
+
{
|
|
577
|
+
target: '.cds--modal-footer.cds--modal-footer',
|
|
578
|
+
}
|
|
579
|
+
);
|
|
580
|
+
});
|
|
581
|
+
});
|
|
76
582
|
});
|
|
@@ -21,12 +21,11 @@ import {
|
|
|
21
21
|
ComboChart,
|
|
22
22
|
ChartOptions,
|
|
23
23
|
} from '@carbon/charts-react';
|
|
24
|
-
import { Global } from '@emotion/react';
|
|
25
24
|
import styled from '@emotion/styled';
|
|
26
25
|
import { transparentize } from 'polished';
|
|
27
26
|
import { ThemeInterface, ThemeContext, useIsInverse } from 'react-magma-dom';
|
|
28
27
|
|
|
29
|
-
import
|
|
28
|
+
import './carbon-charts.css';
|
|
30
29
|
|
|
31
30
|
export enum CarbonChartType {
|
|
32
31
|
area = 'area',
|
|
@@ -50,7 +49,7 @@ export enum CarbonChartType {
|
|
|
50
49
|
}
|
|
51
50
|
|
|
52
51
|
export interface CarbonChartProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
53
|
-
dataSet: Array<
|
|
52
|
+
dataSet: Array<Object>;
|
|
54
53
|
isInverse?: boolean;
|
|
55
54
|
/**
|
|
56
55
|
* For a complete list of options, see Carbon Charts documentation
|
|
@@ -221,33 +220,33 @@ const CarbonChartWrapper = styled.div<{
|
|
|
221
220
|
}
|
|
222
221
|
.cds--cc--scatter circle.dot {
|
|
223
222
|
filter: drop-shadow(
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
223
|
+
1px 0px 0px
|
|
224
|
+
${props =>
|
|
225
|
+
props.isInverse
|
|
226
|
+
? props.theme.colors.primary600
|
|
227
|
+
: props.theme.colors.neutral100}
|
|
228
|
+
)
|
|
229
|
+
drop-shadow(
|
|
230
|
+
-1px 0px 0px
|
|
231
|
+
${props =>
|
|
232
|
+
props.isInverse
|
|
233
|
+
? props.theme.colors.primary600
|
|
234
|
+
: props.theme.colors.neutral100}
|
|
235
|
+
)
|
|
236
|
+
drop-shadow(
|
|
237
|
+
0px 1px 0px
|
|
238
|
+
${props =>
|
|
239
|
+
props.isInverse
|
|
240
|
+
? props.theme.colors.primary600
|
|
241
|
+
: props.theme.colors.neutral100}
|
|
242
|
+
)
|
|
243
|
+
drop-shadow(
|
|
244
|
+
0px -1px 0px
|
|
245
|
+
${props =>
|
|
246
|
+
props.isInverse
|
|
247
|
+
? props.theme.colors.primary600
|
|
248
|
+
: props.theme.colors.neutral100}
|
|
249
|
+
);
|
|
251
250
|
}
|
|
252
251
|
.cds--cc--scatter circle.dot.hovered {
|
|
253
252
|
stroke-width: 0.5em;
|
|
@@ -327,22 +326,23 @@ const CarbonChartWrapper = styled.div<{
|
|
|
327
326
|
transition: 0.1s all linear;
|
|
328
327
|
stroke-width: 1.1em;
|
|
329
328
|
}
|
|
330
|
-
|
|
329
|
+
|
|
331
330
|
.cds--cc--tooltip {
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
331
|
+
${props => {
|
|
332
|
+
const chartColors =
|
|
333
|
+
(props.isInverse
|
|
334
|
+
? props.theme.chartColorsInverse
|
|
335
|
+
: props.theme.chartColors) || [];
|
|
337
336
|
|
|
338
|
-
|
|
339
|
-
|
|
337
|
+
return chartColors.reduce((result, color, index) => {
|
|
338
|
+
const indexNum = index + 1;
|
|
340
339
|
|
|
341
|
-
|
|
340
|
+
result += `.tooltip-${props.groupsLength}-1-${indexNum} { background-color: ${color}; }`;
|
|
342
341
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
342
|
+
return result;
|
|
343
|
+
}, '');
|
|
344
|
+
}}
|
|
345
|
+
}
|
|
346
346
|
|
|
347
347
|
.cds--overflow-menu-options__btn:focus {
|
|
348
348
|
outline-color: ${props =>
|
|
@@ -583,7 +583,6 @@ export const CarbonChart = React.forwardRef<HTMLDivElement, CarbonChartProps>(
|
|
|
583
583
|
? allInverseColors[i]
|
|
584
584
|
: allColors[i]);
|
|
585
585
|
}
|
|
586
|
-
|
|
587
586
|
return {};
|
|
588
587
|
});
|
|
589
588
|
|
|
@@ -616,20 +615,17 @@ export const CarbonChart = React.forwardRef<HTMLDivElement, CarbonChartProps>(
|
|
|
616
615
|
const groupsLength = Object.keys(buildColors()).length;
|
|
617
616
|
|
|
618
617
|
return (
|
|
619
|
-
<
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
<ChartType data={dataSet} options={newOptions} />
|
|
631
|
-
</CarbonChartWrapper>
|
|
632
|
-
</React.Fragment>
|
|
618
|
+
<CarbonChartWrapper
|
|
619
|
+
data-testid={testId}
|
|
620
|
+
ref={ref}
|
|
621
|
+
isInverse={isInverse}
|
|
622
|
+
theme={theme}
|
|
623
|
+
className="carbon-chart-wrapper"
|
|
624
|
+
groupsLength={groupsLength < 6 ? groupsLength : 14}
|
|
625
|
+
{...rest}
|
|
626
|
+
>
|
|
627
|
+
<ChartType data={dataSet} options={newOptions} />
|
|
628
|
+
</CarbonChartWrapper>
|
|
633
629
|
);
|
|
634
630
|
}
|
|
635
631
|
);
|