Skip to content

Commit 5562dbf

Browse files
authored
Merge pull request #232 from benmccann/spaces-v-tabs
Replace tabs with spaces
2 parents 30da353 + 74f0433 commit 5562dbf

File tree

1 file changed

+35
-35
lines changed

1 file changed

+35
-35
lines changed

src/index.js

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ class ChartComponent extends React.Component {
1010

1111
static propTypes = {
1212
data: PropTypes.oneOfType([
13-
PropTypes.object,
14-
PropTypes.func
13+
PropTypes.object,
14+
PropTypes.func
1515
]).isRequired,
1616
getDatasetAtEvent: PropTypes.func,
1717
getElementAtEvent: PropTypes.func,
@@ -98,9 +98,9 @@ class ChartComponent extends React.Component {
9898

9999
const nextData = this.transformDataProp(nextProps);
100100

101-
if( !isEqual(this.shadowDataProp, nextData)) {
102-
return true;
103-
}
101+
if( !isEqual(this.shadowDataProp, nextData)) {
102+
return true;
103+
}
104104

105105
return !isEqual(plugins, nextProps.plugins);
106106

@@ -160,36 +160,36 @@ class ChartComponent extends React.Component {
160160
let currentDatasets = (this.chart_instance.config.data && this.chart_instance.config.data.datasets) || [];
161161
const nextDatasets = data.datasets || [];
162162

163-
// use the key provider to work out which series have been added/removed/changed
164-
const currentDatasetKeys = currentDatasets.map(this.props.datasetKeyProvider);
165-
const nextDatasetKeys = nextDatasets.map(this.props.datasetKeyProvider);
166-
const newDatasets = nextDatasets.filter(d => currentDatasetKeys.indexOf(this.props.datasetKeyProvider(d)) === -1);
167-
168-
// process the updates (via a reverse for loop so we can safely splice deleted datasets out of the array
169-
for (let idx = currentDatasets.length - 1; idx >= 0; idx -= 1) {
170-
const currentDatasetKey = this.props.datasetKeyProvider(currentDatasets[idx]);
171-
if (nextDatasetKeys.indexOf(currentDatasetKey) === -1) {
172-
// deleted series
173-
currentDatasets.splice(idx, 1);
174-
} else {
175-
const retainedDataset = find(nextDatasets, d => this.props.datasetKeyProvider(d) === currentDatasetKey);
176-
if (retainedDataset) {
177-
// update it in place if it is a retained dataset
178-
currentDatasets[idx].data.splice(retainedDataset.data.length);
179-
retainedDataset.data.forEach((point, pid) => {
180-
currentDatasets[idx].data[pid] = retainedDataset.data[pid];
181-
});
182-
const {data, ...otherProps} = retainedDataset;
183-
currentDatasets[idx] = {
184-
data: currentDatasets[idx].data,
185-
...currentDatasets[idx],
186-
...otherProps
187-
};
188-
}
189-
}
190-
}
191-
// finally add any new series
192-
newDatasets.forEach(d => currentDatasets.push(d));
163+
// use the key provider to work out which series have been added/removed/changed
164+
const currentDatasetKeys = currentDatasets.map(this.props.datasetKeyProvider);
165+
const nextDatasetKeys = nextDatasets.map(this.props.datasetKeyProvider);
166+
const newDatasets = nextDatasets.filter(d => currentDatasetKeys.indexOf(this.props.datasetKeyProvider(d)) === -1);
167+
168+
// process the updates (via a reverse for loop so we can safely splice deleted datasets out of the array
169+
for (let idx = currentDatasets.length - 1; idx >= 0; idx -= 1) {
170+
const currentDatasetKey = this.props.datasetKeyProvider(currentDatasets[idx]);
171+
if (nextDatasetKeys.indexOf(currentDatasetKey) === -1) {
172+
// deleted series
173+
currentDatasets.splice(idx, 1);
174+
} else {
175+
const retainedDataset = find(nextDatasets, d => this.props.datasetKeyProvider(d) === currentDatasetKey);
176+
if (retainedDataset) {
177+
// update it in place if it is a retained dataset
178+
currentDatasets[idx].data.splice(retainedDataset.data.length);
179+
retainedDataset.data.forEach((point, pid) => {
180+
currentDatasets[idx].data[pid] = retainedDataset.data[pid];
181+
});
182+
const {data, ...otherProps} = retainedDataset;
183+
currentDatasets[idx] = {
184+
data: currentDatasets[idx].data,
185+
...currentDatasets[idx],
186+
...otherProps
187+
};
188+
}
189+
}
190+
}
191+
// finally add any new series
192+
newDatasets.forEach(d => currentDatasets.push(d));
193193
const { datasets, ...rest } = data;
194194

195195
this.chart_instance.config.data = {

0 commit comments

Comments
 (0)