Skip to content

Commit 74e051d

Browse files
authored
Merge pull request esnet#306 from esnet/fix-issues
Fix pending issues
2 parents 4312901 + a33e673 commit 74e051d

28 files changed

+852
-324
lines changed

CHANGES.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
# Changelog
22

3+
## v0.15.3
4+
5+
> Aug 15, 2018
6+
7+
* Add feature to add style prop to `LabelAxis` component
8+
* Refactor `AreaChart` code
9+
10+
Bug fixes:
11+
12+
* Corrects the wrong order for testing style type (Fixes [#277](https://github.com/esnet/react-timeseries-charts/issues/277))
13+
* Correctly stacking in area charts when some points are bad (Fixes [#284](https://github.com/esnet/react-timeseries-charts/issues/284))
14+
* Adds prop to hide TimeAxis (Fixes [#295](https://github.com/esnet/react-timeseries-charts/issues/295))
15+
* Adds function argument while styling barcharts (Fixes [#291](https://github.com/esnet/react-timeseries-charts/issues/291))
16+
* Adds a prop `marginBottom` to the `Legend` component (Fixes [#243](https://github.com/esnet/react-timeseries-charts/issues/243))
17+
* Doesn't draw a `BarChart` when the height of the rectangle is 0 (Fixes [#294](https://github.com/esnet/react-timeseries-charts/issues/294))
18+
* Removes warnings on climate example (Fixes [#257](https://github.com/esnet/react-timeseries-charts/issues/257))
19+
* Exposes x, y and time value to onBackgroundClick method in `ChartContainer` (Fixes [#296](https://github.com/esnet/react-timeseries-charts/issues/296))
20+
* TimeMarker can be custom styled (Fixes [#304](https://github.com/esnet/react-timeseries-charts/issues/304))
21+
* Ability to style legend (Fixes [#112](https://github.com/esnet/react-timeseries-charts/issues/112))
22+
323
## v0.15.0
424

525
> May 22, 2018

lib/components/AreaChart.js

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -241,14 +241,14 @@ var AreaChart = (function(_React$Component) {
241241
{
242242
key: "providedAreaStyleMap",
243243
value: function providedAreaStyleMap(column) {
244-
var style = defaultStyle;
244+
var style = {};
245245
if (this.props.style) {
246246
if (this.props.style instanceof _styler.Styler) {
247247
style = this.props.style.areaChartStyle()[column];
248-
} else if (_underscore2.default.isObject(this.props.style)) {
249-
style = this.props.style[column];
250248
} else if (_underscore2.default.isFunction(this.props.style)) {
251249
style = this.props.style(column);
250+
} else if (_underscore2.default.isObject(this.props.style)) {
251+
style = this.props.style ? this.props.style[column] : defaultStyle;
252252
}
253253
}
254254
return style;
@@ -422,28 +422,19 @@ var AreaChart = (function(_React$Component) {
422422
_underscore2.default.isNull(value) ||
423423
_underscore2.default.isNaN(value) ||
424424
!_underscore2.default.isFinite(value);
425+
if (badPoint) value = 0;
425426

426427
// Case 1:
427428
// When stacking is present with multiple area charts, then mark bad points as 0
428429
if (len > 1) {
429430
if (!currentPoints) currentPoints = [];
430-
if (!badPoint) {
431-
currentPoints.push({
432-
x0: _this3.props.timeScale(seriesPoint.timestamp()),
433-
y0: _this3.props.yScale(offsets[j]),
434-
y1: _this3.props.yScale(
435-
offsets[j] + dir * seriesPoint.get(column)
436-
)
437-
});
438-
} else {
439-
currentPoints.push({
440-
x0: _this3.props.timeScale(seriesPoint.timestamp()),
441-
y0: _this3.props.yScale(offsets[j]),
442-
y1: _this3.props.yScale(offsets[j])
443-
});
444-
}
431+
currentPoints.push({
432+
x0: _this3.props.timeScale(seriesPoint.timestamp()),
433+
y0: _this3.props.yScale(offsets[j]),
434+
y1: _this3.props.yScale(offsets[j] + dir * value)
435+
});
445436
if (_this3.props.stack) {
446-
offsets[j] += dir * seriesPoint.get(column);
437+
offsets[j] += dir * value;
447438
}
448439
}
449440
// Case Two
@@ -454,12 +445,10 @@ var AreaChart = (function(_React$Component) {
454445
currentPoints.push({
455446
x0: _this3.props.timeScale(seriesPoint.timestamp()),
456447
y0: _this3.props.yScale(offsets[j]),
457-
y1: _this3.props.yScale(
458-
offsets[j] + dir * seriesPoint.get(column)
459-
)
448+
y1: _this3.props.yScale(offsets[j] + dir * value)
460449
});
461450
if (_this3.props.stack) {
462-
offsets[j] += dir * seriesPoint.get(column);
451+
offsets[j] += dir * value;
463452
}
464453
} else if (currentPoints) {
465454
if (currentPoints.length > 1) {
@@ -490,12 +479,10 @@ var AreaChart = (function(_React$Component) {
490479
cleanedPoints.push({
491480
x0: _this3.props.timeScale(_seriesPoint.timestamp()),
492481
y0: _this3.props.yScale(offsets[_j]),
493-
y1: _this3.props.yScale(
494-
offsets[_j] + dir * _seriesPoint.get(column)
495-
)
482+
y1: _this3.props.yScale(offsets[_j] + dir * _value)
496483
});
497484
if (_this3.props.stack) {
498-
offsets[_j] += dir * _seriesPoint.get(column);
485+
offsets[_j] += dir * _value;
499486
}
500487
}
501488
}

lib/components/BandChart.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ var BandChart = (function(_React$Component) {
434434
{
435435
key: "providedStyleArray",
436436
value: function providedStyleArray(column) {
437-
var style = defaultStyle;
437+
var style = {};
438438
if (this.props.style) {
439439
if (this.props.style instanceof _styler.Styler) {
440440
style = this.props.style.boxChartStyle()[column];

lib/components/BarChart.js

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -258,13 +258,13 @@ var BarChart = (function(_React$Component) {
258258
},
259259
{
260260
key: "providedStyleMap",
261-
value: function providedStyleMap(column) {
261+
value: function providedStyleMap(column, event) {
262262
var style = {};
263263
if (this.props.style) {
264264
if (this.props.style instanceof _styler.Styler) {
265265
style = this.props.style.barChartStyle()[column];
266266
} else if (_underscore2.default.isFunction(this.props.style)) {
267-
style = this.props.style(column);
267+
style = this.props.style(column, event);
268268
} else if (_underscore2.default.isObject(this.props.style)) {
269269
style = this.props.style ? this.props.style[column] : defaultStyle;
270270
}
@@ -280,12 +280,14 @@ var BarChart = (function(_React$Component) {
280280
key: "style",
281281
value: function style(column, event) {
282282
var style = void 0;
283-
var styleMap = this.providedStyleMap(column);
283+
var styleMap = this.providedStyleMap(column, event);
284284

285285
var isHighlighted =
286286
this.props.highlighted &&
287-
column === this.props.highlighted.column &&
288-
_pondjs.Event.is(this.props.highlighted.event, event);
287+
((column === this.props.highlighted.column &&
288+
_pondjs.Event.is(this.props.highlighted.event, event)) ||
289+
(this.props.highlightEntireEvent &&
290+
_pondjs.Event.is(this.props.highlighted.event, event)));
289291

290292
var isSelected =
291293
this.props.selected &&
@@ -401,6 +403,9 @@ var BarChart = (function(_React$Component) {
401403
height = Math.max(Math.abs(height), minBarHeight);
402404
var y = positiveBar ? yposPositive - height : yposNegative;
403405

406+
// Don't draw a rect when height and minBarHeight are both 0
407+
if (height === 0) return "break";
408+
404409
// Event marker if info provided and hovering
405410
var isHighlighted =
406411
_this2.props.highlighted &&
@@ -452,7 +457,9 @@ var BarChart = (function(_React$Component) {
452457
.done);
453458
_iteratorNormalCompletion2 = true
454459
) {
455-
_loop2();
460+
var _ret2 = _loop2();
461+
462+
if (_ret2 === "break") break;
456463
}
457464
} catch (err) {
458465
_didIteratorError2 = true;
@@ -543,6 +550,12 @@ BarChart.propTypes = {
543550
*/
544551
columns: _propTypes2.default.arrayOf(_propTypes2.default.string),
545552

553+
/**
554+
* When true, the entire `highlighted` event will be highlighted, instead of
555+
* only the column bar that's currently being hovered
556+
*/
557+
highlightEntireEvent: _propTypes2.default.bool,
558+
546559
/**
547560
* The style of the bar chart drawing (using SVG CSS properties).
548561
* This is an object with a key for each column which is being drawn,
@@ -693,6 +706,7 @@ BarChart.propTypes = {
693706
BarChart.defaultProps = {
694707
visible: true,
695708
columns: ["value"],
709+
highlightEntireEvent: false,
696710
spacing: 1.0,
697711
offset: 0,
698712
minBarHeight: 1,

lib/components/BoxChart.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ var BoxChart = (function(_React$Component) {
442442
{
443443
key: "providedStyleArray",
444444
value: function providedStyleArray(column) {
445-
var style = defaultStyle;
445+
var style = {};
446446
if (this.props.style) {
447447
if (this.props.style instanceof _styler.Styler) {
448448
style = this.props.style.boxChartStyle()[column];

0 commit comments

Comments
 (0)