Compare commits

...

31 Commits

Author SHA1 Message Date
Jakub Juszczak
4f5aa1811d 💎 Release new version 1.2.0 2017-07-25 12:56:13 +02:00
Jakub Juszczak
098c90edf1 Add scatter chart 2017-07-25 12:53:17 +02:00
Jakub Juszczak
3f15eb9abc Add dist files to ignire 2017-07-25 12:52:12 +02:00
Jakub Juszczak
68e94b7fe3 Merge branch 'release/1.x' into pr/152
* release/1.x:
  ⬆️ Update dependency chart.js to 2.6.0
  🐛 Fix dependency
  💎 Release new version 1.1.4

# Conflicts:
#	dist/vue-chartjs.js
#	dist/vue-chartjs.js.map
2017-07-25 12:49:06 +02:00
Denis Lapi
0d24270bf2 Delete vue-chartjs.js 2017-07-22 19:25:48 +02:00
Denis Lapi
e034467e5b Delete vue-chartjs.js.map 2017-07-22 19:25:39 +02:00
Jakub Juszczak
c7cb8e24e9 ⬆️ Update dependency chart.js to 2.6.0 2017-07-22 17:28:36 +02:00
DenisLapi
4c9f4fc5e5 #149 - Fix error on beforeDestroy - VueJS v1 2017-07-22 10:01:29 +02:00
Jakub Juszczak
a25d327b13 🐛 Fix dependency 2017-02-23 08:46:21 +01:00
Jakub Juszczak
f57e555d94 💎 Release new version 1.1.4
Updated chart.js dependency
2017-02-22 13:01:59 +01:00
Jakub Juszczak
88d2771175 📝 Update README 2016-10-02 09:19:41 +02:00
Jakub Juszczak
b8e7ce11de 📝 Update CHANGELOG 2016-09-08 13:40:05 +02:00
Jakub Juszczak
98961547f3 💎 Release new version 1.1.3 2016-09-08 13:39:30 +02:00
Jakub Juszczak
c11127e64f 1.1.3 2016-09-08 13:38:52 +02:00
Jakub Juszczak
0f98800b92 Add prepublish command to package.json for np 2016-09-08 13:34:05 +02:00
Jakub Juszczak
8eefeeef86 📝 Update README with badges 2016-09-08 13:30:19 +02:00
Jakub Juszczak
d913e9c515 Add unit tests and travis.yml 2016-09-08 13:21:20 +02:00
Jakub Juszczak
377ae5e27a Change example location to src folder for easier testing 2016-09-08 13:06:36 +02:00
Jakub Juszczak
9bcffae429 Add missing image for readme 2016-09-08 12:12:25 +02:00
Jakub Juszczak
086fb1d4e9 Add BubbleExample to app.vue 2016-09-08 12:12:15 +02:00
Jakub Juszczak
f241613107 Add canvas id as prop 2016-09-08 12:08:19 +02:00
Jakub Juszczak
af373cf09d 📝 Add BubbleChart Preview to README 2016-09-08 12:04:36 +02:00
Jakub Juszczak
a7776f8407 Add bubbleChart example 2016-09-08 12:03:15 +02:00
Jakub
776f3976ec Merge pull request #9 from jcalonso/feature/bubble-chart
Add bubble chart type
2016-09-08 11:49:31 +02:00
Juan Carlos Alonso
3785e73b43 Added bubble chart type 2016-09-07 22:50:18 +01:00
Jakub Juszczak
9bf6e6078d 📝 Update CHANGELOG
Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2016-09-07 10:38:43 +02:00
Jakub Juszczak
e62e8c81fb Update npm version
Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2016-09-07 10:30:07 +02:00
Jakub Juszczak
9f79fb581d 🔥 Remove placeholder test
Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2016-09-07 10:29:56 +02:00
Jakub Juszczak
45d500d401 💎 Release new version 1.1.2
Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2016-09-07 10:24:07 +02:00
Jakub Juszczak
9f02e95355 🐛 Fix props 2016-09-07 10:19:05 +02:00
Jakub Juszczak
d80eace435 📝 Update CHANGELOG 2016-08-23 20:59:21 +02:00
36 changed files with 6215 additions and 95 deletions

2
.gitignore vendored
View File

@@ -4,3 +4,5 @@ npm-debug.log
selenium-debug.log
test/unit/coverage
test/e2e/reports
dist/
es/

5
.travis.yml Normal file
View File

