@react-fabric/chart 1.0.0-beta.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 (88) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +10 -0
  3. package/dist/cjs/charts/ActivityMap.js +183 -0
  4. package/dist/cjs/charts/CountSeries.js +156 -0
  5. package/dist/cjs/charts/DataSeries.js +185 -0
  6. package/dist/cjs/charts/Generic.js +90 -0
  7. package/dist/cjs/charts/MapSeries.js +215 -0
  8. package/dist/cjs/charts/TimeSeries.js +213 -0
  9. package/dist/cjs/charts/TimeSlider.js +194 -0
  10. package/dist/cjs/charts/WordBubble.js +80 -0
  11. package/dist/cjs/index.js +23 -0
  12. package/dist/cjs/theme/darkBase.js +418 -0
  13. package/dist/cjs/theme/index.js +98 -0
  14. package/dist/cjs/theme/lightBase.js +415 -0
  15. package/dist/cjs/theme/palettes.js +113 -0
  16. package/dist/cjs/types/charts.js +56 -0
  17. package/dist/cjs/types/utils.js +104 -0
  18. package/dist/cjs/types/world.svg.js +5 -0
  19. package/dist/cjs/wrapper/Chart.module.css +1 -0
  20. package/dist/cjs/wrapper/ChartContainer.js +171 -0
  21. package/dist/cjs/wrapper/ChartToolbar.js +38 -0
  22. package/dist/cjs/wrapper/ChartWrapper.js +57 -0
  23. package/dist/cjs/wrapper/PaletteSelect.js +146 -0
  24. package/dist/esm/charts/ActivityMap.js +183 -0
  25. package/dist/esm/charts/CountSeries.js +156 -0
  26. package/dist/esm/charts/DataSeries.js +185 -0
  27. package/dist/esm/charts/Generic.js +90 -0
  28. package/dist/esm/charts/MapSeries.js +196 -0
  29. package/dist/esm/charts/TimeSeries.js +213 -0
  30. package/dist/esm/charts/TimeSlider.js +194 -0
  31. package/dist/esm/charts/WordBubble.js +80 -0
  32. package/dist/esm/index.js +11 -0
  33. package/dist/esm/theme/darkBase.js +418 -0
  34. package/dist/esm/theme/index.js +97 -0
  35. package/dist/esm/theme/lightBase.js +415 -0
  36. package/dist/esm/theme/palettes.js +113 -0
  37. package/dist/esm/types/charts.js +35 -0
  38. package/dist/esm/types/utils.js +101 -0
  39. package/dist/esm/types/world.svg.js +5 -0
  40. package/dist/esm/wrapper/Chart.module.css +1 -0
  41. package/dist/esm/wrapper/ChartContainer.js +152 -0
  42. package/dist/esm/wrapper/ChartToolbar.js +38 -0
  43. package/dist/esm/wrapper/ChartWrapper.js +57 -0
  44. package/dist/esm/wrapper/PaletteSelect.js +146 -0
  45. package/dist/types/charts/ActivityMap.d.ts +21 -0
  46. package/dist/types/charts/CountSeries.d.ts +10 -0
  47. package/dist/types/charts/DataSeries.d.ts +13 -0
  48. package/dist/types/charts/Generic.d.ts +56 -0
  49. package/dist/types/charts/MapSeries.d.ts +9 -0
  50. package/dist/types/charts/TimeSeries.d.ts +17 -0
  51. package/dist/types/charts/TimeSlider.d.ts +16 -0
  52. package/dist/types/charts/WordBubble.d.ts +9 -0
  53. package/dist/types/index.d.ts +9 -0
  54. package/dist/types/theme/darkBase.d.ts +391 -0
  55. package/dist/types/theme/index.d.ts +2 -0
  56. package/dist/types/theme/lightBase.d.ts +388 -0
  57. package/dist/types/theme/palettes.d.ts +45 -0
  58. package/dist/types/types/charts.d.ts +3 -0
  59. package/dist/types/types/index.d.ts +36 -0
  60. package/dist/types/types/utils.d.ts +4 -0
  61. package/dist/types/types/world.svg.d.ts +2 -0
  62. package/dist/types/wrapper/ChartContainer.d.ts +20 -0
  63. package/dist/types/wrapper/ChartToolbar.d.ts +3 -0
  64. package/dist/types/wrapper/ChartWrapper.d.ts +5 -0
  65. package/dist/types/wrapper/PaletteSelect.d.ts +1 -0
  66. package/package.json +58 -0
  67. package/src/charts/ActivityMap.tsx +295 -0
  68. package/src/charts/CountSeries.tsx +186 -0
  69. package/src/charts/DataSeries.tsx +228 -0
  70. package/src/charts/Generic.tsx +190 -0
  71. package/src/charts/MapSeries.tsx +217 -0
  72. package/src/charts/TimeSeries.tsx +236 -0
  73. package/src/charts/TimeSlider.tsx +235 -0
  74. package/src/charts/WordBubble.tsx +105 -0
  75. package/src/index.ts +32 -0
  76. package/src/theme/darkBase.ts +400 -0
  77. package/src/theme/index.ts +122 -0
  78. package/src/theme/lightBase.ts +397 -0
  79. package/src/theme/palettes.ts +589 -0
  80. package/src/types/charts.ts +32 -0
  81. package/src/types/index.ts +61 -0
  82. package/src/types/utils.ts +151 -0
  83. package/src/types/world.svg.ts +467 -0
  84. package/src/wrapper/Chart.module.css +90 -0
  85. package/src/wrapper/ChartContainer.tsx +217 -0
  86. package/src/wrapper/ChartToolbar.tsx +40 -0
  87. package/src/wrapper/ChartWrapper.tsx +46 -0
  88. package/src/wrapper/PaletteSelect.tsx +139 -0
