Skip to content

Commit fc5c640

Browse files
committed
revert legend change but keep it as well
1 parent 928d8df commit fc5c640

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-chartjs-2",
3-
"version": "2.5.0",
3+
"version": "2.5.2",
44
"description": "react-chartjs-2",
55
"main": "lib/index.js",
66
"author": "Goran Udosic",

src/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,10 @@ class ChartComponent extends React.Component {
250250
const {options, legend, type, redraw, plugins} = this.props;
251251
const node = this.element;
252252
const data = this.memoizeDataProps();
253-
options.legend = legend;
253+
254+
if(typeof legend !== 'undefined' && !isEqual(ChartComponent.defaultProps.legend, legend)) {
255+
options.legend = legend;
256+
}
254257

255258
this.chart_instance = new Chart(node, {
256259
type,

test/__tests__/Chart_spec.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ describe('<Chart />', () => {
3636
});
3737

3838
const mountComponent = props => mount(
39-
<Chart data={data} {...props} />,
40-
{ attachTo: DOM.body.firstChild }
39+
<Chart data={data} {...props} />,
40+
{ attachTo: DOM.body.firstChild }
4141
);
4242

4343
beforeEach(() => {
@@ -122,15 +122,14 @@ describe('<Chart />', () => {
122122
it('renders on props.options change', () => {
123123
const spy = sinon.spy(Chart.prototype, 'render');
124124
const wrapper = mountComponent({ options: {} });
125-
const defaultLegendOpts = wrapper.prop('legend');
126125

127126
expect(spy.callCount).to.equal(1);
128127

129-
wrapper.setProps({ options: { legend: defaultLegendOpts } });
128+
wrapper.setProps({ options: {} });
130129

131130
expect(spy.callCount).to.equal(1);
132131

133-
wrapper.setProps({ options: { legend: defaultLegendOpts, a: 1 } });
132+
wrapper.setProps({ options: { a: 1 } });
134133

135134
expect(spy.callCount).to.equal(2);
136135

0 commit comments

Comments
 (0)