Skip to content

Commit

Permalink
Merge pull request #306 from esnet/fix-issues
Browse files Browse the repository at this point in the history
Fix pending issues
  • Loading branch information
sartaj10 authored Aug 15, 2018
2 parents 4312901 + a33e673 commit 74e051d
Show file tree
Hide file tree
Showing 28 changed files with 852 additions and 324 deletions.
20 changes: 20 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# Changelog

## v0.15.3

> Aug 15, 2018
* Add feature to add style prop to `LabelAxis` component
* Refactor `AreaChart` code

Bug fixes:

* Corrects the wrong order for testing style type (Fixes [#277](https://github.com/esnet/react-timeseries-charts/issues/277))
* Correctly stacking in area charts when some points are bad (Fixes [#284](https://github.com/esnet/react-timeseries-charts/issues/284))
* Adds prop to hide TimeAxis (Fixes [#295](https://github.com/esnet/react-timeseries-charts/issues/295))
* Adds function argument while styling barcharts (Fixes [#291](https://github.com/esnet/react-timeseries-charts/issues/291))
* Adds a prop `marginBottom` to the `Legend` component (Fixes [#243](https://github.com/esnet/react-timeseries-charts/issues/243))
* Doesn't draw a `BarChart` when the height of the rectangle is 0 (Fixes [#294](https://github.com/esnet/react-timeseries-charts/issues/294))
* Removes warnings on climate example (Fixes [#257](https://github.com/esnet/react-timeseries-charts/issues/257))
* Exposes x, y and time value to onBackgroundClick method in `ChartContainer` (Fixes [#296](https://github.com/esnet/react-timeseries-charts/issues/296))
* TimeMarker can be custom styled (Fixes [#304](https://github.com/esnet/react-timeseries-charts/issues/304))
* Ability to style legend (Fixes [#112](https://github.com/esnet/react-timeseries-charts/issues/112))

## v0.15.0

> May 22, 2018
Expand Down
41 changes: 14 additions & 27 deletions lib/components/AreaChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,14 +241,14 @@ var AreaChart = (function(_React$Component) {
{
key: "providedAreaStyleMap",
value: function providedAreaStyleMap(column) {
var style = defaultStyle;
var style = {};
if (this.props.style) {
if (this.props.style instanceof _styler.Styler) {
style = this.props.style.areaChartStyle()[column];
} else if (_underscore2.default.isObject(this.props.style)) {
style = this.props.style[column];
} else if (_underscore2.default.isFunction(this.props.style)) {
style = this.props.style(column);
} else if (_underscore2.default.isObject(this.props.style)) {
style = this.props.style ? this.props.style[column] : defaultStyle;
}
}
return style;
Expand Down Expand Up @@ -422,28 +422,19 @@ var AreaChart = (function(_React$Component) {
_underscore2.default.isNull(value) ||
_underscore2.default.isNaN(value) ||
!_underscore2.default.isFinite(value);
if (badPoint) value = 0;

// Case 1:
// When stacking is present with multiple area charts, then mark bad points as 0
if (len > 1) {
if (!currentPoints) currentPoints = [];
if (!badPoint) {
currentPoints.push({
x0: _this3.props.timeScale(seriesPoint.timestamp()),
y0: _this3.props.yScale(offsets[j]),
y1: _this3.props.yScale(
offsets[j] + dir * seriesPoint.get(column)
)
});
} else {
currentPoints.push({
x0: _this3.props.timeScale(seriesPoint.timestamp()),
y0: _this3.props.yScale(offsets[j]),
y1: _this3.props.yScale(offsets[j])
});
}
currentPoints.push({
x0: _this3.props.timeScale(seriesPoint.timestamp()),
y0: _this3.props.yScale(offsets[j]),
y1: _this3.props.yScale(offsets[j] + dir * value)
});
if (_this3.props.stack) {
offsets[j] += dir * seriesPoint.get(column);
offsets[j] += dir * value;
}
}
// Case Two
Expand All @@ -454,12 +445,10 @@ var AreaChart = (function(_React$Component) {
currentPoints.push({
x0: _this3.props.timeScale(seriesPoint.timestamp()),
y0: _this3.props.yScale(offsets[j]),
y1: _this3.props.yScale(
offsets[j] + dir * seriesPoint.get(column)
)
y1: _this3.props.yScale(offsets[j] + dir * value)
});
if (_this3.props.stack) {
offsets[j] += dir * seriesPoint.get(column);
offsets[j] += dir * value;
}
} else if (currentPoints) {
if (currentPoints.length > 1) {
Expand Down Expand Up @@ -490,12 +479,10 @@ var AreaChart = (function(_React$Component) {
cleanedPoints.push({
x0: _this3.props.timeScale(_seriesPoint.timestamp()),
y0: _this3.props.yScale(offsets[_j]),
y1: _this3.props.yScale(
offsets[_j] + dir * _seriesPoint.get(column)
)
y1: _this3.props.yScale(offsets[_j] + dir * _value)
});
if (_this3.props.stack) {
offsets[_j] += dir * _seriesPoint.get(column);
offsets[_j] += dir * _value;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/components/BandChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ var BandChart = (function(_React$Component) {
{
key: "providedStyleArray",
value: function providedStyleArray(column) {
var style = defaultStyle;
var style = {};
if (this.props.style) {
if (this.props.style instanceof _styler.Styler) {
style = this.props.style.boxChartStyle()[column];
Expand Down
26 changes: 20 additions & 6 deletions lib/components/BarChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,13 @@ var BarChart = (function(_React$Component) {
},
{
key: "providedStyleMap",
value: function providedStyleMap(column) {
value: function providedStyleMap(column, event) {
var style = {};
if (this.props.style) {
if (this.props.style instanceof _styler.Styler) {
style = this.props.style.barChartStyle()[column];
} else if (_underscore2.default.isFunction(this.props.style)) {
style = this.props.style(column);
style = this.props.style(column, event);
} else if (_underscore2.default.isObject(this.props.style)) {
style = this.props.style ? this.props.style[column] : defaultStyle;
}
Expand All @@ -280,12 +280,14 @@ var BarChart = (function(_React$Component) {
key: "style",
value: function style(column, event) {
var style = void 0;
var styleMap = this.providedStyleMap(column);
var styleMap = this.providedStyleMap(column, event);

var isHighlighted =
this.props.highlighted &&
column === this.props.highlighted.column &&
_pondjs.Event.is(this.props.highlighted.event, event);
((column === this.props.highlighted.column &&
_pondjs.Event.is(this.props.highlighted.event, event)) ||
(this.props.highlightEntireEvent &&
_pondjs.Event.is(this.props.highlighted.event, event)));

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

// Don't draw a rect when height and minBarHeight are both 0
if (height === 0) return "break";

// Event marker if info provided and hovering
var isHighlighted =
_this2.props.highlighted &&
Expand Down Expand Up @@ -452,7 +457,9 @@ var BarChart = (function(_React$Component) {
.done);
_iteratorNormalCompletion2 = true
) {
_loop2();
var _ret2 = _loop2();

if (_ret2 === "break") break;
}
} catch (err) {
_didIteratorError2 = true;
Expand Down Expand Up @@ -543,6 +550,12 @@ BarChart.propTypes = {
*/
columns: _propTypes2.default.arrayOf(_propTypes2.default.string),

/**
* When true, the entire `highlighted` event will be highlighted, instead of
* only the column bar that's currently being hovered
*/
highlightEntireEvent: _propTypes2.default.bool,

/**
* The style of the bar chart drawing (using SVG CSS properties).
* This is an object with a key for each column which is being drawn,
Expand Down Expand Up @@ -693,6 +706,7 @@ BarChart.propTypes = {
BarChart.defaultProps = {
visible: true,
columns: ["value"],
highlightEntireEvent: false,
spacing: 1.0,
offset: 0,
minBarHeight: 1,
Expand Down
2 changes: 1 addition & 1 deletion lib/components/BoxChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ var BoxChart = (function(_React$Component) {
{
key: "providedStyleArray",
value: function providedStyleArray(column) {
var style = defaultStyle;
var style = {};
if (this.props.style) {
if (this.props.style instanceof _styler.Styler) {
style = this.props.style.boxChartStyle()[column];
Expand Down
Loading

0 comments on commit 74e051d

Please sign in to comment.