@zgfe/business-lib 1.1.72-beta.0 → 1.1.72-beta.1

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.
@@ -23,6 +23,9 @@ export declare namespace ChartTypes {
23
23
  xAxis: Array<string>;
24
24
  x_axis?: Array<string>;
25
25
  series: Array<ChartItmProps>;
26
+ resultFormatMap?: {
27
+ [key: string]: string;
28
+ };
26
29
  }
27
30
  interface Props {
28
31
  type?: 'bar' | 'pie' | 'line' | 'map';
@@ -170,7 +170,9 @@ export var getChartOption = function getChartOption(chartType, data) {
170
170
  }
171
171
  tooltip.axisPointer = tooltip.axisPointer || {};
172
172
  tooltip.axisPointer.type = chartType === 'bar' ? 'shadow' : 'line';
173
- tooltip.formatter = tooltipFormatter ? tooltipFormatter : tooltipFormatterDefault;
173
+ tooltip.formatter = function (params) {
174
+ return tooltipFormatter ? tooltipFormatter(params) : tooltipFormatterDefault(params, data.resultFormatMap);
175
+ };
174
176
  if (legendPosition === 'top') {
175
177
  grid.top = series.length > 1 || series.length > 0 && series[0].name ? 45 : 10;
176
178
  } else if (legendPosition === 'bottom') {
@@ -9,4 +9,7 @@ export declare const formatPieData: (data: ChartTypes.Value, showAll?: boolean,
9
9
  export declare const formatChartData: (data: ChartTypes.Value, showAll?: boolean, showList?: Array<any>, reverseXAxis?: boolean, color?: string[]) => {
10
10
  xAxis: string[];
11
11
  series: any;
12
+ resultFormatMap: {
13
+ [key: string]: string;
14
+ };
12
15
  };
@@ -33,9 +33,13 @@ export var formatChartData = function formatChartData(data, showAll, showList, r
33
33
  var xAxisData = data.xAxis || data.x_axis;
34
34
  var xAxis = reverseXAxis && data.series.length ? [] : xAxisData;
35
35
  var sData = [];
36
+ var resultFormatMap = {};
36
37
  var colorData = color || chartColors;
37
38
  data.series.forEach(function (seriesItem) {
38
39
  var name = seriesItem.names.join(',');
40
+ if (seriesItem.resultFormat && !resultFormatMap[name]) {
41
+ resultFormatMap[name] = seriesItem.resultFormat;
42
+ }
39
43
  if (showAll || showList && showMap[name] || !showList && sData.length < 10) {
40
44
  if (reverseXAxis) {
41
45
  xAxis.push(name);
@@ -59,7 +63,8 @@ export var formatChartData = function formatChartData(data, showAll, showList, r
59
63
  });
60
64
  return {
61
65
  xAxis: xAxis,
62
- series: sData
66
+ series: sData,
67
+ resultFormatMap: resultFormatMap
63
68
  };
64
69
  };
65
70
  var getShowMap = function getShowMap(showList) {
@@ -1,4 +1,6 @@
1
- declare const tooltipFormatterDefault: (params: any) => string;
1
+ declare const tooltipFormatterDefault: (params: any, resultFormatMap?: {
2
+ [key: string]: string;
3
+ } | undefined) => string;
2
4
  declare const yAxisFormatterDefault: (value: number) => string;
3
5
  declare const xAxisFormatterDefault: (value: string) => string;
4
6
  declare const mapTooltipFormatter: (params: any) => string | undefined;
@@ -1,6 +1,6 @@
1
1
  import util from '../../utils/util';
2
2
  var maxLength = 20;
3
- var tooltipFormatterDefault = function tooltipFormatterDefault(params) {
3
+ var tooltipFormatterDefault = function tooltipFormatterDefault(params, resultFormatMap) {
4
4
  var xDate = params[0].name;
5
5
  var xLabel = xDate;
6
6
  var lengthReg = new RegExp('\\S{1,' + maxLength + '}', 'g');
@@ -18,6 +18,8 @@ var tooltipFormatterDefault = function tooltipFormatterDefault(params) {
18
18
  var lineLabel = item.value;
19
19
  if (item.seriesName.indexOf('CTR') > -1) {
20
20
  lineLabel += '%';
21
+ } else if (resultFormatMap && resultFormatMap[item.seriesName] && /percent/.test(resultFormatMap[item.seriesName])) {
22
+ lineLabel = util.toThousands(lineLabel) + '%';
21
23
  } else {
22
24
  lineLabel = util.toThousands(lineLabel);
23
25
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zgfe/business-lib",
3
- "version": "1.1.72-beta.0",
3
+ "version": "1.1.72-beta.1",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -58,5 +58,5 @@
58
58
  "react": "^16.12.0 || ^17.0.0",
59
59
  "yorkie": "^2.0.0"
60
60
  },
61
- "gitHead": "7fe3a264456eb515e4cfa777b160d09df8eb41fe"
61
+ "gitHead": "15e0d81feda4142c22299096a50cbaa49a882fd6"
62
62
  }