@zgfe/business-lib 1.0.0-beta.1 → 1.0.0-beta.4
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/es/analysisLayout/demo/index.js +1 -1
- package/es/analysisLayout/index.d.ts +28 -0
- package/es/analysisLayout/index.js +4 -5
- package/es/analysisLayout/index.less +10 -4
- package/es/assets/iconfont/iconfont.css +123 -0
- package/es/assets/iconfont/iconfont.js +46 -0
- package/es/assets/iconfont/iconfont.json +198 -0
- package/es/assets/iconfont/iconfont.ttf +0 -0
- package/es/assets/iconfont/iconfont.woff +0 -0
- package/es/assets/iconfont/iconfont.woff2 +0 -0
- package/es/attributeSelector/demo/multi.js +1 -1
- package/es/attributeSelector/demo/multiForm.js +1 -1
- package/es/attributeSelector/demo/single.js +1 -1
- package/es/attributeSelector/demo/singleForm.js +1 -1
- package/es/attributeSelector/group.js +1 -1
- package/es/attributeSelector/index.js +2 -1
- package/es/attributeSelector/index.less +2 -2
- package/es/chart/demo/bar.js +7 -12
- package/es/chart/demo/data/data.d.ts +8 -0
- package/es/chart/demo/data/data.js +28 -0
- package/es/chart/demo/data/data2.d.ts +8 -0
- package/es/chart/demo/data/data2.js +7 -0
- package/es/chart/demo/data/data3.d.ts +10 -0
- package/es/chart/demo/data/data3.js +584 -0
- package/es/chart/demo/index.js +6 -5
- package/es/chart/demo/map.d.ts +2 -0
- package/es/chart/demo/map.js +11 -0
- package/es/chart/demo/pie.js +5 -22
- package/es/chart/index.d.ts +37 -17
- package/es/chart/index.js +45 -22
- package/es/chart/type.d.ts +22 -0
- package/es/chart/type.js +1 -0
- package/es/chart/util/chartConfig.d.ts +108 -0
- package/es/chart/util/chartConfig.js +379 -0
- package/es/chart/{color.d.ts → util/color.d.ts} +0 -0
- package/es/chart/{color.js → util/color.js} +0 -0
- package/es/chart/util/data/china.js +530 -0
- package/es/chart/util/data/cityGeoCoord.d.ts +22553 -0
- package/es/chart/util/data/cityGeoCoord.js +22552 -0
- package/es/chart/util/data/provinceGeoCoord.d.ts +343 -0
- package/es/chart/util/data/provinceGeoCoord.js +9258 -0
- package/es/chart/util/formatData.d.ts +13 -0
- package/es/chart/util/formatData.js +56 -0
- package/es/chart/util/formatOption.d.ts +5 -0
- package/es/chart/util/formatOption.js +91 -0
- package/es/chart/util/mapUtil.d.ts +8 -0
- package/es/chart/util/mapUtil.js +195 -0
- package/es/commonStyle/icon.less +32 -5
- package/es/commonStyle/index.less +3 -171
- package/es/commonStyle/select.less +3 -12
- package/es/commonStyle/theme.less +80 -39
- package/es/commonStyle/variable.less +5 -2
- package/es/components/iconFont.d.ts +5 -0
- package/es/components/iconFont.js +30 -0
- package/es/datePicker/demo/form.js +1 -1
- package/es/datePicker/demo/index.js +1 -1
- package/es/datePicker/index.js +8 -15
- package/es/datePicker/index.less +4 -28
- package/es/dialog/components/list.js +1 -1
- package/es/dialog/components/selectToInput.js +12 -1
- package/es/dialog/components/style/list.less +1 -1
- package/es/dialog/components/style/tab.less +2 -2
- package/es/dialog/components/tab.js +1 -1
- package/es/dialog/demo/index.js +1 -1
- package/es/dialog/demo/index2.js +20 -2
- package/es/dialog/demo/index3.js +1 -1
- package/es/dialog/style/index.less +7 -1
- package/es/eventSelector/demo/form.js +1 -1
- package/es/eventSelector/demo/index.js +1 -1
- package/es/eventSelector/demo/nodata.js +1 -1
- package/es/eventSelector/index.d.ts +1 -1
- package/es/eventSelector/index.js +3 -13
- package/es/eventSelector/{cascade.less → index.less} +2 -1
- package/es/globalAttributes/demo/index.js +1 -1
- package/es/globalAttributes/index.js +2 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -4
- package/es/multipleSelector/demo/index.js +1 -1
- package/es/multipleSelector/index.js +2 -8
- package/es/multipleSelector/index.less +23 -25
- package/es/select/demo/index.js +34 -5
- package/es/select/index.d.ts +2 -1
- package/es/select/index.js +32 -9
- package/es/select/index.less +1 -0
- package/es/table/demo/index.js +1 -1
- package/es/table/demo/index2.js +1 -1
- package/es/table/index.js +1 -1
- package/es/table/index.less +78 -41
- package/es/targetConditionGroup/components/conditionItem.js +3 -3
- package/es/targetConditionGroup/components/style/group.less +1 -1
- package/es/targetConditionGroup/components/style/index.less +1 -1
- package/es/targetConditionGroup/data/operates.js +5 -5
- package/es/targetConditionGroup/demo/form.js +1 -1
- package/es/targetConditionGroup/demo/index.js +1 -1
- package/es/targetConditionGroup/index.js +2 -1
- package/es/targetConditionGroup/index.less +1 -2
- package/es/targetSelector/components/BizCascadeBox.d.ts +1 -1
- package/es/targetSelector/components/BizCascadeBox.js +1 -1
- package/es/targetSelector/demo/form.js +1 -1
- package/es/targetSelector/demo/index.js +1 -1
- package/es/targetSelector/demo/nodata.js +1 -1
- package/es/targetSelector/index.js +1 -2
- package/es/targetSelector/index.less +1 -26
- package/es/userGroup/demo/cluster.js +1 -1
- package/es/userGroup/demo/index.js +1 -1
- package/es/userGroup/index.js +1 -2
- package/es/userGroup/index.less +1 -1
- package/es/userGroup/userCluster.js +2 -1
- package/package.json +1 -1
- package/es/chart/chartConfig.d.ts +0 -28
- package/es/chart/chartConfig.js +0 -256
- package/es/chart/demo/data.d.ts +0 -11
- package/es/chart/demo/data.js +0 -37
package/es/chart/index.d.ts
CHANGED
|
@@ -1,33 +1,32 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
data?: Array<string | number | object>;
|
|
5
|
-
}
|
|
6
|
-
interface DataProps {
|
|
7
|
-
xData?: Array<string>;
|
|
8
|
-
seriesData: Array<ChartItmProps>;
|
|
9
|
-
}
|
|
2
|
+
import './util/data/china.js';
|
|
3
|
+
import { DataProps } from './type';
|
|
10
4
|
interface BizChartProps {
|
|
11
|
-
/**
|
|
12
|
-
* @description 自定义图表配置
|
|
13
|
-
* @default -
|
|
14
|
-
*/
|
|
15
|
-
option?: any;
|
|
16
5
|
/**
|
|
17
6
|
* @description 图形类型
|
|
18
7
|
* @default line
|
|
19
8
|
*/
|
|
20
|
-
type
|
|
9
|
+
type: 'bar' | 'pie' | 'line' | 'map';
|
|
21
10
|
/**
|
|
22
11
|
* @description 数据(x轴和series数据)
|
|
23
12
|
* @default -
|
|
24
13
|
*/
|
|
25
|
-
data
|
|
14
|
+
data: DataProps;
|
|
26
15
|
/**
|
|
27
16
|
* @description 柱图是同色还是一柱一色(仅对柱图单一系列作用)
|
|
28
17
|
* @default true
|
|
29
18
|
*/
|
|
30
19
|
sameColor?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* @description 是否是城市
|
|
22
|
+
* @default true
|
|
23
|
+
*/
|
|
24
|
+
isCity?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* @description 用户群,以,隔开
|
|
27
|
+
* @default -
|
|
28
|
+
*/
|
|
29
|
+
userGroup?: string;
|
|
31
30
|
/**
|
|
32
31
|
* @description 提示格式
|
|
33
32
|
* @default -
|
|
@@ -52,12 +51,33 @@ interface BizChartProps {
|
|
|
52
51
|
* @description 图例位置
|
|
53
52
|
* @default -
|
|
54
53
|
*/
|
|
55
|
-
legendPosition
|
|
54
|
+
legendPosition?: 'top' | 'bottom' | 'middle';
|
|
56
55
|
/**
|
|
57
56
|
* @description 图例布局朝向
|
|
58
57
|
* @default -
|
|
59
58
|
*/
|
|
60
|
-
legendOrient
|
|
59
|
+
legendOrient?: 'horizontal' | 'vertical';
|
|
60
|
+
/**
|
|
61
|
+
* @description 显示数据项(从store中过滤),对应series中的names字段。如果没传的话,默认会展示前10条记录
|
|
62
|
+
* @abstract [['group', 'item1'], ['group', 'item2']]或['item1', 'item2']
|
|
63
|
+
* @default -
|
|
64
|
+
*/
|
|
65
|
+
showList?: Array<any>;
|
|
66
|
+
/**
|
|
67
|
+
* @description 默认展示showList指定的条目或者前10条记录,并生成"其它"记录。showAll置为true后,将强制在饼图上展示所有记录
|
|
68
|
+
* @default true
|
|
69
|
+
*/
|
|
70
|
+
showAll?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* @description 是否将series中每项数据的names转为新的x轴
|
|
73
|
+
* @tip 目前只有柱状图时有效
|
|
74
|
+
* @default false
|
|
75
|
+
*/
|
|
76
|
+
reverseXAxis?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* @description reverseXAxis为true时,该项是图例名称
|
|
79
|
+
*/
|
|
80
|
+
seriesName?: string;
|
|
61
81
|
}
|
|
62
82
|
declare const BizChart: React.FC<BizChartProps>;
|
|
63
83
|
export default BizChart;
|
package/es/chart/index.js
CHANGED
|
@@ -16,18 +16,29 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
16
16
|
|
|
17
17
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
18
18
|
|
|
19
|
-
import React, { useEffect, useState } from 'react';
|
|
19
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
20
20
|
import ReactEChartsCore from 'echarts-for-react/lib/core';
|
|
21
21
|
import * as echarts from 'echarts';
|
|
22
|
-
import { getChartOption } from './chartConfig';
|
|
22
|
+
import { getChartOption, getPieOption, getMapOption } from './util/chartConfig';
|
|
23
|
+
import { provinceSeries, citySeries, maxMinValue } from './util/mapUtil';
|
|
24
|
+
import { formatPieData, formatChartData } from './util/formatData';
|
|
25
|
+
import './util/data/china.js';
|
|
26
|
+
import util from '../utils/util';
|
|
23
27
|
|
|
24
28
|
var BizChart = function BizChart(props) {
|
|
25
|
-
var
|
|
26
|
-
type = _props$type === void 0 ? 'line' : _props$type,
|
|
27
|
-
option = props.option,
|
|
29
|
+
var type = props.type,
|
|
28
30
|
data = props.data,
|
|
31
|
+
showList = props.showList,
|
|
32
|
+
userGroup = props.userGroup,
|
|
33
|
+
_props$showAll = props.showAll,
|
|
34
|
+
showAll = _props$showAll === void 0 ? true : _props$showAll,
|
|
29
35
|
_props$sameColor = props.sameColor,
|
|
30
36
|
sameColor = _props$sameColor === void 0 ? true : _props$sameColor,
|
|
37
|
+
_props$reverseXAxis = props.reverseXAxis,
|
|
38
|
+
reverseXAxis = _props$reverseXAxis === void 0 ? false : _props$reverseXAxis,
|
|
39
|
+
_props$isCity = props.isCity,
|
|
40
|
+
isCity = _props$isCity === void 0 ? true : _props$isCity,
|
|
41
|
+
seriesName = props.seriesName,
|
|
31
42
|
tooltipFormatter = props.tooltipFormatter,
|
|
32
43
|
xAxisFormatter = props.xAxisFormatter,
|
|
33
44
|
yAxisFormatter = props.yAxisFormatter,
|
|
@@ -40,30 +51,42 @@ var BizChart = function BizChart(props) {
|
|
|
40
51
|
chartOption = _useState2[0],
|
|
41
52
|
setChartOption = _useState2[1];
|
|
42
53
|
|
|
43
|
-
|
|
44
|
-
var
|
|
45
|
-
|
|
46
|
-
if (
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
54
|
+
var showMap = useMemo(function () {
|
|
55
|
+
var data = {};
|
|
56
|
+
|
|
57
|
+
if (showList) {
|
|
58
|
+
showList.forEach(function (item) {
|
|
59
|
+
if (util.isArray(item)) {
|
|
60
|
+
data[item.join('-')] = true;
|
|
61
|
+
} else if (util.isString(item)) {
|
|
62
|
+
data[item] = true;
|
|
63
|
+
}
|
|
64
|
+
});
|
|
52
65
|
}
|
|
53
66
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
67
|
+
return data;
|
|
68
|
+
}, [showList]);
|
|
69
|
+
useEffect(function () {
|
|
70
|
+
var eOption = {};
|
|
71
|
+
|
|
72
|
+
if (type === 'pie') {
|
|
73
|
+
var rData = formatPieData(data, showAll, showMap, showList);
|
|
74
|
+
eOption = getPieOption(rData, legendPosition, legendOrient, tooltipFormatter);
|
|
75
|
+
} else if (type === 'line' || type === 'bar') {
|
|
76
|
+
var _rData = formatChartData(data, reverseXAxis, showMap, showList);
|
|
77
|
+
|
|
78
|
+
eOption = getChartOption(type, reverseXAxis && showList ? showList : _rData.x_axis, _rData.series, sameColor, legendPosition, legendOrient, valueUnit, tooltipFormatter, xAxisFormatter, yAxisFormatter, reverseXAxis, seriesName);
|
|
79
|
+
} else if (type === 'map') {
|
|
80
|
+
var series = isCity ? citySeries(data, !!userGroup) : provinceSeries(data, !!userGroup);
|
|
81
|
+
var maxMin = maxMinValue(series[0]);
|
|
82
|
+
var showVisualMap = !(userGroup && userGroup.split(',').length > 1);
|
|
83
|
+
eOption = getMapOption(series, maxMin, showVisualMap, tooltipFormatter);
|
|
60
84
|
}
|
|
61
85
|
|
|
62
|
-
console.log('option>>>', eOption);
|
|
63
86
|
setChartOption(function () {
|
|
64
87
|
return _objectSpread({}, eOption);
|
|
65
88
|
});
|
|
66
|
-
}, [data, type]);
|
|
89
|
+
}, [data, type, reverseXAxis]);
|
|
67
90
|
return /*#__PURE__*/React.createElement(ReactEChartsCore, {
|
|
68
91
|
echarts: echarts,
|
|
69
92
|
option: chartOption,
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface ChartItmProps {
|
|
2
|
+
names: Array<string>;
|
|
3
|
+
values: Array<number>;
|
|
4
|
+
userGroupCompareData?: object;
|
|
5
|
+
}
|
|
6
|
+
export interface DataProps {
|
|
7
|
+
x_axis: Array<string>;
|
|
8
|
+
series: Array<ChartItmProps>;
|
|
9
|
+
}
|
|
10
|
+
export interface ItemDataProps {
|
|
11
|
+
data: Array<object>;
|
|
12
|
+
[prop: string]: any;
|
|
13
|
+
}
|
|
14
|
+
export interface ProvinceDataProps {
|
|
15
|
+
name: string;
|
|
16
|
+
value: number;
|
|
17
|
+
childrenOptions: Array<any>;
|
|
18
|
+
isProvince?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface ProvinceMapDataProps {
|
|
21
|
+
[prop: string]: ProvinceDataProps;
|
|
22
|
+
}
|
package/es/chart/type.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { GridComponentOption, TitleComponentOption, TooltipComponentOption } from 'echarts/types/dist/echarts';
|
|
2
|
+
import { BarSeriesOption, LegendComponentOption, LineSeriesOption, PieSeriesOption, ToolboxComponentOption, XAXisOption, YAXisOption } from 'echarts/types/dist/shared';
|
|
3
|
+
import '../index.less';
|
|
4
|
+
export declare const baseConfig: EChartsOption;
|
|
5
|
+
export declare const seriesConfig: any;
|
|
6
|
+
export declare type EChartsOption = echarts.ComposeOption<TitleComponentOption | ToolboxComponentOption | TooltipComponentOption | GridComponentOption | LegendComponentOption | LineSeriesOption | BarSeriesOption | PieSeriesOption>;
|
|
7
|
+
export declare const legendConfig: LegendComponentOption;
|
|
8
|
+
export declare const gridConfig: {
|
|
9
|
+
left: number;
|
|
10
|
+
right: string;
|
|
11
|
+
bottom: number;
|
|
12
|
+
top: number;
|
|
13
|
+
containLabel: boolean;
|
|
14
|
+
};
|
|
15
|
+
export declare const xAxisConfig: XAXisOption;
|
|
16
|
+
export declare const yAxisConfig: YAXisOption;
|
|
17
|
+
export declare const tooltipConfig: TooltipComponentOption;
|
|
18
|
+
/**
|
|
19
|
+
* 折现/柱图
|
|
20
|
+
* @param xData x轴数据 []
|
|
21
|
+
* @param seriesData 系列数据 [{name:'系列名称',data:[数据]}]
|
|
22
|
+
* @param chartType 图表类型
|
|
23
|
+
* @param seriesType 系列类型(单选列柱图是单个颜色还是一个柱一个颜色)
|
|
24
|
+
* @param legendPosition 图例位置
|
|
25
|
+
* @param legendOrient 图例方向
|
|
26
|
+
* @param unit y轴单位
|
|
27
|
+
* @param tooltipFormatter tooltip 自定义显示
|
|
28
|
+
* @param xAxisFormatter x轴 自定义显示
|
|
29
|
+
* @param yAxisFormatter y轴 自定义显示
|
|
30
|
+
* @param reverseXAxis 柱图单系列
|
|
31
|
+
* @param seriesName 系列名称
|
|
32
|
+
*
|
|
33
|
+
*/
|
|
34
|
+
export declare const getChartOption: (chartType: string, xData?: string[] | undefined, seriesData?: object[], sameColor?: boolean, legendPosition?: 'top' | 'bottom' | 'middle', legendOrient?: 'horizontal' | 'vertical', unit?: string | undefined, tooltipFormatter?: ((value: any) => string) | undefined, xAxisFormatter?: ((value: any) => string) | undefined, yAxisFormatter?: ((value: any) => string) | undefined, reverseXAxis?: boolean | undefined, seriesName?: string | undefined) => EChartsOption;
|
|
35
|
+
/**
|
|
36
|
+
* 饼图配置
|
|
37
|
+
* @param seriesData 数据 [{name:'',value:''}]
|
|
38
|
+
* @param legendPosition 图例位置
|
|
39
|
+
* @param legendOrient 图例方向
|
|
40
|
+
* @param tooltipFormatter tooltip 自定义显示
|
|
41
|
+
* @returns
|
|
42
|
+
*/
|
|
43
|
+
export declare const getPieOption: (seriesData?: object[], legendPosition?: 'top' | 'bottom' | 'middle', legendOrient?: 'horizontal' | 'vertical', tooltipFormatter?: ((value: any) => string) | undefined) => EChartsOption;
|
|
44
|
+
/**
|
|
45
|
+
* 地图
|
|
46
|
+
* @param seriesData 数据
|
|
47
|
+
* @param maxMinValue 最大最小值
|
|
48
|
+
* @param showVisualMap 是否显示
|
|
49
|
+
* @param tooltipFormat 提示formatter
|
|
50
|
+
* @returns option
|
|
51
|
+
*/
|
|
52
|
+
export declare const getMapOption: (seriesData: object[] | undefined, maxMinValue: {
|
|
53
|
+
min: number;
|
|
54
|
+
max: number;
|
|
55
|
+
}, showVisualMap?: boolean, tooltipFormat?: ((value: any) => string) | undefined) => {
|
|
56
|
+
geo: {
|
|
57
|
+
map: string;
|
|
58
|
+
roam: boolean;
|
|
59
|
+
layoutCenter: string[];
|
|
60
|
+
top: number;
|
|
61
|
+
bottom: number;
|
|
62
|
+
};
|
|
63
|
+
backgroundColor: string;
|
|
64
|
+
tooltip: {
|
|
65
|
+
trigger: string;
|
|
66
|
+
textStyle: {
|
|
67
|
+
fontSize: number;
|
|
68
|
+
};
|
|
69
|
+
backgroundColor: string;
|
|
70
|
+
borderColor: string;
|
|
71
|
+
padding: number;
|
|
72
|
+
extraCssText: string;
|
|
73
|
+
className: string;
|
|
74
|
+
confine: boolean;
|
|
75
|
+
formatter: (params: any) => string | undefined;
|
|
76
|
+
};
|
|
77
|
+
legend: {
|
|
78
|
+
show: boolean;
|
|
79
|
+
};
|
|
80
|
+
visualMap: {
|
|
81
|
+
type: string;
|
|
82
|
+
min: number;
|
|
83
|
+
max: number;
|
|
84
|
+
left: string;
|
|
85
|
+
top: string;
|
|
86
|
+
text: string[];
|
|
87
|
+
realtime: boolean;
|
|
88
|
+
calculable: boolean;
|
|
89
|
+
seriesIndex: number;
|
|
90
|
+
inRange: {
|
|
91
|
+
color: string[];
|
|
92
|
+
};
|
|
93
|
+
show: boolean;
|
|
94
|
+
};
|
|
95
|
+
toolbox: {
|
|
96
|
+
show: boolean;
|
|
97
|
+
orient: string;
|
|
98
|
+
right: string;
|
|
99
|
+
bottom: string;
|
|
100
|
+
feature: {
|
|
101
|
+
saveAsImage: {
|
|
102
|
+
show: boolean;
|
|
103
|
+
title: string;
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
series: object[];
|
|
108
|
+
};
|
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
+
|
|
3
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
|
|
5
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
6
|
+
|
|
7
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
8
|
+
|
|
9
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
10
|
+
|
|
11
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
12
|
+
|
|
13
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
14
|
+
|
|
15
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
16
|
+
|
|
17
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
18
|
+
|
|
19
|
+
import { tooltipFormatterDefault, xAxisFormatterDefault, yAxisFormatterDefault, mapTooltipFormatter } from './formatOption';
|
|
20
|
+
import { chartColors } from './color';
|
|
21
|
+
import '../index.less';
|
|
22
|
+
export var baseConfig = {
|
|
23
|
+
color: chartColors,
|
|
24
|
+
textStyle: {
|
|
25
|
+
color: '#5F6085'
|
|
26
|
+
},
|
|
27
|
+
toolbox: {
|
|
28
|
+
show: false
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
export var seriesConfig = {
|
|
32
|
+
symbol: 'circle',
|
|
33
|
+
symbolSize: 5
|
|
34
|
+
};
|
|
35
|
+
export var legendConfig = {
|
|
36
|
+
type: 'scroll',
|
|
37
|
+
height: 17,
|
|
38
|
+
padding: 0,
|
|
39
|
+
itemHeight: 10,
|
|
40
|
+
itemWidth: 10,
|
|
41
|
+
lineStyle: {
|
|
42
|
+
opacity: 0
|
|
43
|
+
},
|
|
44
|
+
textStyle: {
|
|
45
|
+
color: '#5F6085',
|
|
46
|
+
lineHeight: 17
|
|
47
|
+
},
|
|
48
|
+
pageIconSize: 10,
|
|
49
|
+
pageTextStyle: {
|
|
50
|
+
color: '#5F6085'
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
export var gridConfig = {
|
|
54
|
+
left: 0,
|
|
55
|
+
right: '3%',
|
|
56
|
+
bottom: 0,
|
|
57
|
+
top: 24,
|
|
58
|
+
containLabel: true
|
|
59
|
+
};
|
|
60
|
+
export var xAxisConfig = {
|
|
61
|
+
axisLine: {
|
|
62
|
+
lineStyle: {
|
|
63
|
+
color: '#ECEDF0',
|
|
64
|
+
width: 1
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
axisTick: {
|
|
68
|
+
lineStyle: {
|
|
69
|
+
color: '#ECEDF0'
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
nameTextStyle: {
|
|
73
|
+
lineHeight: 30
|
|
74
|
+
},
|
|
75
|
+
// boundaryGap: false,
|
|
76
|
+
axisLabel: {
|
|
77
|
+
formatter: function formatter(value) {
|
|
78
|
+
return value;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
export var yAxisConfig = {
|
|
83
|
+
type: 'value',
|
|
84
|
+
splitLine: {
|
|
85
|
+
lineStyle: {
|
|
86
|
+
type: 'dashed'
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
axisLabel: {
|
|
90
|
+
formatter: function formatter(value) {
|
|
91
|
+
return String(value);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
export var tooltipConfig = {
|
|
96
|
+
trigger: 'axis',
|
|
97
|
+
confine: false,
|
|
98
|
+
backgroundColor: 'rgba(250, 251, 253, 0.8)',
|
|
99
|
+
borderColor: 'transparent',
|
|
100
|
+
padding: 8,
|
|
101
|
+
extraCssText: '0px 4px 10px rgba(0, 0, 0, 0.1)',
|
|
102
|
+
className: 'biz-chart-tooltip',
|
|
103
|
+
appendToBody: true,
|
|
104
|
+
axisPointer: {
|
|
105
|
+
type: 'shadow',
|
|
106
|
+
z: 0,
|
|
107
|
+
shadowStyle: {
|
|
108
|
+
color: '#f6f6f6'
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* 折现/柱图
|
|
114
|
+
* @param xData x轴数据 []
|
|
115
|
+
* @param seriesData 系列数据 [{name:'系列名称',data:[数据]}]
|
|
116
|
+
* @param chartType 图表类型
|
|
117
|
+
* @param seriesType 系列类型(单选列柱图是单个颜色还是一个柱一个颜色)
|
|
118
|
+
* @param legendPosition 图例位置
|
|
119
|
+
* @param legendOrient 图例方向
|
|
120
|
+
* @param unit y轴单位
|
|
121
|
+
* @param tooltipFormatter tooltip 自定义显示
|
|
122
|
+
* @param xAxisFormatter x轴 自定义显示
|
|
123
|
+
* @param yAxisFormatter y轴 自定义显示
|
|
124
|
+
* @param reverseXAxis 柱图单系列
|
|
125
|
+
* @param seriesName 系列名称
|
|
126
|
+
*
|
|
127
|
+
*/
|
|
128
|
+
|
|
129
|
+
export var getChartOption = function getChartOption(chartType, xData) {
|
|
130
|
+
var seriesData = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
131
|
+
var sameColor = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
132
|
+
var legendPosition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 'top';
|
|
133
|
+
var legendOrient = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 'horizontal';
|
|
134
|
+
var unit = arguments.length > 6 ? arguments[6] : undefined;
|
|
135
|
+
var tooltipFormatter = arguments.length > 7 ? arguments[7] : undefined;
|
|
136
|
+
var xAxisFormatter = arguments.length > 8 ? arguments[8] : undefined;
|
|
137
|
+
var yAxisFormatter = arguments.length > 9 ? arguments[9] : undefined;
|
|
138
|
+
var reverseXAxis = arguments.length > 10 ? arguments[10] : undefined;
|
|
139
|
+
var seriesName = arguments.length > 11 ? arguments[11] : undefined;
|
|
140
|
+
|
|
141
|
+
var xAxis = JSON.parse(JSON.stringify(xAxisConfig)),
|
|
142
|
+
tooltip = JSON.parse(JSON.stringify(tooltipConfig)),
|
|
143
|
+
yAxis = _objectSpread({}, yAxisConfig),
|
|
144
|
+
legend = _objectSpread({}, legendConfig),
|
|
145
|
+
grid = _objectSpread({}, gridConfig),
|
|
146
|
+
seriesItem = _objectSpread({}, seriesConfig); // x轴配置
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
if (xData) {
|
|
150
|
+
xAxis.data = xData;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
xAxis.boundaryGap = chartType === 'bar';
|
|
154
|
+
xAxis.axisLabel = xAxis.axisLabel || {
|
|
155
|
+
rotate: 0
|
|
156
|
+
};
|
|
157
|
+
xAxis.axisLabel.rotate = chartType === 'bar' ? 45 : 0;
|
|
158
|
+
|
|
159
|
+
if (xAxisFormatter) {
|
|
160
|
+
xAxis.axisLabel.formatter = xAxisFormatter;
|
|
161
|
+
} else {
|
|
162
|
+
xAxis.axisLabel.formatter = xAxisFormatterDefault;
|
|
163
|
+
} //Y轴配置
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
yAxis.axisLabel = yAxis.axisLabel || {};
|
|
167
|
+
|
|
168
|
+
if (yAxisFormatter) {
|
|
169
|
+
yAxis.axisLabel.formatter = yAxisFormatter;
|
|
170
|
+
} else {
|
|
171
|
+
yAxis.axisLabel.formatter = yAxisFormatterDefault;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (unit) {
|
|
175
|
+
yAxis.name = unit;
|
|
176
|
+
} // series配置
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
var itemStyle = {
|
|
180
|
+
color: sameColor ? 'auto' : function (param) {
|
|
181
|
+
return chartColors[param.dataIndex % 20];
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
var series = [];
|
|
185
|
+
|
|
186
|
+
if (chartType === 'bar') {
|
|
187
|
+
seriesItem.barMaxWidth = 40;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (!reverseXAxis) {
|
|
191
|
+
series = seriesData.map(function (item) {
|
|
192
|
+
var data = _objectSpread({}, item);
|
|
193
|
+
|
|
194
|
+
if (item.names) {
|
|
195
|
+
data = {
|
|
196
|
+
name: item.names.join('-'),
|
|
197
|
+
data: item.values
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return _objectSpread(_objectSpread(_objectSpread({}, data), seriesItem), {}, {
|
|
202
|
+
itemStyle: itemStyle,
|
|
203
|
+
type: chartType
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
} else {
|
|
207
|
+
series = [_objectSpread(_objectSpread({
|
|
208
|
+
name: seriesName || '',
|
|
209
|
+
data: _toConsumableArray(seriesData)
|
|
210
|
+
}, seriesItem), {}, {
|
|
211
|
+
itemStyle: itemStyle,
|
|
212
|
+
type: chartType
|
|
213
|
+
})];
|
|
214
|
+
} // tooltip config
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
tooltip.axisPointer = tooltip.axisPointer || {};
|
|
218
|
+
tooltip.axisPointer.type = chartType === 'bar' ? 'shadow' : 'line';
|
|
219
|
+
|
|
220
|
+
if (tooltipFormatter) {
|
|
221
|
+
tooltip.formatter = tooltipFormatter;
|
|
222
|
+
} else {
|
|
223
|
+
tooltip.formatter = tooltipFormatterDefault;
|
|
224
|
+
} // grid config
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
if (legendPosition === 'top') {
|
|
228
|
+
grid.top = series.length > 1 || series[0].name ? 45 : 10;
|
|
229
|
+
} else if (legendPosition === 'bottom') {
|
|
230
|
+
grid.bottom = series.length > 1 || series[0].name ? 45 : 0;
|
|
231
|
+
} // 图例配置
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
legend.top = legendPosition;
|
|
235
|
+
legend.orient = legendOrient;
|
|
236
|
+
|
|
237
|
+
if (legendOrient === 'vertical') {
|
|
238
|
+
legend.left = 'left';
|
|
239
|
+
legend.height = 'auto';
|
|
240
|
+
legend.width = 50;
|
|
241
|
+
grid.left = 80;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return _objectSpread(_objectSpread({}, baseConfig), {}, {
|
|
245
|
+
legend: legend,
|
|
246
|
+
xAxis: xAxis,
|
|
247
|
+
yAxis: yAxis,
|
|
248
|
+
tooltip: tooltip,
|
|
249
|
+
grid: grid,
|
|
250
|
+
series: series
|
|
251
|
+
});
|
|
252
|
+
};
|
|
253
|
+
/**
|
|
254
|
+
* 饼图配置
|
|
255
|
+
* @param seriesData 数据 [{name:'',value:''}]
|
|
256
|
+
* @param legendPosition 图例位置
|
|
257
|
+
* @param legendOrient 图例方向
|
|
258
|
+
* @param tooltipFormatter tooltip 自定义显示
|
|
259
|
+
* @returns
|
|
260
|
+
*/
|
|
261
|
+
|
|
262
|
+
export var getPieOption = function getPieOption() {
|
|
263
|
+
var seriesData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
264
|
+
var legendPosition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'top';
|
|
265
|
+
var legendOrient = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'horizontal';
|
|
266
|
+
var tooltipFormatter = arguments.length > 3 ? arguments[3] : undefined;
|
|
267
|
+
var series = [{
|
|
268
|
+
type: 'pie',
|
|
269
|
+
data: seriesData,
|
|
270
|
+
label: {
|
|
271
|
+
show: false
|
|
272
|
+
}
|
|
273
|
+
}];
|
|
274
|
+
|
|
275
|
+
var tooltip = JSON.parse(JSON.stringify(tooltipConfig)),
|
|
276
|
+
legend = _objectSpread({}, legendConfig),
|
|
277
|
+
grid = _objectSpread({}, gridConfig);
|
|
278
|
+
|
|
279
|
+
legend.top = legendPosition;
|
|
280
|
+
legend.orient = legendOrient;
|
|
281
|
+
|
|
282
|
+
if (legendOrient === 'vertical') {
|
|
283
|
+
legend.left = 'left';
|
|
284
|
+
legend.height = 'auto';
|
|
285
|
+
legend.width = 50;
|
|
286
|
+
grid.left = 80;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
tooltip.trigger = 'item';
|
|
290
|
+
|
|
291
|
+
if (tooltipFormatter) {
|
|
292
|
+
tooltip.formatter = tooltipFormatter;
|
|
293
|
+
} else {
|
|
294
|
+
tooltip.formatter = function (params) {
|
|
295
|
+
var name = params.name,
|
|
296
|
+
value = params.value,
|
|
297
|
+
marker = params.marker;
|
|
298
|
+
return "<div class=\"biz-chart-tooltip-item\"><span class=\"biz-chart-tooltip-content\">".concat(marker).concat(name, ":</span> <span class=\"biz-chart-tooltip-value\">").concat(value, "</span></div>");
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
return _objectSpread(_objectSpread({}, baseConfig), {}, {
|
|
303
|
+
legend: legend,
|
|
304
|
+
tooltip: tooltip,
|
|
305
|
+
grid: grid,
|
|
306
|
+
series: series
|
|
307
|
+
});
|
|
308
|
+
};
|
|
309
|
+
/**
|
|
310
|
+
* 地图
|
|
311
|
+
* @param seriesData 数据
|
|
312
|
+
* @param maxMinValue 最大最小值
|
|
313
|
+
* @param showVisualMap 是否显示
|
|
314
|
+
* @param tooltipFormat 提示formatter
|
|
315
|
+
* @returns option
|
|
316
|
+
*/
|
|
317
|
+
|
|
318
|
+
export var getMapOption = function getMapOption() {
|
|
319
|
+
var seriesData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
320
|
+
var maxMinValue = arguments.length > 1 ? arguments[1] : undefined;
|
|
321
|
+
var showVisualMap = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
322
|
+
var tooltipFormat = arguments.length > 3 ? arguments[3] : undefined;
|
|
323
|
+
var option = {
|
|
324
|
+
geo: {
|
|
325
|
+
map: 'china',
|
|
326
|
+
roam: false,
|
|
327
|
+
layoutCenter: ['30%', '30%'],
|
|
328
|
+
top: 20,
|
|
329
|
+
bottom: 20
|
|
330
|
+
},
|
|
331
|
+
backgroundColor: '#fff',
|
|
332
|
+
tooltip: {
|
|
333
|
+
trigger: 'item',
|
|
334
|
+
textStyle: {
|
|
335
|
+
fontSize: 12
|
|
336
|
+
},
|
|
337
|
+
backgroundColor: 'rgba(250, 251, 253, 0.8)',
|
|
338
|
+
borderColor: 'transparent',
|
|
339
|
+
padding: 8,
|
|
340
|
+
extraCssText: '0px 4px 10px rgba(0, 0, 0, 0.1)',
|
|
341
|
+
className: 'biz-chart-tooltip',
|
|
342
|
+
confine: true,
|
|
343
|
+
formatter: tooltipFormat || mapTooltipFormatter
|
|
344
|
+
},
|
|
345
|
+
legend: {
|
|
346
|
+
show: false
|
|
347
|
+
},
|
|
348
|
+
visualMap: {
|
|
349
|
+
type: 'continuous',
|
|
350
|
+
min: maxMinValue.min,
|
|
351
|
+
max: maxMinValue.max,
|
|
352
|
+
left: 'left',
|
|
353
|
+
top: 'bottom',
|
|
354
|
+
text: ['高', '低'],
|
|
355
|
+
realtime: true,
|
|
356
|
+
calculable: true,
|
|
357
|
+
seriesIndex: 0,
|
|
358
|
+
inRange: {
|
|
359
|
+
color: ['lightskyblue', 'yellow', 'orangered']
|
|
360
|
+
},
|
|
361
|
+
show: showVisualMap // 用户群对比不支持
|
|
362
|
+
|
|
363
|
+
},
|
|
364
|
+
toolbox: {
|
|
365
|
+
show: true,
|
|
366
|
+
orient: 'horizontal',
|
|
367
|
+
right: '20',
|
|
368
|
+
bottom: '20',
|
|
369
|
+
feature: {
|
|
370
|
+
saveAsImage: {
|
|
371
|
+
show: true,
|
|
372
|
+
title: '保存为图片'
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
},
|
|
376
|
+
series: seriesData
|
|
377
|
+
};
|
|
378
|
+
return option;
|
|
379
|
+
};
|
|
File without changes
|
|
File without changes
|