amazing-react-charts 0.7.6 → 0.7.7

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.
@@ -7,6 +7,8 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = exports.TOOLBOX_DEFAULT_PROPS = void 0;
9
9
 
10
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
11
+
10
12
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
13
 
12
14
  var _react = _interopRequireDefault(require("react"));
@@ -140,7 +142,13 @@ var AreaChart = function AreaChart(props) {
140
142
  type: 'line',
141
143
  data: yData,
142
144
  label: {
143
- formatter: typeof yComplement === 'function' ? yComplement : formatLabel,
145
+ formatter: function formatter(item) {
146
+ if (typeof yComplement === 'function' && (0, _typeof2.default)(item) === 'object') {
147
+ return yComplement(item.data);
148
+ }
149
+
150
+ typeof yComplement === 'function' ? yComplement : formatLabel;
151
+ },
144
152
  show: true,
145
153
  position: 'top',
146
154
  fontSize: yType === 'time' ? 10 : 11.5,
@@ -29,7 +29,9 @@ export interface IDefaultChartProps {
29
29
  scrollStart?: number;
30
30
  onClickBar?(itemProps?: Record<string, unknown>, itemFunctions?: Record<string, unknown>): void;
31
31
  }
32
- export declare type Complement = string | ((value: string | number) => string);
32
+ export declare type Complement = string | ((value: string | number | {
33
+ data: number;
34
+ }) => string);
33
35
  declare type ToolboxEntryProps = {
34
36
  saveAsImage?: string;
35
37
  dataView?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "amazing-react-charts",
3
- "version": "0.7.6",
3
+ "version": "0.7.7",
4
4
  "description": "An amazing react charts package based in echarts",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -21,6 +21,7 @@ import {
21
21
  } from './types'
22
22
 
23
23
  const STYLES = { width: '99.9%', height: 300 }
24
+
24
25
  export const TOOLBOX_DEFAULT_PROPS = {
25
26
  showTitle: false,
26
27
  right: '9.52%',
@@ -155,9 +156,17 @@ const AreaChart = (props: IDefaultChartProps) => {
155
156
  type: 'line' as const,
156
157
  data: yData,
157
158
  label: {
158
- formatter: typeof yComplement === 'function'
159
- ? yComplement
160
- : formatLabel,
159
+ formatter: (item: number | string | {data: number}) => {
160
+ if(typeof yComplement === 'function' && typeof item === 'object') {
161
+ return yComplement(item.data)
162
+ }
163
+
164
+
165
+ typeof yComplement === 'function'
166
+ ? yComplement
167
+ : formatLabel
168
+
169
+ },
161
170
  show: true,
162
171
  position: 'top',
163
172
  fontSize: yType === 'time' ? 10 : 11.5,
package/src/core/types.ts CHANGED
@@ -34,7 +34,8 @@ export interface IDefaultChartProps {
34
34
  ): void;
35
35
  }
36
36
 
37
- export type Complement = string | ((value: string | number) => string);
37
+ export type Complement =
38
+ string | ((value: string | number | {data: number}) => string);
38
39
 
39
40
  type ToolboxEntryProps = {
40
41
  saveAsImage?: string;