amazing-react-charts 0.4.12 → 0.4.14
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/dist/core/DonutChart.js
CHANGED
|
@@ -37,6 +37,15 @@ var WIDTH_STYLE = {
|
|
|
37
37
|
width: '99.9%'
|
|
38
38
|
};
|
|
39
39
|
exports.WIDTH_STYLE = WIDTH_STYLE;
|
|
40
|
+
var titleStyle = {
|
|
41
|
+
position: 'absolute',
|
|
42
|
+
top: 5,
|
|
43
|
+
margin: 0,
|
|
44
|
+
fontFamily: 'Roboto, Helvetica, Arial, sans-serif',
|
|
45
|
+
fontSize: 16,
|
|
46
|
+
fontWeight: 300,
|
|
47
|
+
color: 'black'
|
|
48
|
+
};
|
|
40
49
|
|
|
41
50
|
var DonutChart = function DonutChart(props) {
|
|
42
51
|
var titleProps = props.title,
|
|
@@ -114,14 +123,13 @@ var DonutChart = function DonutChart(props) {
|
|
|
114
123
|
grid: grid,
|
|
115
124
|
color: colors,
|
|
116
125
|
title: {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
text: titleProps,
|
|
126
|
+
top: 'middle',
|
|
127
|
+
left: 'center',
|
|
128
|
+
text: donutCenterValue || (0, _auxiliarFunctions.thousandSeparator)(totalValues),
|
|
121
129
|
textAlign: 'left',
|
|
122
130
|
textStyle: {
|
|
123
131
|
fontFamily: 'Roboto, Helvetica, Arial, sans-serif',
|
|
124
|
-
fontSize:
|
|
132
|
+
fontSize: centerPieValueFontSize || 24,
|
|
125
133
|
fontWeight: '300'
|
|
126
134
|
}
|
|
127
135
|
},
|
|
@@ -141,21 +149,6 @@ var DonutChart = function DonutChart(props) {
|
|
|
141
149
|
icon: 'shape'
|
|
142
150
|
},
|
|
143
151
|
series: [{
|
|
144
|
-
name: 'background',
|
|
145
|
-
type: 'pie',
|
|
146
|
-
radius: donutRadius,
|
|
147
|
-
data: data,
|
|
148
|
-
animation: false,
|
|
149
|
-
center: center || ['50%', '50%'],
|
|
150
|
-
label: {
|
|
151
|
-
color: 'black',
|
|
152
|
-
position: 'center',
|
|
153
|
-
formatter: donutCenterValue || (0, _auxiliarFunctions.thousandSeparator)(totalValues),
|
|
154
|
-
fontFamily: 'Roboto, Helvetica, Arial, sans-serif',
|
|
155
|
-
fontSize: centerPieValueFontSize || 24,
|
|
156
|
-
fontWeight: '300'
|
|
157
|
-
}
|
|
158
|
-
}, {
|
|
159
152
|
name: 'first',
|
|
160
153
|
type: 'pie',
|
|
161
154
|
radius: donutRadius,
|
|
@@ -179,11 +172,22 @@ var DonutChart = function DonutChart(props) {
|
|
|
179
172
|
borderColor: pieceBorderColor || 'white'
|
|
180
173
|
}
|
|
181
174
|
};
|
|
182
|
-
|
|
183
|
-
|
|
175
|
+
|
|
176
|
+
var TitleChart = function TitleChart() {
|
|
177
|
+
return /*#__PURE__*/_react.default.createElement("h1", {
|
|
178
|
+
style: titleStyle
|
|
179
|
+
}, titleProps);
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
183
|
+
style: {
|
|
184
|
+
position: 'relative'
|
|
185
|
+
}
|
|
186
|
+
}, title && /*#__PURE__*/_react.default.createElement(TitleChart, null), /*#__PURE__*/_react.default.createElement(_echartsForReact.default, {
|
|
187
|
+
style: _objectSpread({}, WIDTH_STYLE),
|
|
184
188
|
opts: (0, _auxiliarFunctions.getWidthOpts)(width),
|
|
185
189
|
option: options
|
|
186
|
-
});
|
|
190
|
+
}));
|
|
187
191
|
};
|
|
188
192
|
|
|
189
193
|
exports.DonutChart = DonutChart;
|
|
@@ -33,7 +33,7 @@ var takeLabelComplement = function takeLabelComplement(item, yComplement, typeCh
|
|
|
33
33
|
exports.takeLabelComplement = takeLabelComplement;
|
|
34
34
|
|
|
35
35
|
var takeDonutChartComplement = function takeDonutChartComplement(item, complement) {
|
|
36
|
-
return item === 0 && typeof complement === 'function' ? '' : "".concat(item, "
|
|
36
|
+
return item === 0 && typeof complement === 'function' ? '' : "".concat(item, " ").concat(complement ? "(".concat(complement, ")") : '');
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
exports.takeDonutChartComplement = takeDonutChartComplement;
|
package/package.json
CHANGED
package/src/core/DonutChart.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react'
|
|
1
|
+
import React, { CSSProperties, useEffect, useState } from 'react'
|
|
2
2
|
import ReactEcharts from 'echarts-for-react'
|
|
3
3
|
import { IProps } from './PieChart'
|
|
4
4
|
import { PieChartData, PieDataLabel } from './types'
|
|
@@ -23,6 +23,16 @@ interface IDonutProps extends IProps {
|
|
|
23
23
|
|
|
24
24
|
export const WIDTH_STYLE = { width: '99.9%' }
|
|
25
25
|
|
|
26
|
+
const titleStyle: CSSProperties = {
|
|
27
|
+
position: 'absolute',
|
|
28
|
+
top: 5,
|
|
29
|
+
margin: 0,
|
|
30
|
+
fontFamily: 'Roboto, Helvetica, Arial, sans-serif',
|
|
31
|
+
fontSize: 16,
|
|
32
|
+
fontWeight: 300,
|
|
33
|
+
color: 'black'
|
|
34
|
+
}
|
|
35
|
+
|
|
26
36
|
export const DonutChart = (props: IDonutProps) => {
|
|
27
37
|
const {
|
|
28
38
|
title: titleProps,
|
|
@@ -113,14 +123,13 @@ export const DonutChart = (props: IDonutProps) => {
|
|
|
113
123
|
grid: grid,
|
|
114
124
|
color: colors,
|
|
115
125
|
title: {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
text: titleProps,
|
|
126
|
+
top: 'middle',
|
|
127
|
+
left: 'center',
|
|
128
|
+
text: donutCenterValue || thousandSeparator(totalValues),
|
|
120
129
|
textAlign: 'left',
|
|
121
130
|
textStyle: {
|
|
122
131
|
fontFamily: 'Roboto, Helvetica, Arial, sans-serif',
|
|
123
|
-
fontSize:
|
|
132
|
+
fontSize: centerPieValueFontSize || 24,
|
|
124
133
|
fontWeight: '300' as const
|
|
125
134
|
}
|
|
126
135
|
},
|
|
@@ -138,22 +147,6 @@ export const DonutChart = (props: IDonutProps) => {
|
|
|
138
147
|
icon: 'shape'
|
|
139
148
|
},
|
|
140
149
|
series: [
|
|
141
|
-
{
|
|
142
|
-
name: 'background',
|
|
143
|
-
type: 'pie',
|
|
144
|
-
radius: donutRadius,
|
|
145
|
-
data: data,
|
|
146
|
-
animation: false,
|
|
147
|
-
center: center || ['50%', '50%'],
|
|
148
|
-
label: {
|
|
149
|
-
color: 'black',
|
|
150
|
-
position: 'center',
|
|
151
|
-
formatter: donutCenterValue || thousandSeparator(totalValues),
|
|
152
|
-
fontFamily: 'Roboto, Helvetica, Arial, sans-serif',
|
|
153
|
-
fontSize: centerPieValueFontSize || 24,
|
|
154
|
-
fontWeight: '300' as const
|
|
155
|
-
}
|
|
156
|
-
},
|
|
157
150
|
{
|
|
158
151
|
name: 'first',
|
|
159
152
|
type: 'pie',
|
|
@@ -174,19 +167,24 @@ export const DonutChart = (props: IDonutProps) => {
|
|
|
174
167
|
length: 4,
|
|
175
168
|
length2: 4
|
|
176
169
|
}
|
|
177
|
-
}
|
|
170
|
+
},
|
|
178
171
|
],
|
|
179
172
|
itemStyle: {
|
|
180
173
|
borderColor: pieceBorderColor || 'white'
|
|
181
174
|
}
|
|
182
175
|
}
|
|
183
176
|
|
|
177
|
+
const TitleChart = () => <h1 style={titleStyle}>{titleProps}</h1>
|
|
178
|
+
|
|
184
179
|
return (
|
|
185
|
-
<
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
180
|
+
<div style={{ position: 'relative'}}>
|
|
181
|
+
{title && <TitleChart />}
|
|
182
|
+
<ReactEcharts
|
|
183
|
+
style={{...WIDTH_STYLE}}
|
|
184
|
+
opts={getWidthOpts(width)}
|
|
185
|
+
option={options}
|
|
186
|
+
/>
|
|
187
|
+
</div>
|
|
190
188
|
)
|
|
191
189
|
}
|
|
192
190
|
|
|
@@ -38,7 +38,7 @@ export const takeDonutChartComplement = (
|
|
|
38
38
|
complement?: Complement
|
|
39
39
|
) => item === 0 && typeof complement === 'function'
|
|
40
40
|
? ''
|
|
41
|
-
: `${item} (${complement
|
|
41
|
+
: `${item} ${complement ? `(${complement})` : ''}`
|
|
42
42
|
|
|
43
43
|
export const timeConvert = (value: number) => {
|
|
44
44
|
const hrs = Math.floor(value)
|