Skip to content

Commit

Permalink
✨ Change reactiveDataMixin
Browse files Browse the repository at this point in the history
  • Loading branch information
apertureless committed Oct 15, 2016
1 parent 4ec6fa4 commit f94b320
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
1 change: 1 addition & 0 deletions codecov.yml
Expand Up @@ -25,6 +25,7 @@ coverage:
ignore:
- "tests/*"
- "src/examples/*"
- "src/mixins/*"


comment:
Expand Down
2 changes: 2 additions & 0 deletions package.json
Expand Up @@ -56,9 +56,11 @@
"http-proxy-middleware": "^0.17.2",
"inject-loader": "^2.0.1",
"isparta-loader": "^2.0.0",
"jasmine-core": "^2.5.2",
"json-loader": "^0.5.4",
"karma": "^1.3.0",
"karma-coverage": "^1.1.1",
"karma-jasmine": "^1.0.2",
"karma-mocha": "^1.2.0",
"karma-phantomjs-launcher": "^1.0.0",
"karma-sinon-chai": "^1.2.0",
Expand Down
22 changes: 16 additions & 6 deletions src/mixins/reactiveData.js
Expand Up @@ -19,16 +19,26 @@ module.exports = {
})

if (JSON.stringify(newDataLabels) === JSON.stringify(oldDataLabels)) {
newData.datasets.forEach((dataset, i) => {
chart.data.datasets[i].data = dataset.data
})
chart.data.labels = newData.labels
chart.update()
this.forceUpdate(newData, chart)
} else {
this.renderChart(this.chartData, this.options)
this.forceRender()
}
}
}
}
},
methods: {
forceUpdate (newData, chart) {
newData.datasets.forEach((dataset, i) => {
chart.data.datasets[i].data = dataset.data
})

chart.data.labels = newData.labels
chart.update()
},

forceRender () {
this.renderChart(this.chartData, this.options)
}
}
}
1 change: 1 addition & 0 deletions test/unit/.eslintrc
Expand Up @@ -4,6 +4,7 @@
},
"globals": {
"expect": true,
"jasmine": true,
"sinon": true
}
}
2 changes: 1 addition & 1 deletion test/unit/karma.conf.js
Expand Up @@ -54,7 +54,7 @@ module.exports = function (config) {
// http://karma-runner.github.io/0.13/config/browsers.html
// 2. add it to the `browsers` array below.
browsers: ['PhantomJS'],
frameworks: ['mocha', 'sinon-chai'],
frameworks: ['mocha', 'sinon-chai', 'jasmine'],
reporters: ['spec', 'coverage'],
files: ['./index.js'],
preprocessors: {
Expand Down

0 comments on commit f94b320

Please sign in to comment.