@@ -0,0 +1,38 @@
1
+ 'use client';
2
+
3
+ import classNames from 'classnames';
4
+ import classes from './Chart.module.css';
5
+ import { jsx } from 'react/jsx-runtime';
6
+
7
+ /*
8
+ * React Fabric
9
+ * @version: 1.0.0
10
+ *
11
+ *
12
+ * The MIT License (MIT)
13
+ * Copyright (c) 2024 Adarsh Pastakia
14
+ *
15
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
16
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
17
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
18
+ * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
19
+ * subject to the following conditions:
20
+ *
21
+ * The above copyright notice and this permission notice shall be included in all copies or substantial
22
+ * portions of the Software.
23
+ *
24
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
25
+ * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
27
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
+ */
29
+
30
+ var ChartToolbar = function ChartToolbar(_ref) {
31
+ var children = _ref.children;
32
+ return /*#__PURE__*/jsx("div", {
33
+ className: classNames("flex flex-nowrap items-center justify-end bg-base area-head", classes.chartToolbar),
34
+ children: children
35
+ });
36
+ };
37
+
38
+ export { ChartToolbar };
@@ -0,0 +1,57 @@
1
+ 'use client';
2
+
3
+ import { ErrorBoundary } from '@react-fabric/core';
4
+ import 'echarts-wordcloud';
5
+ import { jsx, jsxs } from 'react/jsx-runtime';
6
+
7
+ /*
8
+ * React Fabric
9
+ * @version: 1.0.0
10
+ *
11
+ *
12
+ * The MIT License (MIT)
13
+ * Copyright (c) 2024 Adarsh Pastakia
14
+ *
15
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
16
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
17
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
18
+ * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
19
+ * subject to the following conditions:
20
+ *
21
+ * The above copyright notice and this permission notice shall be included in all copies or substantial
22
+ * portions of the Software.
23
+ *
24
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
25
+ * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
27
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
+ */
29
+
30
+ var Error = function Error(_ref) {
31
+ var _ref$error = _ref.error,
32
+ error = _ref$error === void 0 ? "" : _ref$error;
33
+ return /*#__PURE__*/jsxs("div", {
34
+ className: "text-sm",
35
+ children: [/*#__PURE__*/jsx("span", {
36
+ className: "bg-danger text-white py-1 px-2 mx-2 rounded",
37
+ children: "Error"
38
+ }), /*#__PURE__*/jsx("span", {
39
+ children: error
40
+ })]
41
+ });
42
+ };
43
+ var ChartWrapper = function ChartWrapper(_ref2) {
44
+ var children = _ref2.children;
45
+ return /*#__PURE__*/jsx("div", {
46
+ className: "grid overflow-hidden area-content relative",
47
+ style: {
48
+ gridTemplate: "\"head\" auto \"content\" 1fr / 1fr"
49
+ },
50
+ children: /*#__PURE__*/jsx(ErrorBoundary, {
51
+ errorElement: Error,
52
+ children: children
53
+ })
54
+ });
55
+ };
56
+
57
+ export { ChartWrapper };
@@ -0,0 +1,146 @@
1
+ 'use client';
2
+
3
+ import { Dropdown, Button, CoreIcons, Menu, MenuItem } from '@react-fabric/core';
4
+ import { ChartPalette } from '../theme/palettes.js';
5
+ import { jsxs, jsx } from 'react/jsx-runtime';
6
+
7
+ /*
8
+ * React Fabric
9
+ * @version: 1.0.0
10
+ *
11
+ *
12
+ * The MIT License (MIT)
13
+ * Copyright (c) 2024 Adarsh Pastakia
14
+ *
15
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
16
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
17
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
18
+ * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
19
+ * subject to the following conditions:
20
+ *
21
+ * The above copyright notice and this permission notice shall be included in all copies or substantial
22
+ * portions of the Software.
23
+ *
24
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
25
+ * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
27
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
+ */
29
+
30
+ var PaletteMap = function PaletteMap(_ref) {
31
+ var _ref$colors = _ref.colors,
32
+ colors = _ref$colors === void 0 ? [] : _ref$colors,
33
+ _ref$label = _ref.label,
34
+ label = _ref$label === void 0 ? "" : _ref$label;
35
+ return /*#__PURE__*/jsxs("div", {
36
+ className: "flex items-center",
37
+ children: [colors.slice(0, 8).map(function (c) {
38
+ return /*#__PURE__*/jsx("div", {
39
+ className: "inline-block rounded-full outline w-3 h-3 mx-px",
40
+ style: {
41
+ backgroundColor: c
42
+ }
43
+ }, c);
44
+ }), /*#__PURE__*/jsx("div", {
45
+ className: "text-xs text-muted px-2",
46
+ children: label
47
+ })]
48
+ });
49
+ };
50
+ var PaletteSelect = function PaletteSelect(_ref2) {
51
+ var onClick = _ref2.onClick,
52
+ _ref2$theme = _ref2.theme,
53
+ theme = _ref2$theme === void 0 ? "default" : _ref2$theme,
54
+ _ref2$defaultTheme = _ref2.defaultTheme,
55
+ defaultTheme = _ref2$defaultTheme === void 0 ? "default" : _ref2$defaultTheme;
56
+ return /*#__PURE__*/jsxs(Dropdown, {
57
+ children: [/*#__PURE__*/jsx(Button, {
58
+ icon: CoreIcons.palette,
59
+ "aria-label": "palette",
60
+ size: "sm",
61
+ variant: "link"
62
+ }), /*#__PURE__*/jsxs(Menu, {
63
+ onClick: onClick,
64
+ children: [/*#__PURE__*/jsx(MenuItem, {
65
+ id: defaultTheme,
66
+ icon: theme === defaultTheme ? "◉" : "◯",
67
+ label: PaletteMap({
68
+ label: "Default",
69
+ colors: ChartPalette.Default
70
+ })
71
+ }), /*#__PURE__*/jsx(MenuItem, {
72
+ id: "qualitative",
73
+ icon: theme === "qualitative" ? "◉" : "◯",
74
+ label: PaletteMap({
75
+ label: "Qualitative",
76
+ colors: ChartPalette.Qualitative
77
+ })
78
+ }), /*#__PURE__*/jsx(MenuItem, {
79
+ id: "diverging",
80
+ icon: theme === "diverging" ? "◉" : "◯",
81
+ label: PaletteMap({
82
+ label: "Diverging",
83
+ colors: ChartPalette.Diverging
84
+ })
85
+ }), /*#__PURE__*/jsx(MenuItem, {
86
+ id: "sequential",
87
+ icon: theme === "sequential" ? "◉" : "◯",
88
+ label: PaletteMap({
89
+ label: "Sequential",
90
+ colors: ChartPalette.Sequential
91
+ })
92
+ }), /*#__PURE__*/jsx(MenuItem, {
93
+ id: "spectral",
94
+ icon: theme === "spectral" ? "◉" : "◯",
95
+ label: PaletteMap({
96
+ label: "Spectral",
97
+ colors: ChartPalette.Spectral
98
+ })
99
+ }), /*#__PURE__*/jsx(MenuItem, {
100
+ id: "uber",
101
+ icon: theme === "uber" ? "◉" : "◯",
102
+ label: PaletteMap({
103
+ label: "Uber Pool",
104
+ colors: ChartPalette.UberPool
105
+ })
106
+ }), /*#__PURE__*/jsx(MenuItem, {
107
+ id: "fireice",
108
+ icon: theme === "fireice" ? "◉" : "◯",
109
+ label: PaletteMap({
110
+ label: "Fire Ice",
111
+ colors: ChartPalette.FireIce
112
+ })
113
+ }), /*#__PURE__*/jsx(MenuItem, {
114
+ id: "warming",
115
+ icon: theme === "warming" ? "◉" : "◯",
116
+ label: PaletteMap({
117
+ label: "Global Warming",
118
+ colors: ChartPalette.GlobalWarming
119
+ })
120
+ }), /*#__PURE__*/jsx(MenuItem, {
121
+ id: "sunrise",
122
+ icon: theme === "sunrise" ? "◉" : "◯",
123
+ label: PaletteMap({
124
+ label: "Sunrise",
125
+ colors: ChartPalette.Sunrise
126
+ })
127
+ }), /*#__PURE__*/jsx(MenuItem, {
128
+ id: "ocean",
129
+ icon: theme === "ocean" ? "◉" : "◯",
130
+ label: PaletteMap({
131
+ label: "Ocean",
132
+ colors: ChartPalette.Ocean
133
+ })
134
+ }), /*#__PURE__*/jsx(MenuItem, {
135
+ id: "wine",
136
+ icon: theme === "wine" ? "◉" : "◯",
137
+ label: PaletteMap({
138
+ label: "Wine",
139
+ colors: ChartPalette.Wine
140
+ })
141
+ })]
142
+ })]
143
+ });
144
+ };
145
+
146
+ export { PaletteSelect };
@@ -0,0 +1,21 @@
1
+ import { type FC } from "react";
2
+ import { type BaseChart } from "../types";
3
+ export interface ActivityMapProps extends BaseChart {
4
+ heatmapPalette?: string[];
5
+ data: Array<Array<[low: number, high: number, count: number]>>;
6
+ time?: "day-hour" | "month-day";
7
+ type?: "scatter" | "heatmap";
8
+ /**
9
+ * day/month names
10
+ */
11
+ highLabels?: string[];
12
+ /**
13
+ * hours/day names
14
+ */
15
+ lowLabels?: string[];
16
+ onClick?: (highIndex: number, lowIndex: number) => void;
17
+ }
18
+ /**
19
+ * Chart showing activity map
20
+ */
21
+ export declare const ActivityMap: FC<ActivityMapProps>;
@@ -0,0 +1,10 @@
1
+ import { type FC } from "react";
2
+ import { type BaseChart, type CountType } from "../types";
3
+ export interface CountSeriesProps extends BaseChart, CountType {
4
+ type?: "pie" | "bar" | "column";
5
+ onClick?: (key: string) => void;
6
+ }
7
+ /**
8
+ * Chart to display simple data count series
9
+ */
10
+ export declare const CountSeries: FC<CountSeriesProps>;
@@ -0,0 +1,13 @@
1
+ import { type FC } from "react";
2
+ import { type BaseChart, type SeriesType } from "../types";
3
+ export interface DataSeriesProps extends BaseChart, SeriesType {
4
+ type?: "column" | "line" | "bar" | "radar" | "line-stacked" | "column-stacked" | "bar-stacked";
5
+ onClick?: (data: {
6
+ category: string;
7
+ series: string;
8
+ }) => void;
9
+ }
10
+ /**
11
+ * Chart to display simple data category series
12
+ */
13
+ export declare const DataSeries: FC<DataSeriesProps>;
@@ -0,0 +1,56 @@
1
+ import { type EChartOption, type EChartsType } from "echarts";
2
+ import { type FC, type RefObject } from "react";
3
+ import { type BaseChart } from "../types";
4
+ export interface GenericProps extends BaseChart {
5
+ chartRef?: RefObject<EChartsType>;
6
+ legend?: EChartOption["legend"];
7
+ toolbox?: EChartOption["toolbox"];
8
+ tooltip?: EChartOption["tooltip"];
9
+ actions?: JSX.Element;
10
+ /**
11
+ * 2d axis
12
+ */
13
+ xAxis?: EChartOption["xAxis"];
14
+ /**
15
+ * 2d axis
16
+ */
17
+ yAxis?: EChartOption["yAxis"];
18
+ /**
19
+ * chart series
20
+ */
21
+ series?: EChartOption["series"];
22
+ /**
23
+ * polar series
24
+ */
25
+ polar?: EChartOption["polar"];
26
+ /**
27
+ * polar axis
28
+ */
29
+ angleAxis?: EChartOption["angleAxis"];
30
+ /**
31
+ * polar axis
32
+ */
33
+ radiusAxis?: EChartOption["radiusAxis"];
34
+ /**
35
+ * radar series
36
+ */
37
+ radar?: EChartOption["radar"];
38
+ /**
39
+ * paarllel series
40
+ */
41
+ parallel?: EChartOption["parallel"];
42
+ /**
43
+ * parallel axis
44
+ */
45
+ parallelAxis?: EChartOption["parallelAxis"];
46
+ onClick?: (e: KeyValue) => void;
47
+ onRendered?: (e: KeyValue) => void;
48
+ onBrush?: (e: KeyValue) => void;
49
+ onBrushEnd?: (e: KeyValue) => void;
50
+ onBrushSelected?: (e: KeyValue) => void;
51
+ /**
52
+ * Data table renderer that returns HTML string
53
+ */
54
+ dataTableRenderer?: (chartOption: EChartOption) => string;
55
+ }
56
+ export declare const GenericChart: FC<GenericProps>;
@@ -0,0 +1,9 @@
1
+ import { type FC } from "react";
2
+ import { type BaseChart, type CountType } from "../types";
3
+ export interface MapSeriesProps extends BaseChart, CountType {
4
+ onClick?: (key: string) => void;
5
+ }
6
+ /**
7
+ * Chart to display simple map data series
8
+ */
9
+ export declare const MapSeries: FC<MapSeriesProps>;
@@ -0,0 +1,17 @@
1
+ import { type FC } from "react";
2
+ import { type BaseChart, type TimeSeriesType } from "../types";
3
+ export interface TimeSeriesProps extends BaseChart, TimeSeriesType {
4
+ type?: "line" | "column" | "line-stacked" | "column-stacked";
5
+ onClick?: (data: {
6
+ category: string;
7
+ series: string;
8
+ }) => void;
9
+ onBrush?: (range: {
10
+ start: Date;
11
+ end: Date;
12
+ }) => void;
13
+ }
14
+ /**
15
+ * Chart to display simple data time series
16
+ */
17
+ export declare const TimeSeries: FC<TimeSeriesProps>;
@@ -0,0 +1,16 @@
1
+ import { type FC } from "react";
2
+ import { type BaseChart } from "../types";
3
+ export interface TimeSliderProps extends BaseChart {
4
+ data: Array<[Date, number]>;
5
+ range?: {
6
+ start: Date;
7
+ end: Date;
8
+ };
9
+ onBrush?: (range: {
10
+ start: Date;
11
+ end: Date;
12
+ }) => void;
13
+ }
14
+ /**
15
+ * Chart to display time scale data with zoom and brush */
16
+ export declare const TimeSlider: FC<TimeSliderProps>;
@@ -0,0 +1,9 @@
1
+ import { type FC } from "react";
2
+ import { type BaseChart, type CountType } from "../types";
3
+ export interface WordBubbleProps extends Omit<BaseChart, "theme">, CountType {
4
+ onClick?: (key: string) => void;
5
+ }
6
+ /**
7
+ * Chart to display simple word cloud
8
+ */
9
+ export declare const WordBubble: FC<WordBubbleProps>;
@@ -0,0 +1,9 @@
1
+ export { ActivityMap } from "./charts/ActivityMap";
2
+ export { CountSeries } from "./charts/CountSeries";
3
+ export { DataSeries } from "./charts/DataSeries";
4
+ export { GenericChart } from "./charts/Generic";
5
+ export { MapSeries } from "./charts/MapSeries";
6
+ export { TimeSeries } from "./charts/TimeSeries";
7
+ export { TimeSlider } from "./charts/TimeSlider";
8
+ export { WordBubble } from "./charts/WordBubble";
9
+ export { registerTheme } from "./types/charts";