@@ -0,0 +1,5 @@
language: node_js
node_js:
- "6"
after_success:
- bash <(curl -s https://codecov.io/bash)

View File

@@ -1,5 +1,30 @@
# Change Log
## [v1.1.3](https://github.com/apertureless/vue-chartjs/tree/v1.1.3) (2016-09-08)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/1.1.2...v1.1.3)
**Implemented enhancements:**
- Add test [\#1](https://github.com/apertureless/vue-chartjs/issues/1)
**Fixed bugs:**
- Passing chart size \(width / height\) as prop doesnt resize the chart [\#8](https://github.com/apertureless/vue-chartjs/issues/8)
**Merged pull requests:**
- Added bubble chart type [\#9](https://github.com/apertureless/vue-chartjs/pull/9) ([jcalonso](https://github.com/jcalonso))
## [1.1.2](https://github.com/apertureless/vue-chartjs/tree/1.1.2) (2016-09-07)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/1.1.1...1.1.2)
**Implemented enhancements:**
- Change name of the render method to ensure compatiblity with Vue 2.0 [\#4](https://github.com/apertureless/vue-chartjs/issues/4)
## [1.1.1](https://github.com/apertureless/vue-chartjs/tree/1.1.1) (2016-08-23)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/1.1.0...1.1.1)
## [1.1.0](https://github.com/apertureless/vue-chartjs/tree/1.1.0) (2016-08-21)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/1.0.3...1.1.0)

View File

@@ -1,12 +1,12 @@
# Vue-ChartJs
[![npm version](https://badge.fury.io/js/vue-chartjs.svg)](https://badge.fury.io/js/vue-chartjs) ![npm dependencies](https://david-dm.org/apertureless/vue-chartjs.svg)
[![npm version](https://badge.fury.io/js/vue-chartjs.svg)](https://badge.fury.io/js/vue-chartjs) ![npm dependencies](https://david-dm.org/apertureless/vue-chartjs.svg) [![codecov](https://codecov.io/gh/apertureless/vue-chartjs/branch/master/graph/badge.svg)](https://codecov.io/gh/apertureless/vue-chartjs) [![Build Status](https://travis-ci.org/apertureless/vue-chartjs.svg?branch=master)](https://travis-ci.org/apertureless/vue-chartjs)
> VueJS wrapper for ChartJs
## Install
Simply run `npm install vue-chartjs`
Simply run `npm install vue-chartjs@1.1.3`
## How to use
@@ -107,17 +107,9 @@ export default {
![Pie](assets/polar.png)
## Todo
- [x] ~~Implement Bar Chart~~
- [x] ~~Implement Line Chart~~
- [x] ~~Implement Radar Chart~~
- [x] ~~Implement Polar Area Chart~~
- [x] ~~Implement Pie Chart~~
- [x] ~~Implement Doughnut Chart~~
- [x] ~~Make npm module~~
- [ ] Add tests
### Bubble
![Bubble](assets/bubble.png)
## Build Setup

BIN
assets/bubble.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

22
dist/vue-chartjs.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,30 +0,0 @@
<template>
<div class="container">
<bar-example></bar-example>
<line-example></line-example>
<doughnut-example></doughnut-example>
<pie-example></pie-example>
<radar-example></radar-example>
<polar-area-example></polar-area-example>
</div>
</template>
<script>
import BarExample from './examples/BarExample'
import LineExample from './examples/LineExample'
import DoughnutExample from './examples/DoughnutExample'
import PieExample from './examples/PieExample'
import RadarExample from './examples/RadarExample'
import PolarAreaExample from './examples/PolarAreaExample'
export default {
components: { BarExample, LineExample, DoughnutExample, PieExample, RadarExample, PolarAreaExample }
}
</script>
<style>
.container {
max-width: 800px;
margin: 0 auto;
}
</style>

View File

@@ -1,6 +1,6 @@
{
"name": "vue-chartjs",
"version": "1.1.1",
"version": "1.2.0",
"description": "Vue wrapper for chart.js",
"author": "Jakub Juszczak <jakub@nextindex.de>",
"repository": {
@@ -15,17 +15,21 @@
"Charts"
],
"main": "dist/vue-chartjs.js",
"files": [
"dist"
],
"scripts": {
"dev": "node build/dev-server.js",
"build": "node build/build.js",
"unit": "karma start test/unit/karma.conf.js --single-run",
"e2e": "node test/e2e/runner.js",
"test": "npm run unit && npm run e2e",
"lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs"
"test": "npm run unit",
"lint": "eslint --ext .js,.vue src test/unit/specs",
"prepublish": "node build/build.js"
},
"dependencies": {
"babel-runtime": "^6.0.0",
"chart.js": "^2.1.6",
"chart.js": "^2.6.0",
"vue": "^1.0.21"
},
"devDependencies": {

View File

@@ -5,11 +5,15 @@ import { mergeOptions } from '../helpers/options'
export default Vue.extend({
template: `
<div>
<canvas id="bar-chart" width=width height=height v-el:canvas></canvas>
<canvas id="{{chartId}}" width="{{width}}" height="{{height}}" v-el:canvas></canvas>
</div>
`,
props: {
chartId: {
default: 'bar-chart',
type: String
},
width: {
default: 400,
type: Number
@@ -59,6 +63,8 @@ export default Vue.extend({
}
},
beforeDestroy () {
this._chart.destroy()
if (this._chart) {
this._chart.destroy()
}
}
})

53
src/BaseCharts/Bubble.js Normal file
View File

@@ -0,0 +1,53 @@
import Vue from 'vue'
import Chart from 'chart.js'
import { mergeOptions } from '../helpers/options'
export default Vue.extend({
template: `
<div>
<canvas id="{{chartId}}" width={{width}} height={{height}} v-el:canvas></canvas>
</div>
`,
props: {
chartId: {
default: 'bubble-chart',
type: String
},
width: {
default: 400,
type: Number
},
height: {
default: 400,
type: Number
}
},
data () {
return {
defaultOptions: {
}
}
},
methods: {
render (data, options) {
let chartOptions = mergeOptions(this.defaultOptions, options)
this._chart = new Chart(
this.$els.canvas.getContext('2d'), {
type: 'bubble',
data: data,
options: chartOptions
}
)
this._chart.generateLegend()
}
},
beforeDestroy () {
if (this._chart) {
this._chart.destroy()
}
}
})

View File

@@ -5,11 +5,15 @@ import { mergeOptions } from '../helpers/options'
export default Vue.extend({
template: `
<div>
<canvas id="doughnut-chart" width=width height=height v-el:canvas></canvas>
<canvas id="{{chartId}}" width={{width}} height={{height}} v-el:canvas></canvas>
</div>
`,
props: {
chartId: {
default: 'doughnut-chart',
type: String
},
width: {
default: 400,
type: Number
@@ -42,6 +46,8 @@ export default Vue.extend({
}
},
beforeDestroy () {
this._chart.destroy()
if (this._chart) {
this._chart.destroy()
}
}
})

View File

@@ -5,11 +5,15 @@ import { mergeOptions } from '../helpers/options'
export default Vue.extend({
template: `
<div>
<canvas id="line-chart" width=width height=height v-el:canvas></canvas>
<canvas id="{{chartId}}" width={{width}} height={{height}} v-el:canvas></canvas>
</div>
`,
props: {
chartId: {
default: 'line-chart',
type: String
},
width: {
default: 400,
type: Number
@@ -57,6 +61,8 @@ export default Vue.extend({
}
},
beforeDestroy () {
this._chart.destroy()
if (this._chart) {
this._chart.destroy()
}
}
})

View File

@@ -5,11 +5,15 @@ import { mergeOptions } from '../helpers/options'
export default Vue.extend({
template: `
<div>
<canvas id="pie-chart" width=width height=height v-el:canvas></canvas>
<canvas id="{{chartId}}" width={{width}} height={{height}} v-el:canvas></canvas>
</div>
`,
props: {
chartId: {
default: 'pie-chart',
type: String
},
width: {
default: 400,
type: Number
@@ -42,6 +46,8 @@ export default Vue.extend({
}
},
beforeDestroy () {
this._chart.destroy()
if (this._chart) {
this._chart.destroy()
}
}
})

View File

@@ -5,11 +5,15 @@ import { mergeOptions } from '../helpers/options'
export default Vue.extend({
template: `
<div>
<canvas id="polar-chart" width=width height=height v-el:canvas></canvas>
<canvas id="{{chartId}}" width={{width}} height={{height}} v-el:canvas></canvas>
</div>
`,
props: {
chartId: {
default: 'polar-chart',
type: String
},
width: {
default: 400,
type: Number
@@ -42,6 +46,8 @@ export default Vue.extend({
}
},
beforeDestroy () {
this._chart.destroy()
if (this._chart) {
this._chart.destroy()
}
}
})

View File

@@ -5,11 +5,15 @@ import { mergeOptions } from '../helpers/options'
export default Vue.extend({
template: `
<div>
<canvas id="radar-chart" width=width height=height v-el:canvas></canvas>
<canvas id="{{chartId}}" width={{width}} height={{height}} v-el:canvas></canvas>
</div>
`,
props: {
chartId: {
default: 'radar-chart',
type: String
},
width: {
default: 400,
type: Number
@@ -42,6 +46,8 @@ export default Vue.extend({
}
},
beforeDestroy () {
this._chart.destroy()
if (this._chart) {
this._chart.destroy()
}
}
})

59
src/BaseCharts/Scatter.js Normal file
View File

@@ -0,0 +1,59 @@
import Vue from 'vue'
import Chart from 'chart.js'
import { mergeOptions } from '../helpers/options'
export default Vue.extend({
template: `
<div>
<canvas id="{{chartId}}" width={{width}} height={{height}} v-el:canvas></canvas>
</div>
`,
props: {
chartId: {
default: 'scatter-chart',
type: String
},
width: {
default: 400,
type: Number
},
height: {
default: 400,
type: Number
}
},
data () {
return {
defaultOptions: {
scales: {
xAxes: [{
type: 'linear',
position: 'bottom'
}]
}
}
}
},
methods: {
render (data, options) {
let chartOptions = mergeOptions(this.defaultOptions, options)
this._chart = new Chart(
this.$els.canvas.getContext('2d'), {
type: 'scatter',
data: data,
options: chartOptions
}
)
this._chart.generateLegend()
}
},
beforeDestroy () {
if (this._chart) {
this._chart.destroy()
}
}
})

40
src/examples/App.vue Normal file
View File

@@ -0,0 +1,40 @@
<template>
<div class="container">
<bar-example></bar-example>
<line-example></line-example>
<doughnut-example></doughnut-example>
<pie-example></pie-example>
<radar-example></radar-example>
<polar-area-example></polar-area-example>
<bubble-example></bubble-example>
</div>
</template>
<script>
import BarExample from './BarExample'
import LineExample from './LineExample'
import DoughnutExample from './DoughnutExample'
import PieExample from './PieExample'
import RadarExample from './RadarExample'
import PolarAreaExample from './PolarAreaExample'
import BubbleExample from './BubbleExample'
export default {
components: {
BarExample,
LineExample,
DoughnutExample,
PieExample,
RadarExample,
PolarAreaExample,
BubbleExample
}
}
</script>
<style>
.container {
max-width: 800px;
margin: 0 auto;
}
</style>

View File

@@ -11,6 +11,6 @@ export default BarChart.extend({
data: [40, 20, 12, 39, 10, 40, 39, 80, 40, 20, 12, 11]
}
]
})
}, {responsive: true, maintainAspectRatio: false})
}
})

View File

@@ -0,0 +1,52 @@
import BubbleChart from '../BaseCharts/Bubble'
export default BubbleChart.extend({
ready () {
this.render({
datasets: [
{
label: 'Data One',
backgroundColor: '#f87979',
data: [
{
x: 20,
y: 25,
r: 5
},
{
x: 40,
y: 10,
r: 10
},
{
x: 30,
y: 22,
r: 30
}
]
},
{
label: 'Data Two',
backgroundColor: '#7C8CF8',
data: [
{
x: 10,
y: 30,
r: 15
},
{
x: 20,
y: 20,
r: 10
},
{
x: 15,
y: 8,
r: 30
}
]
}
]
})
}
})

View File

@@ -4,6 +4,8 @@ import Line from './BaseCharts/Line'
import Pie from './BaseCharts/Pie'
import PolarArea from './BaseCharts/PolarArea'
import Radar from './BaseCharts/Radar'
import Bubble from './BaseCharts/Bubble'
import Scatter from './BaseCharts/Scatter'
const VueCharts = {
Bar,
@@ -11,7 +13,9 @@ const VueCharts = {
Line,
Pie,
PolarArea,
Radar
Radar,
Bubble,
Scatter
}
module.exports = VueCharts

View File

@@ -0,0 +1,17 @@
import Vue from 'vue'
import BarChart from 'src/examples/BarExample'
describe('BarChart', () => {
it('should render a canvas', () => {
const vm = new Vue({
el: 'body',
replace: false,
template: '<bar-chart></bar-chart>',
components: { BarChart }
})
expect(vm.$el.querySelector('#bar-chart')).not.to.be.an('undefined')
expect(vm.$el.querySelector('canvas')).not.to.be.an('undefined')
expect(vm.$el.querySelector('canvas')).not.to.be.an('null')
expect(vm.$el.querySelector('canvas')).to.exist
})
})

View File

@@ -0,0 +1,17 @@
import Vue from 'vue'
import BubbleChart from 'src/examples/BubbleExample'
describe('BubbleChart', () => {
it('should render a canvas', () => {
const vm = new Vue({
el: 'body',
replace: false,
template: '<bubble-chart></bubble-chart>',
components: { BubbleChart }
})
expect(vm.$el.querySelector('#bubble-chart')).not.to.be.an('undefined')
expect(vm.$el.querySelector('canvas')).not.to.be.an('undefined')
expect(vm.$el.querySelector('canvas')).not.to.be.an('null')
expect(vm.$el.querySelector('canvas')).to.exist
})
})

View File

@@ -0,0 +1,17 @@
import Vue from 'vue'
import DoughnutChart from 'src/examples/DoughnutExample'
describe('DoughnutChart', () => {
it('should render a canvas', () => {
const vm = new Vue({
el: 'body',
replace: false,
template: '<doughnut-chart></doughnut-chart>',
components: { DoughnutChart }
})
expect(vm.$el.querySelector('#doughnut-chart')).not.to.be.an('undefined')
expect(vm.$el.querySelector('canvas')).not.to.be.an('undefined')
expect(vm.$el.querySelector('canvas')).not.to.be.an('null')
expect(vm.$el.querySelector('canvas')).to.exist
})
})

View File

@@ -1,12 +0,0 @@
import Vue from 'vue'
import Hello from 'src/components/Hello'
describe('Hello.vue', () => {
it('should render correct contents', () => {
const vm = new Vue({
template: '<div><hello></hello></div>',
components: { Hello }
}).$mount()
expect(vm.$el.querySelector('.hello h1').textContent).to.contain('Hello World!')
})
})

View File

@@ -0,0 +1,17 @@
import Vue from 'vue'
import LineChart from 'src/examples/LineExample'
describe('LineChart', () => {
it('should render a canvas', () => {
const vm = new Vue({
el: 'body',
replace: false,
template: '<line-chart></line-chart>',
components: { LineChart }
})
expect(vm.$el.querySelector('#line-chart')).not.to.be.an('undefined')
expect(vm.$el.querySelector('canvas')).not.to.be.an('undefined')
expect(vm.$el.querySelector('canvas')).not.to.be.an('null')
expect(vm.$el.querySelector('canvas')).to.exist
})
})

View File

@@ -0,0 +1,17 @@
import Vue from 'vue'
import PieChart from 'src/examples/PieExample'
describe('PieChart', () => {
it('should render a canvas', () => {
const vm = new Vue({
el: 'body',
replace: false,
template: '<pie-chart></pie-chart>',
components: { PieChart }
})
expect(vm.$el.querySelector('#pie-chart')).not.to.be.an('undefined')
expect(vm.$el.querySelector('canvas')).not.to.be.an('undefined')
expect(vm.$el.querySelector('canvas')).not.to.be.an('null')
expect(vm.$el.querySelector('canvas')).to.exist
})
})

View File

@@ -0,0 +1,17 @@
import Vue from 'vue'
import PolarChart from 'src/examples/PolarAreaExample'
describe('PolarChart', () => {
it('should render a canvas', () => {
const vm = new Vue({
el: 'body',
replace: false,
template: '<polar-chart></polar-chart>',
components: { PolarChart }
})
expect(vm.$el.querySelector('#polar-chart')).not.to.be.an('undefined')
expect(vm.$el.querySelector('canvas')).not.to.be.an('undefined')
expect(vm.$el.querySelector('canvas')).not.to.be.an('null')
expect(vm.$el.querySelector('canvas')).to.exist
})
})

View File

@@ -0,0 +1,17 @@
import Vue from 'vue'
import RadarChart from 'src/examples/RadarExample'
describe('RadarChart', () => {
it('should render a canvas', () => {
const vm = new Vue({
el: 'body',
replace: false,
template: '<radar-chart></radar-chart>',
components: { RadarChart }
})
expect(vm.$el.querySelector('#radar-chart')).not.to.be.an('undefined')
expect(vm.$el.querySelector('canvas')).not.to.be.an('undefined')
expect(vm.$el.querySelector('canvas')).not.to.be.an('null')
expect(vm.$el.querySelector('canvas')).to.exist
})
})

View File

@@ -0,0 +1,30 @@
import { mergeOptions } from 'src/helpers/options'
describe('mergeOptions.js', () => {
const a = {
a: 'a',
b: 'a'
}
const b = {
a: 'b',
b: 'b'
}
const c = {
c: 'c'
}
it('should replace old a and b if a and b are new', () => {
let ab = mergeOptions(a, b)
expect(ab).to.have.property('a').and.to.equal('b')
expect(ab).to.have.property('b').and.to.equal('b')
})
it('should add c if c is new', () => {
let ac = mergeOptions(a, c)
expect(ac).to.have.property('a').and.to.equal('a')
expect(ac).to.have.property('b').and.to.equal('a')
expect(ac).to.have.property('c').and.to.equal('c')
})
})

5764
yarn.lock Normal file

File diff suppressed because it is too large Load Diff