onesight-charts 0.0.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.
- package/LICENSE +21 -0
- package/README.md +24 -0
- package/dist/components/line/demo.js +13 -0
- package/dist/components/line/index.js +294 -0
- package/dist/components/line/style.scss +110 -0
- package/dist/components/line/tooltipConfig.js +93 -0
- package/dist/components/one-table/demo/line-chart.js +908 -0
- package/dist/components/one-table/index.js +128 -0
- package/dist/components/one-table/index.scss +5 -0
- package/dist/components/pie/index.js +94 -0
- package/dist/components/pie/index.scss +5 -0
- package/dist/components/tooltip/demo/line-chart.js +908 -0
- package/dist/components/tooltip/index.js +128 -0
- package/dist/components/tooltip/index.scss +5 -0
- package/dist/index.js +1 -0
- package/dist/umd/onesight-charts.min.css +1 -0
- package/dist/umd/onesight-charts.min.js +1 -0
- package/dist/utils/chartUtils.js +215 -0
- package/dist/utils/colors.js +26 -0
- package/lib/components/line/demo.js +42 -0
- package/lib/components/line/index.js +307 -0
- package/lib/components/line/style.scss +110 -0
- package/lib/components/line/tooltipConfig.js +144 -0
- package/lib/components/one-table/demo/line-chart.js +1020 -0
- package/lib/components/one-table/index.js +156 -0
- package/lib/components/one-table/index.scss +5 -0
- package/lib/components/pie/index.js +131 -0
- package/lib/components/pie/index.scss +5 -0
- package/lib/components/tooltip/demo/line-chart.js +1020 -0
- package/lib/components/tooltip/index.js +156 -0
- package/lib/components/tooltip/index.scss +5 -0
- package/lib/index.js +39 -0
- package/lib/utils/chartUtils.js +226 -0
- package/lib/utils/colors.js +71 -0
- package/package.json +82 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import ReactECharts from 'echarts-for-react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
var LineChart = function LineChart(_ref) {
|
|
4
|
+
var data = _ref.data;
|
|
5
|
+
var getOption = function getOption() {
|
|
6
|
+
return {
|
|
7
|
+
legend: {
|
|
8
|
+
// data: legendData,
|
|
9
|
+
x: 'center',
|
|
10
|
+
type: 'plain',
|
|
11
|
+
bottom: 0,
|
|
12
|
+
padding: 0,
|
|
13
|
+
left: 'center',
|
|
14
|
+
icon: 'rect',
|
|
15
|
+
itemWidth: 16,
|
|
16
|
+
itemHeight: 4,
|
|
17
|
+
itemGap: 8,
|
|
18
|
+
// formatter: function (name) {
|
|
19
|
+
// let value = legendCustom
|
|
20
|
+
// ? handleCompareSeries(name, series)
|
|
21
|
+
// : handleSeries(name, series);
|
|
22
|
+
// let showName = name;
|
|
23
|
+
// if (series.length >= 4) {
|
|
24
|
+
// const strLen = 15;
|
|
25
|
+
// if (name.length > strLen) {
|
|
26
|
+
// showName = name.substring(0, strLen) + '...';
|
|
27
|
+
// }
|
|
28
|
+
// }
|
|
29
|
+
// return isTranslation
|
|
30
|
+
// ? `{labelName|${formatMessage({
|
|
31
|
+
// id: `listening_${name}`,
|
|
32
|
+
// })} }\n{labelMark|${value}}`
|
|
33
|
+
// : legendCustom
|
|
34
|
+
// ? `{labelName|${showName}}\n{labelMark|${value}}`
|
|
35
|
+
// : `${name}`;
|
|
36
|
+
// },
|
|
37
|
+
textStyle: {
|
|
38
|
+
fontWeight: 500,
|
|
39
|
+
fontSize: 12,
|
|
40
|
+
color: '#364141',
|
|
41
|
+
lineHeight: 6,
|
|
42
|
+
rich: {
|
|
43
|
+
// 给labelName添加样式
|
|
44
|
+
labelName: {
|
|
45
|
+
fontWeight: 500,
|
|
46
|
+
fontSize: 12,
|
|
47
|
+
padding: [6, 6, 0, 0]
|
|
48
|
+
},
|
|
49
|
+
// 给labelMark添加样式
|
|
50
|
+
labelMark: {
|
|
51
|
+
color: '#7A8283',
|
|
52
|
+
fontSize: 12,
|
|
53
|
+
padding: [30, 0, 0, 0]
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
tooltip: {
|
|
59
|
+
trigger: 'axis'
|
|
60
|
+
},
|
|
61
|
+
xAxis: {
|
|
62
|
+
type: 'category',
|
|
63
|
+
axisLine: {
|
|
64
|
+
lineStyle: {
|
|
65
|
+
color: '#e5e5e5'
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
axisTick: {
|
|
69
|
+
show: true,
|
|
70
|
+
alignWithLabel: true,
|
|
71
|
+
length: 5
|
|
72
|
+
},
|
|
73
|
+
axisLabel: {
|
|
74
|
+
// formatter: function (value, index) {
|
|
75
|
+
// return xAxisType === 'date'
|
|
76
|
+
// ? formatDateXaxis(value)
|
|
77
|
+
// : formatMessage({ id: `listening_${value}` });
|
|
78
|
+
// },
|
|
79
|
+
interval: 'auto',
|
|
80
|
+
margin: 12,
|
|
81
|
+
color: '#515E5F',
|
|
82
|
+
fontWeight: 500,
|
|
83
|
+
fontSize: 12,
|
|
84
|
+
lineHeight: 20
|
|
85
|
+
},
|
|
86
|
+
splitLine: {
|
|
87
|
+
show: false,
|
|
88
|
+
interval: 0
|
|
89
|
+
},
|
|
90
|
+
boundaryGap: false
|
|
91
|
+
// data: xAxisData,
|
|
92
|
+
},
|
|
93
|
+
yAxis: {
|
|
94
|
+
type: 'value',
|
|
95
|
+
minInterval: 1,
|
|
96
|
+
axisLabel: {
|
|
97
|
+
// formatter: function (value) {
|
|
98
|
+
// let formatted = customize.numberFormatNull(value);
|
|
99
|
+
// if (formatted.length < 4) {
|
|
100
|
+
// // 假设最大长度为4
|
|
101
|
+
// formatted = ' ' + formatted; // 在前面添加空格
|
|
102
|
+
// }
|
|
103
|
+
// return formatted;
|
|
104
|
+
// },
|
|
105
|
+
margin: 14,
|
|
106
|
+
color: '#515E5F',
|
|
107
|
+
fontSize: 12,
|
|
108
|
+
lineHeight: 20
|
|
109
|
+
},
|
|
110
|
+
splitLine: {
|
|
111
|
+
lineStyle: {
|
|
112
|
+
type: 'dashed',
|
|
113
|
+
color: '#E5E5E5'
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
series: data,
|
|
118
|
+
animation: true
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
return /*#__PURE__*/React.createElement(ReactECharts, {
|
|
122
|
+
option: getOption(),
|
|
123
|
+
style: {
|
|
124
|
+
height: 400
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
export default LineChart;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import * as echarts from 'echarts';
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import "./index.scss";
|
|
4
|
+
export default function Pie() {
|
|
5
|
+
var chartID = 'chart-pie';
|
|
6
|
+
useEffect(function () {
|
|
7
|
+
ceartChart();
|
|
8
|
+
}, []);
|
|
9
|
+
var ceartChart = function ceartChart() {
|
|
10
|
+
var myChart = echarts.init(document.getElementById(chartID), null, {
|
|
11
|
+
renderer: 'svg'
|
|
12
|
+
});
|
|
13
|
+
var option = {
|
|
14
|
+
tooltip: {
|
|
15
|
+
show: false,
|
|
16
|
+
className: 'pie-tooltip',
|
|
17
|
+
trigger: 'item',
|
|
18
|
+
padding: 0
|
|
19
|
+
},
|
|
20
|
+
series: [{
|
|
21
|
+
type: 'pie',
|
|
22
|
+
radius: [70, 95],
|
|
23
|
+
itemStyle: {
|
|
24
|
+
borderColor: '#fff',
|
|
25
|
+
borderWidth: 2
|
|
26
|
+
},
|
|
27
|
+
label: {
|
|
28
|
+
show: false,
|
|
29
|
+
position: 'center'
|
|
30
|
+
},
|
|
31
|
+
emphasis: {
|
|
32
|
+
label: {
|
|
33
|
+
show: true,
|
|
34
|
+
formatter: function formatter() {
|
|
35
|
+
return '';
|
|
36
|
+
},
|
|
37
|
+
rich: {
|
|
38
|
+
n: {
|
|
39
|
+
height: 40,
|
|
40
|
+
padding: [0, 0, 12, 0],
|
|
41
|
+
lineHeight: 16,
|
|
42
|
+
fontWeight: 500,
|
|
43
|
+
fontSize: 16,
|
|
44
|
+
color: '#515e5f',
|
|
45
|
+
align: 'center'
|
|
46
|
+
},
|
|
47
|
+
v: {
|
|
48
|
+
lineHeight: 36,
|
|
49
|
+
fontWeight: 800,
|
|
50
|
+
fontSize: 30,
|
|
51
|
+
color: '#273333',
|
|
52
|
+
align: 'center',
|
|
53
|
+
padding: [0, 0, 15, 0]
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
data: [{
|
|
59
|
+
value: 5325,
|
|
60
|
+
name: 'positive',
|
|
61
|
+
proportion: 0.0595,
|
|
62
|
+
type: 1,
|
|
63
|
+
itemStyle: {
|
|
64
|
+
color: '#1DA9A0'
|
|
65
|
+
}
|
|
66
|
+
}, {
|
|
67
|
+
value: 1879,
|
|
68
|
+
name: 'negative',
|
|
69
|
+
proportion: 0.021,
|
|
70
|
+
type: 2,
|
|
71
|
+
itemStyle: {
|
|
72
|
+
color: '#EE6666'
|
|
73
|
+
}
|
|
74
|
+
}, {
|
|
75
|
+
value: 82344,
|
|
76
|
+
name: 'neutral',
|
|
77
|
+
proportion: 0.9195,
|
|
78
|
+
type: 3,
|
|
79
|
+
itemStyle: {
|
|
80
|
+
color: '#bbbbbb'
|
|
81
|
+
}
|
|
82
|
+
}],
|
|
83
|
+
selectedMode: true,
|
|
84
|
+
selectedOffset: 0,
|
|
85
|
+
minAngle: 3
|
|
86
|
+
}]
|
|
87
|
+
};
|
|
88
|
+
myChart.setOption(option);
|
|
89
|
+
};
|
|
90
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
91
|
+
id: chartID,
|
|
92
|
+
className: "onesight-chart-pie"
|
|
93
|
+
});
|
|
94
|
+
}
|