@easyv/charts 1.5.5 → 1.5.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.
- package/lib/components/Axis.js +4 -2
- package/lib/components/Band.js +3 -2
- package/lib/components/StereoBar.js +3 -3
- package/lib/hooks/useAxes.js +2 -0
- package/package.json +1 -1
- package/src/components/Axis.tsx +4 -2
- package/src/components/Band.tsx +4 -3
- package/src/components/Chart.js +0 -3
- package/src/components/StereoBar.tsx +3 -4
- package/src/components/TextOverflow.tsx +1 -1
- package/src/hooks/useAxes.js +2 -1
- package/src/types/index.d.ts +1 -0
package/lib/components/Axis.js
CHANGED
|
@@ -199,6 +199,8 @@ var Label = function Label(_ref5) {
|
|
|
199
199
|
translateX = _ref5$config$translat.x,
|
|
200
200
|
translateY = _ref5$config$translat.y,
|
|
201
201
|
font = _ref5$config.font,
|
|
202
|
+
_ref5$config$textAlig = _ref5$config.textAlign,
|
|
203
|
+
textAlign = _ref5$config$textAlig === void 0 ? "center" : _ref5$config$textAlig,
|
|
202
204
|
_ref5$config$appearan = _ref5$config.appearance;
|
|
203
205
|
_ref5$config$appearan = _ref5$config$appearan === void 0 ? defaultAppearance : _ref5$config$appearan;
|
|
204
206
|
var width = _ref5$config$appearan.width,
|
|
@@ -241,8 +243,8 @@ var Label = function Label(_ref5) {
|
|
|
241
243
|
style: {
|
|
242
244
|
width: width,
|
|
243
245
|
transform: transform,
|
|
244
|
-
textAlign:
|
|
245
|
-
justifyContent: "center"
|
|
246
|
+
textAlign: textAlign,
|
|
247
|
+
justifyContent: textAlign == "left" ? "flex-start" : textAlign == "right" ? "flex-end" : "center"
|
|
246
248
|
}
|
|
247
249
|
})));
|
|
248
250
|
};
|
package/lib/components/Band.js
CHANGED
|
@@ -120,7 +120,8 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref3) {
|
|
|
120
120
|
_ref3$yAxis = _ref3.yAxis,
|
|
121
121
|
yScaler = _ref3$yAxis.scaler,
|
|
122
122
|
isClipAxis = _ref3$yAxis.isClipAxis,
|
|
123
|
-
clipValue = _ref3$yAxis.clipValue
|
|
123
|
+
clipValue = _ref3$yAxis.clipValue,
|
|
124
|
+
reverse = _ref3$yAxis.reverse;
|
|
124
125
|
if (!data.length) return null;
|
|
125
126
|
var step = isControlChart ? controlStep : normalStep;
|
|
126
127
|
var xScaler = isControlChart ? controlDragScaler : normalScaler;
|
|
@@ -192,7 +193,7 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref3) {
|
|
|
192
193
|
};
|
|
193
194
|
|
|
194
195
|
if (isNaN(positionX)) return null;
|
|
195
|
-
var positionY = y < 0 ? y1 : y2;
|
|
196
|
+
var positionY = reverse ? y > 0 ? y1 : y2 : y < 0 ? y1 : y2;
|
|
196
197
|
var attr = getAttr({
|
|
197
198
|
isVertical: isVertical,
|
|
198
199
|
x: positionX,
|
|
@@ -109,7 +109,7 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref3) {
|
|
|
109
109
|
step = _ref3$xAxis.step,
|
|
110
110
|
direction = _ref3$xAxis.direction,
|
|
111
111
|
yScaler = _ref3.yAxis.scaler,
|
|
112
|
-
|
|
112
|
+
name = _ref3.name;
|
|
113
113
|
if (!data.length) return null;
|
|
114
114
|
|
|
115
115
|
var _getSeriesInfo = (0, _utils.getSeriesInfo)({
|
|
@@ -125,8 +125,8 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref3) {
|
|
|
125
125
|
var _data = showHighlight ? getHighlightData(data, extent) : data;
|
|
126
126
|
|
|
127
127
|
var isVertical = direction === 'vertical';
|
|
128
|
-
var highlightColor = parseMultiColorToSVG(highlightFill, 'highlight_gradient_' + id + '_' +
|
|
129
|
-
var color = parseMultiColorToSVG(fill, 'gradient_' + id + '_' +
|
|
128
|
+
var highlightColor = parseMultiColorToSVG(highlightFill, 'highlight_gradient_' + id + '_' + name);
|
|
129
|
+
var color = parseMultiColorToSVG(fill, 'gradient_' + id + '_' + name);
|
|
130
130
|
return /*#__PURE__*/_react["default"].createElement("g", {
|
|
131
131
|
className: "__easyv-band"
|
|
132
132
|
}, /*#__PURE__*/_react["default"].createElement("defs", null, /*#__PURE__*/_react["default"].createElement("filter", {
|
package/lib/hooks/useAxes.js
CHANGED
|
@@ -125,6 +125,7 @@ var _default = function _default(_ref) {
|
|
|
125
125
|
type = item.type,
|
|
126
126
|
orientation = item.orientation,
|
|
127
127
|
ticks = item.ticks,
|
|
128
|
+
reverse = item.reverse,
|
|
128
129
|
_item$tickCount = item.tickCount,
|
|
129
130
|
count = _item$tickCount === void 0 ? 1 : _item$tickCount,
|
|
130
131
|
_item$step = item.step,
|
|
@@ -331,6 +332,7 @@ var _default = function _default(_ref) {
|
|
|
331
332
|
_length = _getChartsConfig2.length;
|
|
332
333
|
|
|
333
334
|
var range = _direction === "horizontal" ? [_start, _end] : _direction === "vertical" ? [_end, _start] : [0, 0];
|
|
335
|
+
if (reverse) range = [range[1], range[0]];
|
|
334
336
|
var newDomain = domain;
|
|
335
337
|
var fixedDomain = extent && extent.min != "" && extent.max != ""; //判断配置项中是否强制了最大最小值,如果已经被强制了,就不计算newDomain
|
|
336
338
|
|
package/package.json
CHANGED
package/src/components/Axis.tsx
CHANGED
|
@@ -184,6 +184,7 @@ type LabelType = {
|
|
|
184
184
|
show: boolean;
|
|
185
185
|
translate: Translate;
|
|
186
186
|
font: Font;
|
|
187
|
+
textAlign: TextAlign;
|
|
187
188
|
style: CSSProperties | Function;
|
|
188
189
|
appearance?: appearance;
|
|
189
190
|
};
|
|
@@ -206,6 +207,7 @@ const Label: (
|
|
|
206
207
|
style,
|
|
207
208
|
translate: { x: translateX, y: translateY },
|
|
208
209
|
font,
|
|
210
|
+
textAlign = "center",
|
|
209
211
|
appearance: { width, speed, textOverflow } = defaultAppearance,
|
|
210
212
|
},
|
|
211
213
|
}) => {
|
|
@@ -245,8 +247,8 @@ const Label: (
|
|
|
245
247
|
style={{
|
|
246
248
|
width,
|
|
247
249
|
transform,
|
|
248
|
-
textAlign
|
|
249
|
-
justifyContent: "center",
|
|
250
|
+
textAlign,
|
|
251
|
+
justifyContent: textAlign=="left"?"flex-start":textAlign=="right"?"flex-end":"center",
|
|
250
252
|
}}
|
|
251
253
|
></TextOverflow>
|
|
252
254
|
</div>
|
package/src/components/Band.tsx
CHANGED
|
@@ -88,7 +88,7 @@ export default memo(
|
|
|
88
88
|
bandLength = 0,
|
|
89
89
|
data,
|
|
90
90
|
xAxis: { scaler: normalScaler, step:normalStep, controlStep, direction, controlDragScaler },
|
|
91
|
-
yAxis: { scaler: yScaler, isClipAxis, clipValue },
|
|
91
|
+
yAxis: { scaler: yScaler, isClipAxis, clipValue, reverse },
|
|
92
92
|
}: any) => {
|
|
93
93
|
if (!data.length) return null;
|
|
94
94
|
const step = isControlChart?controlStep:normalStep;
|
|
@@ -99,7 +99,6 @@ export default memo(
|
|
|
99
99
|
paddingInner,
|
|
100
100
|
paddingOuter,
|
|
101
101
|
});
|
|
102
|
-
|
|
103
102
|
const _data = showHighlight ? getHighlightData(data, extent) : data;
|
|
104
103
|
const isVertical = direction === "vertical";
|
|
105
104
|
const borderStr = `${border.borderColor} solid ${border.borderWidth}px`;
|
|
@@ -155,7 +154,9 @@ export default memo(
|
|
|
155
154
|
}
|
|
156
155
|
};
|
|
157
156
|
if (isNaN(positionX)) return null;
|
|
158
|
-
const positionY =
|
|
157
|
+
const positionY = reverse?
|
|
158
|
+
y > 0 ? y1 : y2:
|
|
159
|
+
y < 0 ? y1 : y2;
|
|
159
160
|
const attr = getAttr({
|
|
160
161
|
isVertical,
|
|
161
162
|
x: positionX,
|
package/src/components/Chart.js
CHANGED
|
@@ -90,8 +90,6 @@ const Chart = memo(
|
|
|
90
90
|
[id, chartWidth, chartHeight, triggerOnRelative, svg, onEmit]
|
|
91
91
|
);
|
|
92
92
|
|
|
93
|
-
|
|
94
|
-
|
|
95
93
|
useEffect(()=>{
|
|
96
94
|
const activeHandler=(e)=>{
|
|
97
95
|
const { dynamicData = true } = e;
|
|
@@ -104,7 +102,6 @@ const Chart = memo(
|
|
|
104
102
|
}
|
|
105
103
|
},[]);
|
|
106
104
|
|
|
107
|
-
|
|
108
105
|
//对轴类图表进行
|
|
109
106
|
let data = originData;
|
|
110
107
|
if(axes){
|
|
@@ -80,10 +80,9 @@ export default memo(
|
|
|
80
80
|
data,
|
|
81
81
|
xAxis: { scaler: xScaler, step, direction },
|
|
82
82
|
yAxis: { scaler: yScaler },
|
|
83
|
-
|
|
83
|
+
name
|
|
84
84
|
}: any) => {
|
|
85
85
|
if (!data.length) return null;
|
|
86
|
-
|
|
87
86
|
const { seriesWidth, seriesStep, seriesStart } = getSeriesInfo({
|
|
88
87
|
step,
|
|
89
88
|
bandLength,
|
|
@@ -96,11 +95,11 @@ export default memo(
|
|
|
96
95
|
|
|
97
96
|
const highlightColor = parseMultiColorToSVG(
|
|
98
97
|
highlightFill,
|
|
99
|
-
'highlight_gradient_' + id + '_' +
|
|
98
|
+
'highlight_gradient_' + id + '_' + name
|
|
100
99
|
);
|
|
101
100
|
const color = parseMultiColorToSVG(
|
|
102
101
|
fill,
|
|
103
|
-
'gradient_' + id + '_' +
|
|
102
|
+
'gradient_' + id + '_' + name
|
|
104
103
|
);
|
|
105
104
|
return (
|
|
106
105
|
<g className='__easyv-band'>
|
package/src/hooks/useAxes.js
CHANGED
|
@@ -87,6 +87,7 @@ export default ({
|
|
|
87
87
|
type,
|
|
88
88
|
orientation,
|
|
89
89
|
ticks,
|
|
90
|
+
reverse,
|
|
90
91
|
tickCount: count = 1,
|
|
91
92
|
step = 1,
|
|
92
93
|
domain,
|
|
@@ -332,13 +333,13 @@ export default ({
|
|
|
332
333
|
//计算真正需要的tickCount,如果domain区间太小,不能完全按照count来,需要减少count数
|
|
333
334
|
const tickCount = type == "ordinal" ? _count : getTickCount(domain, _count, decimal);
|
|
334
335
|
const { start, end, direction, _paddingOuter, length } = getChartsConfig(orientation, width, height, paddingOuter);
|
|
335
|
-
|
|
336
336
|
let range =
|
|
337
337
|
direction === "horizontal"
|
|
338
338
|
? [start, end]
|
|
339
339
|
: direction === "vertical"
|
|
340
340
|
? [end, start]
|
|
341
341
|
: [0, 0];
|
|
342
|
+
if(reverse)range = [range[1],range[0]];
|
|
342
343
|
let newDomain = domain;
|
|
343
344
|
const fixedDomain = extent && extent.min!="" && extent.max!=""; //判断配置项中是否强制了最大最小值,如果已经被强制了,就不计算newDomain
|
|
344
345
|
if (type !== "ordinal" && !isNaN(domain[1]) && !auto && !fixedDomain) {
|