Skip to content

Commit 94f2294

Browse files
Add legend support to charts
1 parent 15f1448 commit 94f2294

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ class ChartComponent extends React.Component {
196196
const {options, legend, type, redraw, plugins} = this.props;
197197
const node = ReactDOM.findDOMNode(this);
198198
const data = this.memoizeDataProps();
199+
options.legend = legend;
199200

200201
this.chart_instance = new Chart(node, {
201202
type,

test/__tests__/Chart_spec.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,15 @@ 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');
125126

126127
expect(spy.callCount).to.equal(1);
127128

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

130131
expect(spy.callCount).to.equal(1);
131132

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

134135
expect(spy.callCount).to.equal(2);
135136

0 commit comments

Comments
 (0)