Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/merge options #5 #6

Merged
merged 6 commits into from
Aug 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,16 @@
"babel-plugin-transform-runtime": "^6.0.0",
"babel-preset-es2015": "^6.0.0",
"babel-preset-stage-2": "^6.0.0",
"chai": "^3.5.0",
"chromedriver": "^2.21.2",
"connect-history-api-fallback": "^1.1.0",
"cross-spawn": "^2.1.5",
"css-loader": "^0.23.0",
"eslint": "^2.10.2",
"eslint-config-standard": "^5.1.0",
"eslint-friendly-formatter": "^2.0.5",
"eslint-loader": "^1.3.0",
"eslint-plugin-html": "^1.3.0",
"eslint-config-standard": "^5.1.0",
"eslint-plugin-promise": "^1.0.8",
"eslint-plugin-standard": "^1.3.2",
"eventsource-polyfill": "^0.9.6",
Expand All @@ -50,6 +53,8 @@
"function-bind": "^1.0.2",
"html-webpack-plugin": "^2.8.1",
"http-proxy-middleware": "^0.12.0",
"inject-loader": "^2.0.1",
"isparta-loader": "^2.0.0",
"json-loader": "^0.5.4",
"karma": "^0.13.15",
"karma-coverage": "^0.5.5",
Expand All @@ -59,20 +64,16 @@
"karma-sourcemap-loader": "^0.3.7",
"karma-spec-reporter": "0.0.24",
"karma-webpack": "^1.7.0",
"lodash": "^4.15.0",
"lolex": "^1.4.0",
"mocha": "^2.4.5",
"chai": "^3.5.0",
"sinon": "^1.17.3",
"sinon-chai": "^2.8.0",
"inject-loader": "^2.0.1",
"isparta-loader": "^2.0.0",
"phantomjs-prebuilt": "^2.1.3",
"chromedriver": "^2.21.2",
"cross-spawn": "^2.1.5",
"nightwatch": "^0.8.18",
"selenium-server": "2.53.0",
"ora": "^0.2.0",
"phantomjs-prebuilt": "^2.1.3",
"selenium-server": "2.53.0",
"shelljs": "^0.6.0",
"sinon": "^1.17.3",
"sinon-chai": "^2.8.0",
"url-loader": "^0.5.7",
"vue-hot-reload-api": "^1.2.0",
"vue-html-loader": "^1.0.0",
Expand Down
9 changes: 6 additions & 3 deletions src/BaseCharts/Bar.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Vue from 'vue'
import Chart from 'chart.js'
import { mergeOptions } from '../helpers/options'

export default Vue.extend({
template: `
Expand All @@ -21,7 +22,7 @@ export default Vue.extend({

data () {
return {
options: {
defaultOptions: {
scales: {
yAxes: [{
ticks: {
Expand All @@ -44,12 +45,14 @@ export default Vue.extend({
},

methods: {
render (data, options = this.options) {
render (data, options) {
let chartOptions = mergeOptions(this.defaultOptions, options)

this._chart = new Chart(
this.$els.canvas.getContext('2d'), {
type: 'bar',
data: data,
options: options
options: chartOptions
}
)
this._chart.generateLegend()
Expand Down
9 changes: 6 additions & 3 deletions src/BaseCharts/Doughnut.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Vue from 'vue'
import Chart from 'chart.js'
import { mergeOptions } from '../helpers/options'

export default Vue.extend({
template: `
Expand All @@ -21,18 +22,20 @@ export default Vue.extend({

data () {
return {
options: {
defaultOptions: {
}
}
},

methods: {
render (data, options = this.options) {
render (data, options) {
let chartOptions = mergeOptions(this.defaultOptions, options)

this._chart = new Chart(
this.$els.canvas.getContext('2d'), {
type: 'doughnut',
data: data,
options: options
options: chartOptions
}
)
this._chart.generateLegend()
Expand Down
9 changes: 6 additions & 3 deletions src/BaseCharts/Line.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Vue from 'vue'
import Chart from 'chart.js'
import { mergeOptions } from '../helpers/options'

export default Vue.extend({
template: `
Expand All @@ -21,7 +22,7 @@ export default Vue.extend({

data () {
return {
options: {
defaultOptions: {
scales: {
yAxes: [{
ticks: {
Expand All @@ -42,12 +43,14 @@ export default Vue.extend({
},

methods: {
render (data, options = this.options) {
render (data, options) {
let chartOptions = mergeOptions(this.defaultOptions, options)

this._chart = new Chart(
this.$els.canvas.getContext('2d'), {
type: 'line',
data: data,
options: options
options: chartOptions
}
)
this._chart.generateLegend()
Expand Down
9 changes: 6 additions & 3 deletions src/BaseCharts/Pie.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Vue from 'vue'
import Chart from 'chart.js'
import { mergeOptions } from '../helpers/options'

export default Vue.extend({
template: `
Expand All @@ -21,18 +22,20 @@ export default Vue.extend({

data () {
return {
options: {
defaultOptions: {
}
}
},

methods: {
render (data, options = this.options) {
render (data, options) {
let chartOptions = mergeOptions(this.defaultOptions, options)

this._chart = new Chart(
this.$els.canvas.getContext('2d'), {
type: 'pie',
data: data,
options: options
options: chartOptions
}
)
this._chart.generateLegend()
Expand Down
9 changes: 6 additions & 3 deletions src/BaseCharts/PolarArea.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Vue from 'vue'
import Chart from 'chart.js'
import { mergeOptions } from '../helpers/options'

export default Vue.extend({
template: `
Expand All @@ -21,18 +22,20 @@ export default Vue.extend({

data () {
return {
options: {
defaultOptions: {
}
}
},

methods: {
render (data, options = this.options) {
render (data, options) {
let chartOptions = mergeOptions(this.defaultOptions, options)

this._chart = new Chart(
this.$els.canvas.getContext('2d'), {
type: 'polarArea',
data: data,
options: options
options: chartOptions
}
)
this._chart.generateLegend()
Expand Down
9 changes: 6 additions & 3 deletions src/BaseCharts/Radar.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Vue from 'vue'
import Chart from 'chart.js'
import { mergeOptions } from '../helpers/options'

export default Vue.extend({
template: `
Expand All @@ -21,18 +22,20 @@ export default Vue.extend({

data () {
return {
options: {
defaultOptions: {
}
}
},

methods: {
render (data, options = this.options) {
render (data, options) {
let chartOptions = mergeOptions(this.defaultOptions, options)

this._chart = new Chart(
this.$els.canvas.getContext('2d'), {
type: 'radar',
data: data,
options: options
options: chartOptions
}
)
this._chart.generateLegend()
Expand Down
5 changes: 5 additions & 0 deletions src/helpers/options.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import merge from 'lodash/fp/merge'

export function mergeOptions (obj, src) {
return merge(obj, src)
}