Skip to content

Commit 5b73c78

Browse files
author
Alan Smith
committed
Tweaks, demo site, readme..
1 parent 388e660 commit 5b73c78

39 files changed

+12045
-10
lines changed

.eslintignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
dist
2-
node_modules
1+
node_modules
2+
public
3+
bin
4+
build

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ dist/vue3-highcharts.umd.js
66
dist/vue3-highcharts.umd.js.map
77
dist/vue3-highcharts.umd.min.js
88
dist/vue3-highcharts.umd.min.js.map
9-
9+
demo/node_modules
1010

1111
# local env files
1212
.env.local

LICENCE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2020 Alan Smith
3+
Copyright (c) 2020 - Present Alan Smith
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 132 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,134 @@
11
# Vue 3 - Highcharts JS
22

3-
A simple Vue 3 component for rendering Highcharts.js Charts.
3+
A simple, fast, Vue 3 component for rendering Highcharts.js Charts written using the composition API.
4+
5+
## Minimum Requirements
6+
7+
8+
[email protected] ( older versions may work but not tested )
9+
10+
Vue and Highcharts are not bundled with the module and need to be included in your projects dependencies.
11+
12+
## Usage
13+
You can register the component in 2 ways.
14+
15+
### Register as a global component.
16+
```js
17+
import { createApp } from 'vue';
18+
import VueHighcharts from 'vue3-highcharts';
19+
20+
const app = createApp(..options);
21+
app.use(VueHighcharts);
22+
```
23+
24+
### Register as a local component
25+
```js
26+
import VueHighcharts from 'vue3-highcharts';
27+
28+
export default {
29+
name: 'MyChart',
30+
components: {
31+
VueHighcharts,
32+
},
33+
};
34+
```
35+
36+
### Props
37+
The following props can be passed to the component. Options is the only required one.
38+
39+
| Name | Type | Required | Default | Notes |
40+
|---------|-------|------| ------- | ----- |
41+
| type | String | no | 'chart' | This should be the constructor type you'd use with highcharts. If you import the stock chat, you can pass 'stockChart' as this option for example.
42+
options | Object | yes | - |This should be a [Highcharts chart options](https://api.highcharts.com/highcharts/) object
43+
redrawOnUpdate | Boolean | no | true | If the chart should be redrawn when options update.
44+
oneToOneUpdate | Boolean | no | false| If the certain collections should be updated one to one. See [here](https://api.highcharts.com/class-reference/Highcharts.Chart#update).
45+
animateOnUpdate | Boolean | no | true | If the redraw should be animated.
46+
47+
---
48+
49+
### Events
50+
The following events are emitted from the component. No data is provided with any event.
51+
| Name | Notes |
52+
| ---- | ----- |
53+
| rendered | Emitted when the chart has been rendered on the dom |
54+
| updated | Emitted when the chart options have been updated and the chart has been updated |
55+
| destroyed | Emitted when the Highcharts chart instance has been destroyed ( happens when the component unmounts )
56+
57+
58+
---
59+
---
60+
The Highcharts chart object is also exposed on the component instance as `chart`
61+
62+
A wrapper div is also created with a `.vue-highcharts` class around the actual chart.
63+
64+
### Simple Example
65+
66+
```html
67+
<template>
68+
<vue-highcharts
69+
type="chart"
70+
:options="chartOptions"
71+
:redrawOnUpdate="true"
72+
:oneToOneUpdate="false"
73+
:animateOnUpdate="true"
74+
@rendered="onRender"
75+
@update="onUpdate"
76+
@destroy="onDestroy"/>
77+
<template>
78+
```
79+
```js
80+
<script>
81+
import { ref } from 'vue';
82+
83+
export default {
84+
name: 'chart'
85+
setup() {
86+
const data = ref([1, 2, 3])
87+
const chartData = computed(() =>{
88+
return {
89+
series: [{
90+
name: 'Test Series',
91+
data: data.value,
92+
}],
93+
}
94+
});
95+
96+
const onRender = () => {
97+
console.log('Chart rendered');
98+
};
99+
100+
const onUpdate = () => {
101+
console.log('Chart updated');
102+
};
103+
104+
const onDestroy = () => {
105+
console.log('Chart destroyed');
106+
};
107+
108+
return {
109+
chartData,
110+
onRender,
111+
onUpdate,
112+
onDestroy,
113+
};
114+
}
115+
}
116+
</script>
117+
```
118+
```css
119+
<style>
120+
.vue-highcharts {
121+
width: 100%;
122+
}
123+
</style>
124+
```
125+
126+
### Using Stock/Map charts
127+
To use the stock map charts, you need to import and register them. For example, to use the map chart
128+
129+
```
130+
import HighCharts from 'highcharts';
131+
import useMapCharts from 'highcharts/modules/map';
132+
133+
useMapCharts(HighCharts);
134+
```

demo/.browserslistrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
> 1%
2+
last 2 versions
3+
not dead

demo/.editorconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[*.{js,jsx,ts,tsx,vue}]
2+
indent_style = space
3+
indent_size = 2
4+
end_of_line = lf
5+
trim_trailing_whitespace = true
6+
insert_final_newline = true
7+
max_line_length = 100

demo/.eslintrc.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module.exports = {
2+
root: true,
3+
env: {
4+
node: true,
5+
},
6+
extends: [
7+
'plugin:vue/vue3-essential',
8+
'@vue/airbnb',
9+
],
10+
parserOptions: {
11+
ecmaVersion: 2020,
12+
},
13+
rules: {
14+
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
15+
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
16+
'object-curly-newline': 0,
17+
},
18+
};

demo/.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
.DS_Store
2+
node_modules
3+
/dist
4+
5+
6+
# local env files
7+
.env.local
8+
.env.*.local
9+
10+
# Log files
11+
npm-debug.log*
12+
yarn-debug.log*
13+
yarn-error.log*
14+
pnpm-debug.log*
15+
16+
# Editor directories and files
17+
.idea
18+
.vscode
19+
*.suo
20+
*.ntvs*
21+
*.njsproj
22+
*.sln
23+
*.sw?

demo/LICENSE.MD

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 - Present Alan Smith
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

demo/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# vue-highcharts-demo

0 commit comments

Comments
 (0)