@react-fabric/chart 1.0.0-beta.54 → 1.0.0-beta.55

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.
@@ -16,6 +16,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
16
16
  var CountSeriesChart = /*#__PURE__*/react.memo(function (_ref) {
17
17
  var _series = _ref.series,
18
18
  title = _ref.title,
19
+ seriesName = _ref.seriesName,
19
20
  onExport = _ref.onExport,
20
21
  chartTheme = _ref.theme,
21
22
  _ref$type = _ref.type,
@@ -48,7 +49,7 @@ var CountSeriesChart = /*#__PURE__*/react.memo(function (_ref) {
48
49
  var sorted = _series === null || _series === void 0 ? void 0 : _series.sort(utilities.compareValues("desc", "count"));
49
50
  var categoryAxis = Object.assign({}, optionOverride === null || optionOverride === void 0 ? void 0 : optionOverride.xAxis, {
50
51
  type: "category",
51
- name: title !== null && title !== void 0 ? title : "Count Series",
52
+ name: seriesName !== null && seriesName !== void 0 ? seriesName : "Count Series",
52
53
  nameLocation: "center",
53
54
  axisTick: {
54
55
  show: false
@@ -65,18 +66,18 @@ var CountSeriesChart = /*#__PURE__*/react.memo(function (_ref) {
65
66
  });
66
67
  var series = type === "pie" ? [{
67
68
  type: "pie",
68
- name: title !== null && title !== void 0 ? title : "Count Series",
69
+ name: seriesName !== null && seriesName !== void 0 ? seriesName : "Count Series",
69
70
  data: sorted.map(function (item, index) {
70
- var _item$label;
71
+ var _item$name;
71
72
  return {
72
73
  id: item.id,
73
74
  value: item.count,
74
- name: (_item$label = item.label) !== null && _item$label !== void 0 ? _item$label : item.id
75
+ name: (_item$name = item.name) !== null && _item$name !== void 0 ? _item$name : item.id
75
76
  };
76
77
  }),
77
78
  universalTransition: true
78
79
  }] : sorted.map(function (item, index) {
79
- var _item$label2;
80
+ var _item$label;
80
81
  return {
81
82
  id: item.id,
82
83
  type: "bar",
@@ -88,10 +89,10 @@ var CountSeriesChart = /*#__PURE__*/react.memo(function (_ref) {
88
89
  color: "#fff"
89
90
  },
90
91
  data: [{
91
- name: title !== null && title !== void 0 ? title : "Count Series",
92
+ name: seriesName !== null && seriesName !== void 0 ? seriesName : "Count Series",
92
93
  value: item.count
93
94
  }],
94
- name: (_item$label2 = item.label) !== null && _item$label2 !== void 0 ? _item$label2 : item.id,
95
+ name: (_item$label = item.label) !== null && _item$label !== void 0 ? _item$label : item.id,
95
96
  universalTransition: true
96
97
  };
97
98
  });
@@ -101,7 +102,7 @@ var CountSeriesChart = /*#__PURE__*/react.memo(function (_ref) {
101
102
  xAxis: type === "pie" ? null : type === "bar" ? valueAxis : categoryAxis,
102
103
  yAxis: type === "pie" ? null : type === "bar" ? categoryAxis : valueAxis
103
104
  });
104
- }, [_series, title, type, optionOverride], "CountChart options");
105
+ }, [_series, name, type, optionOverride], "CountChart options");
105
106
  return /*#__PURE__*/jsxRuntime.jsxs(ChartContainer.ChartContainer, {
106
107
  title: title,
107
108
  onExport: onExport,
@@ -41,8 +41,6 @@ var defaultOptions = {
41
41
  },
42
42
  tooltip: {
43
43
  trigger: "item",
44
- confine: true,
45
- position: "top",
46
44
  appendToBody: true
47
45
  },
48
46
  legend: {
@@ -128,9 +126,11 @@ var ChartContainer = /*#__PURE__*/react.memo(function (_ref2) {
128
126
  return toolboxOptions(dataTableRenderer);
129
127
  }, [dataTableRenderer]);
130
128
  react.useEffect(function () {
131
- chartRef === null || chartRef === void 0 || chartRef.setOption(_objectSpread(_objectSpread({}, defaultOptions), {}, {
129
+ chartRef === null || chartRef === void 0 || chartRef.setOption(_objectSpread(_objectSpread(_objectSpread({}, defaultOptions), {}, {
132
130
  toolbox: toolbox
133
- }, options), true);
131
+ }, options), {}, {
132
+ tooltip: _objectSpread(_objectSpread({}, defaultOptions.tooltip), options.tooltip)
133
+ }), true);
134
134
  }, [options, chartRef]);
135
135
  var handleExport = react.useCallback(function () {
136
136
  var image = chartRef === null || chartRef === void 0 ? void 0 : chartRef.getDataURL({
@@ -145,7 +145,7 @@ var ChartContainer = /*#__PURE__*/react.memo(function (_ref2) {
145
145
  return /*#__PURE__*/jsxRuntime.jsxs(react.Fragment, {
146
146
  children: [/*#__PURE__*/jsxRuntime.jsxs(ChartToolbar.ChartToolbar, {
147
147
  children: [title && /*#__PURE__*/jsxRuntime.jsx(core.Title, {
148
- className: "flex-fill px-2 py-1 text-dimmed",
148
+ className: "flex-1 px-2 py-1 text-dimmed",
149
149
  children: title
150
150
  }), children, onExport && /*#__PURE__*/jsxRuntime.jsx(core.Button, {
151
151
  size: "sm",
@@ -16,6 +16,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
16
16
  var CountSeriesChart = /*#__PURE__*/memo(function (_ref) {
17
17
  var _series = _ref.series,
18
18
  title = _ref.title,
19
+ seriesName = _ref.seriesName,
19
20
  onExport = _ref.onExport,
20
21
  chartTheme = _ref.theme,
21
22
  _ref$type = _ref.type,
@@ -48,7 +49,7 @@ var CountSeriesChart = /*#__PURE__*/memo(function (_ref) {
48
49
  var sorted = _series === null || _series === void 0 ? void 0 : _series.sort(compareValues("desc", "count"));
49
50
  var categoryAxis = Object.assign({}, optionOverride === null || optionOverride === void 0 ? void 0 : optionOverride.xAxis, {
50
51
  type: "category",
51
- name: title !== null && title !== void 0 ? title : "Count Series",
52
+ name: seriesName !== null && seriesName !== void 0 ? seriesName : "Count Series",
52
53
  nameLocation: "center",
53
54
  axisTick: {
54
55
  show: false
@@ -65,18 +66,18 @@ var CountSeriesChart = /*#__PURE__*/memo(function (_ref) {
65
66
  });
66
67
  var series = type === "pie" ? [{
67
68
  type: "pie",
68
- name: title !== null && title !== void 0 ? title : "Count Series",
69
+ name: seriesName !== null && seriesName !== void 0 ? seriesName : "Count Series",
69
70
  data: sorted.map(function (item, index) {
70
- var _item$label;
71
+ var _item$name;
71
72
  return {
72
73
  id: item.id,
73
74
  value: item.count,
74
- name: (_item$label = item.label) !== null && _item$label !== void 0 ? _item$label : item.id
75
+ name: (_item$name = item.name) !== null && _item$name !== void 0 ? _item$name : item.id
75
76
  };
76
77
  }),
77
78
  universalTransition: true
78
79
  }] : sorted.map(function (item, index) {
79
- var _item$label2;
80
+ var _item$label;
80
81
  return {
81
82
  id: item.id,
82
83
  type: "bar",
@@ -88,10 +89,10 @@ var CountSeriesChart = /*#__PURE__*/memo(function (_ref) {
88
89
  color: "#fff"
89
90
  },
90
91
  data: [{
91
- name: title !== null && title !== void 0 ? title : "Count Series",
92
+ name: seriesName !== null && seriesName !== void 0 ? seriesName : "Count Series",
92
93
  value: item.count
93
94
  }],
94
- name: (_item$label2 = item.label) !== null && _item$label2 !== void 0 ? _item$label2 : item.id,
95
+ name: (_item$label = item.label) !== null && _item$label !== void 0 ? _item$label : item.id,
95
96
  universalTransition: true
96
97
  };
97
98
  });
@@ -101,7 +102,7 @@ var CountSeriesChart = /*#__PURE__*/memo(function (_ref) {
101
102
  xAxis: type === "pie" ? null : type === "bar" ? valueAxis : categoryAxis,
102
103
  yAxis: type === "pie" ? null : type === "bar" ? categoryAxis : valueAxis
103
104
  });
104
- }, [_series, title, type, optionOverride], "CountChart options");
105
+ }, [_series, name, type, optionOverride], "CountChart options");
105
106
  return /*#__PURE__*/jsxs(ChartContainer, {
106
107
  title: title,
107
108
  onExport: onExport,
@@ -22,8 +22,6 @@ var defaultOptions = {
22
22
  },
23
23
  tooltip: {
24
24
  trigger: "item",
25
- confine: true,
26
- position: "top",
27
25
  appendToBody: true
28
26
  },
29
27
  legend: {
@@ -109,9 +107,11 @@ var ChartContainer = /*#__PURE__*/memo(function (_ref2) {
109
107
  return toolboxOptions(dataTableRenderer);
110
108
  }, [dataTableRenderer]);
111
109
  useEffect(function () {
112
- chartRef === null || chartRef === void 0 || chartRef.setOption(_objectSpread(_objectSpread({}, defaultOptions), {}, {
110
+ chartRef === null || chartRef === void 0 || chartRef.setOption(_objectSpread(_objectSpread(_objectSpread({}, defaultOptions), {}, {
113
111
  toolbox: toolbox
114
- }, options), true);
112
+ }, options), {}, {
113
+ tooltip: _objectSpread(_objectSpread({}, defaultOptions.tooltip), options.tooltip)
114
+ }), true);
115
115
  }, [options, chartRef]);
116
116
  var handleExport = useCallback(function () {
117
117
  var image = chartRef === null || chartRef === void 0 ? void 0 : chartRef.getDataURL({
@@ -126,7 +126,7 @@ var ChartContainer = /*#__PURE__*/memo(function (_ref2) {
126
126
  return /*#__PURE__*/jsxs(Fragment, {
127
127
  children: [/*#__PURE__*/jsxs(ChartToolbar, {
128
128
  children: [title && /*#__PURE__*/jsx(Title, {
129
- className: "flex-fill px-2 py-1 text-dimmed",
129
+ className: "flex-1 px-2 py-1 text-dimmed",
130
130
  children: title
131
131
  }), children, onExport && /*#__PURE__*/jsx(Button, {
132
132
  size: "sm",
@@ -1,6 +1,7 @@
1
1
  import { type FC } from "react";
2
2
  import { type BaseChart, type CountType } from "../types";
3
3
  export interface CountSeriesProps extends BaseChart, CountType {
4
+ seriesName?: string;
4
5
  type?: "pie" | "bar" | "column";
5
6
  onClick?: (key: string) => void;
6
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-fabric/chart",
3
- "version": "1.0.0-beta.54",
3
+ "version": "1.0.0-beta.55",
4
4
  "description": "RUF: Charting package",
5
5
  "author": "Adarsh Pastakia <adarshpastakia@outlook.com>",
6
6
  "license": "MIT",
@@ -35,7 +35,7 @@
35
35
  "watch": "npm-run-all -p watch:rollup watch:dts"
36
36
  },
37
37
  "dependencies": {
38
- "@react-fabric/core": "^1.0.0-beta.54",
38
+ "@react-fabric/core": "^1.0.0-beta.55",
39
39
  "@react-fabric/utilities": "^1.0.0-beta.52",
40
40
  "classnames": "^2.5.1",
41
41
  "color": "^4.2.3",
@@ -56,5 +56,5 @@
56
56
  "node": ">=18.12.0",
57
57
  "npm": ">=8.19.0"
58
58
  },
59
- "gitHead": "242f15e3de29d365cce6f41f4ef99ab36bb6b995"
59
+ "gitHead": "c8454798fb7546174ee8c7ea10e491c5e903e789"
60
60
  }
@@ -38,6 +38,7 @@ import { ChartWrapper } from "../wrapper/ChartWrapper";
38
38
  import { PaletteSelect } from "../wrapper/PaletteSelect";
39
39
 
40
40
  export interface CountSeriesProps extends BaseChart, CountType {
41
+ seriesName?: string;
41
42
  type?: "pie" | "bar" | "column";
42
43
  onClick?: (key: string) => void;
43
44
  }
@@ -46,6 +47,7 @@ const CountSeriesChart: FC<CountSeriesProps> = memo(
46
47
  ({
47
48
  series: _series,
48
49
  title,
50
+ seriesName,
49
51
  onExport,
50
52
  theme: chartTheme,
51
53
  type: chartType = "pie",
@@ -79,7 +81,7 @@ const CountSeriesChart: FC<CountSeriesProps> = memo(
79
81
  optionOverride?.xAxis,
80
82
  {
81
83
  type: "category",
82
- name: title ?? "Count Series",
84
+ name: seriesName ?? "Count Series",
83
85
  nameLocation: "center",
84
86
  axisTick: {
85
87
  show: false,
@@ -99,11 +101,11 @@ const CountSeriesChart: FC<CountSeriesProps> = memo(
99
101
  ? [
100
102
  {
101
103
  type: "pie",
102
- name: title ?? "Count Series",
104
+ name: seriesName ?? "Count Series",
103
105
  data: sorted.map((item, index) => ({
104
106
  id: item.id,
105
107
  value: item.count,
106
- name: item.label ?? item.id,
108
+ name: item.name ?? item.id,
107
109
  })),
108
110
  universalTransition: true,
109
111
  },
@@ -120,7 +122,7 @@ const CountSeriesChart: FC<CountSeriesProps> = memo(
120
122
  },
121
123
  data: [
122
124
  {
123
- name: title ?? "Count Series",
125
+ name: seriesName ?? "Count Series",
124
126
  value: item.count,
125
127
  },
126
128
  ],
@@ -137,7 +139,7 @@ const CountSeriesChart: FC<CountSeriesProps> = memo(
137
139
  type === "pie" ? null : type === "bar" ? categoryAxis : valueAxis,
138
140
  };
139
141
  },
140
- [_series, title, type, optionOverride],
142
+ [_series, name, type, optionOverride],
141
143
  "CountChart options",
142
144
  );
143
145
 
@@ -56,8 +56,6 @@ const defaultOptions = {
56
56
  },
57
57
  tooltip: {
58
58
  trigger: "item",
59
- confine: true,
60
- position: "top",
61
59
  appendToBody: true,
62
60
  } as AnyObject,
63
61
  legend: {
@@ -165,6 +163,10 @@ export const ChartContainer = memo(
165
163
  ...defaultOptions,
166
164
  toolbox,
167
165
  ...options,
166
+ tooltip: {
167
+ ...defaultOptions.tooltip,
168
+ ...options.tooltip,
169
+ },
168
170
  },
169
171
  true,
170
172
  );
@@ -182,7 +184,7 @@ export const ChartContainer = memo(
182
184
  <Fragment>
183
185
  <ChartToolbar>
184
186
  {title && (
185
- <Title className="flex-fill px-2 py-1 text-dimmed">{title}</Title>
187
+ <Title className="flex-1 px-2 py-1 text-dimmed">{title}</Title>
186
188
  )}
187
189
  {children}
188
190
  {onExport && (