@react-magma/charts 13.0.4-next.0 → 13.1.1-next.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.
- package/dist/charts.js +447 -27
- package/dist/charts.js.map +1 -1
- package/dist/charts.modern.module.js +443 -30
- package/dist/charts.modern.module.js.map +1 -1
- package/dist/charts.umd.js +1608 -228
- package/dist/charts.umd.js.map +1 -1
- package/dist/components/CarbonChart/CarbonChart.d.ts +41 -0
- package/dist/components/ChartTable/ChartDataTable.d.ts +19 -0
- package/dist/components/ChartTable/ChartFullscreenButton.d.ts +26 -0
- package/dist/components/ChartTable/ChartMoreOptionsButton.d.ts +18 -0
- package/dist/components/ChartTable/ChartTable.stories.d.ts +116 -0
- package/dist/components/ChartTable/ChartTable.test.d.ts +1 -0
- package/dist/components/ChartTable/ChartTableButton.d.ts +24 -0
- package/dist/components/ChartTable/ChartTableModal.d.ts +44 -0
- package/dist/components/ChartTable/ChartToolbar.d.ts +19 -0
- package/dist/components/ChartTable/chartToolbarI18n.d.ts +16 -0
- package/dist/components/ChartTable/index.d.ts +14 -0
- package/dist/components/LineChart/DataTable.d.ts +1 -1
- package/dist/index.d.ts +1 -0
- package/package.json +5 -5
- package/src/components/CarbonChart/CarbonChart.test.js +143 -2
- package/src/components/CarbonChart/CarbonChart.tsx +603 -15
- package/src/components/ChartTable/ChartDataTable.tsx +72 -0
- package/src/components/ChartTable/ChartFullscreenButton.tsx +59 -0
- package/src/components/ChartTable/ChartMoreOptionsButton.tsx +47 -0
- package/src/components/ChartTable/ChartTable.stories.tsx +152 -0
- package/src/components/ChartTable/ChartTable.test.tsx +444 -0
- package/src/components/ChartTable/ChartTableButton.tsx +55 -0
- package/src/components/ChartTable/ChartTableModal.tsx +135 -0
- package/src/components/ChartTable/ChartToolbar.tsx +50 -0
- package/src/components/ChartTable/chartToolbarI18n.ts +55 -0
- package/src/components/ChartTable/index.ts +23 -0
- package/src/components/LineChart/DataTable.tsx +3 -3
- package/src/components/LineChart/LineChart.tsx +1 -1
- package/src/index.ts +1 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { I18nContext } from 'react-magma-dom';
|
|
4
|
+
|
|
5
|
+
export interface ChartToolbarI18n {
|
|
6
|
+
defaultTitle: string;
|
|
7
|
+
downloadAsCsv: string;
|
|
8
|
+
downloadAsJpg: string;
|
|
9
|
+
downloadAsPng: string;
|
|
10
|
+
exitFullScreen: string;
|
|
11
|
+
makeFullScreen: string;
|
|
12
|
+
moreOptionsAriaLabel: string;
|
|
13
|
+
showAsTableTooltip: string;
|
|
14
|
+
tabularRepresentationLabel: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const defaults: ChartToolbarI18n = {
|
|
18
|
+
defaultTitle: 'Chart',
|
|
19
|
+
downloadAsCsv: 'Download as CSV',
|
|
20
|
+
downloadAsJpg: 'Download as JPG',
|
|
21
|
+
downloadAsPng: 'Download as PNG',
|
|
22
|
+
exitFullScreen: 'Exit full screen',
|
|
23
|
+
makeFullScreen: 'Make full screen',
|
|
24
|
+
moreOptionsAriaLabel: 'More options',
|
|
25
|
+
showAsTableTooltip: 'Show as table',
|
|
26
|
+
tabularRepresentationLabel: 'Tabular representation',
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Reads chart toolbar i18n strings from the I18nContext if available,
|
|
31
|
+
* falling back to English defaults.
|
|
32
|
+
*/
|
|
33
|
+
// eslint-disable-next-line complexity
|
|
34
|
+
export function useChartToolbarI18n(): ChartToolbarI18n {
|
|
35
|
+
const i18n = React.useContext(I18nContext);
|
|
36
|
+
const toolbar = (i18n.charts as { toolbar?: Partial<ChartToolbarI18n> })
|
|
37
|
+
?.toolbar;
|
|
38
|
+
|
|
39
|
+
if (!toolbar) return defaults;
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
defaultTitle: toolbar.defaultTitle ?? defaults.defaultTitle,
|
|
43
|
+
downloadAsCsv: toolbar.downloadAsCsv ?? defaults.downloadAsCsv,
|
|
44
|
+
downloadAsJpg: toolbar.downloadAsJpg ?? defaults.downloadAsJpg,
|
|
45
|
+
downloadAsPng: toolbar.downloadAsPng ?? defaults.downloadAsPng,
|
|
46
|
+
exitFullScreen: toolbar.exitFullScreen ?? defaults.exitFullScreen,
|
|
47
|
+
makeFullScreen: toolbar.makeFullScreen ?? defaults.makeFullScreen,
|
|
48
|
+
moreOptionsAriaLabel:
|
|
49
|
+
toolbar.moreOptionsAriaLabel ?? defaults.moreOptionsAriaLabel,
|
|
50
|
+
showAsTableTooltip:
|
|
51
|
+
toolbar.showAsTableTooltip ?? defaults.showAsTableTooltip,
|
|
52
|
+
tabularRepresentationLabel:
|
|
53
|
+
toolbar.tabularRepresentationLabel ?? defaults.tabularRepresentationLabel,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export { ChartDataTable } from './ChartDataTable';
|
|
2
|
+
export type {
|
|
3
|
+
ChartDataTableProps,
|
|
4
|
+
ChartDataTableColumn,
|
|
5
|
+
} from './ChartDataTable';
|
|
6
|
+
|
|
7
|
+
export { ChartFullscreenButton } from './ChartFullscreenButton';
|
|
8
|
+
export type { ChartFullscreenButtonProps } from './ChartFullscreenButton';
|
|
9
|
+
|
|
10
|
+
export { ChartMoreOptionsButton } from './ChartMoreOptionsButton';
|
|
11
|
+
export type { ChartMoreOptionsButtonProps } from './ChartMoreOptionsButton';
|
|
12
|
+
|
|
13
|
+
export { ChartTableButton } from './ChartTableButton';
|
|
14
|
+
export type { ChartTableButtonProps } from './ChartTableButton';
|
|
15
|
+
|
|
16
|
+
export { ChartTableModal } from './ChartTableModal';
|
|
17
|
+
export type { ChartTableModalProps } from './ChartTableModal';
|
|
18
|
+
|
|
19
|
+
export { ChartToolbar } from './ChartToolbar';
|
|
20
|
+
export type { ChartToolbarProps } from './ChartToolbar';
|
|
21
|
+
|
|
22
|
+
export { useChartToolbarI18n } from './chartToolbarI18n';
|
|
23
|
+
export type { ChartToolbarI18n } from './chartToolbarI18n';
|
|
@@ -15,7 +15,7 @@ export interface DataTableProps {
|
|
|
15
15
|
data?: any;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
export const DataTable = props => {
|
|
18
|
+
export const DataTable = (props: DataTableProps) => {
|
|
19
19
|
const { data } = props;
|
|
20
20
|
|
|
21
21
|
return (
|
|
@@ -32,8 +32,8 @@ export const DataTable = props => {
|
|
|
32
32
|
</TableRow>
|
|
33
33
|
</TableHead>
|
|
34
34
|
<TableBody>
|
|
35
|
-
{data.map((dataset, i) => (
|
|
36
|
-
<TableRow key={i}>
|
|
35
|
+
{data.map((dataset: any, i: number) => (
|
|
36
|
+
<TableRow key={dataset.label ?? `row-${i}`}>
|
|
37
37
|
<TableHeaderCell
|
|
38
38
|
scope={TableHeaderCellScope.row}
|
|
39
39
|
style={{
|
|
@@ -653,7 +653,7 @@ export function LineChart<T>(props: LineChartProps<T>) {
|
|
|
653
653
|
color={theme.iterableColors[i]}
|
|
654
654
|
dataIndex={i}
|
|
655
655
|
isHidden={hiddenData.includes(i)}
|
|
656
|
-
key={
|
|
656
|
+
key={name}
|
|
657
657
|
name={name}
|
|
658
658
|
onClick={handleLegendClick}
|
|
659
659
|
onKeyDown={i === 0 ? handleFirstLegendButtonKeydown : undefined}
|
package/src/index.ts
CHANGED