@react-magma/charts 12.0.0-next.3 → 12.0.0-next.5

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.
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
+ import { ChartOptions } from '@carbon/charts-react';
2
3
  import { ThemeInterface } from 'react-magma-dom';
3
- import './styles.min.css';
4
4
  export declare enum CarbonChartType {
5
5
  area = "area",
6
6
  areaStacked = "areaStacked",
@@ -27,7 +27,7 @@ export interface CarbonChartProps extends React.HTMLAttributes<HTMLDivElement> {
27
27
  /**
28
28
  * For a complete list of options, see Carbon Charts documentation
29
29
  */
30
- options: Object;
30
+ options: ChartOptions;
31
31
  testId?: string;
32
32
  /**
33
33
  * @internal
@@ -0,0 +1 @@
1
+ export declare const carbonChartStyles: import("@emotion/react").SerializedStyles;
package/package.json CHANGED
@@ -1,10 +1,13 @@
1
1
  {
2
2
  "name": "@react-magma/charts",
3
- "version": "12.0.0-next.3",
3
+ "version": "12.0.0-next.5",
4
4
  "license": "MIT",
5
5
  "exports": {
6
- ".": "./src",
7
- "./src/components/CarbonChart/": "./styles.min.css"
6
+ ".": {
7
+ "import": "./dist/charts.modern.module.js",
8
+ "require": "./dist/charts.js",
9
+ "types": "./dist/index.d.ts"
10
+ }
8
11
  },
9
12
  "main": "dist/charts.js",
10
13
  "umd:main": "dist/charts.umd.js",
@@ -13,12 +16,11 @@
13
16
  "types": "dist/index.d.ts",
14
17
  "files": [
15
18
  "dist",
16
- "src",
17
- "src/components/CarbonChart/styles.min.css"
19
+ "src"
18
20
  ],
19
21
  "scripts": {
20
- "build": "microbundle build --jsx jsx --jsxImportSource react --globals react/jsx-runtime=jsx",
21
- "build-watch": "microbundle watch --jsx jsx --jsxImportSource react --globals react/jsx-runtime=jsx",
22
+ "build": "microbundle build --jsx jsx --jsxImportSource react --globals react/jsx-runtime=jsx,@emotion/react=EmotionReact,@emotion/styled=EmotionStyled,@carbon/charts-react=CarbonChartsReact",
23
+ "build-watch": "microbundle watch --jsx jsx --jsxImportSource react --globals react/jsx-runtime=jsx,@emotion/react=EmotionReact,@emotion/styled=EmotionStyled,@carbon/charts-react=CarbonChartsReact",
22
24
  "lint": "eslint ./src",
23
25
  "test": "jest",
24
26
  "test-watch": "jest --watch"
@@ -28,7 +30,7 @@
28
30
  "d3": "^7.9.0",
29
31
  "d3-cloud": "^1.2.7",
30
32
  "d3-sankey": "^0.12.3",
31
- "victory": "^35.4.12"
33
+ "victory": "^37.3.6"
32
34
  },
33
35
  "devDependencies": {
34
36
  "@emotion/react": "^11.13.0",
@@ -37,7 +39,7 @@
37
39
  "identity-obj-proxy": "^3.0.0",
38
40
  "react": "^17.0.2",
39
41
  "react-dom": "^17.0.2",
40
- "react-magma-dom": "^4.10.0-next.3",
42
+ "react-magma-dom": "^4.10.0-next.29",
41
43
  "react-magma-icons": "^3.2.0"
42
44
  },
43
45
  "peerDependencies": {
@@ -19,11 +19,14 @@ import {
19
19
  MeterChart,
20
20
  ScatterChart,
21
21
  ComboChart,
22
+ ChartOptions,
22
23
  } from '@carbon/charts-react';
24
+ import { Global } from '@emotion/react';
23
25
  import styled from '@emotion/styled';
24
26
  import { transparentize } from 'polished';
25
27
  import { ThemeInterface, ThemeContext, useIsInverse } from 'react-magma-dom';
26
- import './styles.min.css';
28
+
29
+ import { carbonChartStyles } from './embeddedStyles';
27
30
 
28
31
  export enum CarbonChartType {
29
32
  area = 'area',
@@ -52,7 +55,7 @@ export interface CarbonChartProps extends React.HTMLAttributes<HTMLDivElement> {
52
55
  /**
53
56
  * For a complete list of options, see Carbon Charts documentation
54
57
  */
55
- options: Object;
58
+ options: ChartOptions;
56
59
  testId?: string;
57
60
  /**
58
61
  * @internal
@@ -559,6 +562,7 @@ export const CarbonChart = React.forwardRef<HTMLDivElement, CarbonChartProps>(
559
562
  scale: buildColors(),
560
563
  },
561
564
  tooltip: {
565
+ ...(options?.tooltip || {}),
562
566
  truncation: {
563
567
  type: 'none',
564
568
  },
@@ -577,17 +581,20 @@ export const CarbonChart = React.forwardRef<HTMLDivElement, CarbonChartProps>(
577
581
  const groupsLength = Object.keys(buildColors()).length;
578
582
 
579
583
  return (
580
- <CarbonChartWrapper
581
- data-testid={testId}
582
- ref={ref}
583
- isInverse={isInverse}
584
- theme={theme}
585
- className="carbon-chart-wrapper"
586
- groupsLength={groupsLength < 6 ? groupsLength : 14}
587
- {...rest}
588
- >
589
- <ChartType data={dataSet} options={newOptions} />
590
- </CarbonChartWrapper>
584
+ <>
585
+ <Global styles={carbonChartStyles} />
586
+ <CarbonChartWrapper
587
+ data-testid={testId}
588
+ ref={ref}
589
+ isInverse={isInverse}
590
+ theme={theme}
591
+ className="carbon-chart-wrapper"
592
+ groupsLength={groupsLength < 6 ? groupsLength : 14}
593
+ {...rest}
594
+ >
595
+ <ChartType data={dataSet} options={newOptions} />
596
+ </CarbonChartWrapper>
597
+ </>
591
598
  );
592
599
  }
593
600
  );
@@ -67,6 +67,16 @@ VerticalSimpleBarDiscrete.args = {
67
67
  },
68
68
  },
69
69
  height: '400px',
70
+ tooltip: {
71
+ valueFormatter: (value /*, label */) =>
72
+ typeof value === 'number'
73
+ ? value.toLocaleString(undefined, {
74
+ minimumFractionDigits: 20,
75
+ maximumFractionDigits: 20,
76
+ })
77
+ : String(value),
78
+ enabled: false,
79
+ },
70
80
  },
71
81
  };
72
82