├── .editorconfig
├── .gitignore
├── README.md
├── babel.config.js
├── package-lock.json
├── package.json
├── public
└── index.html
├── src
├── App.vue
├── assets
│ ├── chart-examples.png
│ ├── charts-with-labels.png
│ ├── charts-with-max-axis.png
│ ├── charts.gif
│ ├── long-charts.png
│ └── trendline.png
├── components
│ └── PureVueChart.vue
├── main.js
└── wrapper.js
└── vue.config.js
/.editorconfig:
--------------------------------------------------------------------------------
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
8 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 | /dist
4 |
5 | # local env files
6 | .env.local
7 | .env.*.local
8 |
9 | # Log files
10 | npm-debug.log*
11 | yarn-debug.log*
12 | yarn-error.log*
13 |
14 | # Editor directories and files
15 | .idea
16 | .vscode
17 | *.suo
18 | *.ntvs*
19 | *.njsproj
20 | *.sln
21 | *.sw?
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
Pure Vue Chart
3 |
4 |
5 | A simple and lightweight vue component for making charts that do not rely on large chart libraries and will not bloat your dependencies
6 |
7 |
8 |
9 | Example
10 |
11 | ```
12 |
17 | ```
18 |
19 |
20 |
21 | When props are updated the graph will automatically animate to the new values.
22 |
23 | ## Install
24 | ```
25 | npm i pure-vue-chart
26 | ```
27 | Import it:
28 | ```
29 | import PureVueChart from 'pure-vue-chart';
30 | ```
31 | Register it in your component:
32 | ```
33 | components: {
34 | PureVueChart,
35 | },
36 | ```
37 | ## Use it
38 | ```
39 |
44 | ```
45 | ## Options
46 | To further control the display of data, you can use simple props to manipulate the charts. Here are some examples:
47 |
48 | 
49 |
50 | #### Most of the available props below are self-explanatory:
51 | ```
52 | :points=[1,4,5,3,4]
53 | :show-y-axis="false"
54 | :show-x-axis="true"
55 | :width="400"
56 | :height="200"
57 | :show-values="true"
58 | :use-month-labels="true"
59 | :months="['Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez']"
60 | ```
61 |
62 | ### Additional Features:
63 | #### Trendline
64 | You can add a simple linear trend line by using the following props:
65 | ```
66 | :show-trend-line="true"
67 | :trend-line-width="2"
68 | trend-line-color="lightblue"
69 | ```
70 | 
71 |
72 | #### X-axis labels:
73 | X-axis labels, by default will be from 1 - length-of-data.
74 | But you can automatically use Months by using the prop `:use-month-labels="true"`.
75 | Or you can provide the data as an array of objects, each with a `value` and `label` like so:
76 | ```
77 | :points=[{label: 'N', value: 41.1}, {label: 'NW', value: 1}, {label: 'W', value: 15}]
78 | ```
79 |
80 | Contributing
81 | I'm open to any issues or pull requests so long as
82 | they are simple, easy to read, use the eslint settings in package.json,
83 | and follow commitizen-esque style commit formats. Just open an issue on github and start a discussion.
84 | - pure-vue-chart issues - https://github.com/djaxho/pure-vue-chart/issues
85 |
86 | Authors or Acknowledgments
87 |
90 |
91 | List of features
92 |
93 | Simple bar charts
94 | Line charts (planned)
95 | Pie charts (planned)
96 | Rose charts (planned)
97 |
98 |
99 | License
100 |
101 | This project is licensed under the MIT License but please create pull requests to improve this package together rather that copying itto another project.
102 |
--------------------------------------------------------------------------------
/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: [
3 | '@vue/app',
4 | ],
5 | };
6 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "pure-vue-chart",
3 | "version": "0.4.0",
4 | "description": "Simple and lightweight vue chart svg component without chart library dependencies",
5 | "author": {
6 | "name": "Danny Jackson",
7 | "email": "djaxho@gmail.com"
8 | },
9 | "repository": "https://github.com/djaxho/pure-vue-chart",
10 | "bugs": "https://github.com/djaxho/pure-vue-chart/issues",
11 | "keywords": [
12 | "vue",
13 | "chart",
14 | "pure"
15 | ],
16 | "license": "MIT",
17 | "files": [
18 | "dist"
19 | ],
20 | "main": "./dist/pure-vue-chart.common.js",
21 | "private": false,
22 | "scripts": {
23 | "serve": "vue-cli-service serve",
24 | "build": "vue-cli-service build --target lib --name pure-vue-chart src/wrapper.js",
25 | "lint": "vue-cli-service lint"
26 | },
27 | "dependencies": {
28 | "core-js": "^2.6.5",
29 | "gsap": "^2.1.3",
30 | "vue": "^2.6.10"
31 | },
32 | "devDependencies": {
33 | "@vue/cli-plugin-babel": "^3.11.0",
34 | "@vue/cli-plugin-eslint": "^3.11.0",
35 | "@vue/cli-service": "^3.11.0",
36 | "@vue/eslint-config-airbnb": "^4.0.1",
37 | "babel-eslint": "^10.0.3",
38 | "eslint": "^5.16.0",
39 | "eslint-plugin-vue": "^5.2.3",
40 | "node-sass": "^4.12.0",
41 | "sass-loader": "^7.3.1",
42 | "vue-template-compiler": "^2.6.10"
43 | },
44 | "eslintConfig": {
45 | "root": true,
46 | "env": {
47 | "node": true
48 | },
49 | "extends": [
50 | "plugin:vue/recommended",
51 | "@vue/airbnb"
52 | ],
53 | "rules": {},
54 | "parserOptions": {
55 | "parser": "babel-eslint"
56 | }
57 | },
58 | "postcss": {
59 | "plugins": {
60 | "autoprefixer": {}
61 | }
62 | },
63 | "browserslist": [
64 | "> 1%",
65 | "last 2 versions"
66 | ]
67 | }
68 |
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | pure-vue-chart
9 |
10 |
11 |
12 | We're sorry but pure-vue-chart doesn't work properly without JavaScript enabled. Please enable it to continue.
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
Basic: showing values
4 |
10 |
11 |
12 |
Y axis
13 |
19 |
20 |
21 |
Max Y axis
22 |
29 |
30 |
31 |
X & Y axis
32 |
40 |
41 |
42 |
Trend line
43 |
54 |
55 |
56 |
Color
57 |
69 |
70 |
71 |
Custom labels and titles
72 |
80 |
81 |
87 | 😎
88 |
89 |
97 |
98 |
99 |
100 | {{ barIndex === 0 ? `Custom title: ${staticValue}` : staticValue }}
101 |
102 |
103 |
104 |
105 |
106 |
Plotting objects
107 |
116 |
117 |
118 |
119 |
153 |
154 |
167 |
--------------------------------------------------------------------------------
/src/assets/chart-examples.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/djaxho/pure-vue-chart/d69becbe0b9df9f5a9359c3fc63d94d99e3a5ade/src/assets/chart-examples.png
--------------------------------------------------------------------------------
/src/assets/charts-with-labels.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/djaxho/pure-vue-chart/d69becbe0b9df9f5a9359c3fc63d94d99e3a5ade/src/assets/charts-with-labels.png
--------------------------------------------------------------------------------
/src/assets/charts-with-max-axis.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/djaxho/pure-vue-chart/d69becbe0b9df9f5a9359c3fc63d94d99e3a5ade/src/assets/charts-with-max-axis.png
--------------------------------------------------------------------------------
/src/assets/charts.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/djaxho/pure-vue-chart/d69becbe0b9df9f5a9359c3fc63d94d99e3a5ade/src/assets/charts.gif
--------------------------------------------------------------------------------
/src/assets/long-charts.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/djaxho/pure-vue-chart/d69becbe0b9df9f5a9359c3fc63d94d99e3a5ade/src/assets/long-charts.png
--------------------------------------------------------------------------------
/src/assets/trendline.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/djaxho/pure-vue-chart/d69becbe0b9df9f5a9359c3fc63d94d99e3a5ade/src/assets/trendline.png
--------------------------------------------------------------------------------
/src/components/PureVueChart.vue:
--------------------------------------------------------------------------------
1 |
2 |
9 | {{ title }}
13 |
14 |
19 |
24 |
25 |
30 | {{ staticValue }}
31 |
32 |
33 |
40 | {{ staticValue }}
47 |
48 |
54 |
59 | {{ label }}
60 |
61 |
62 |
70 |
71 |
72 |
73 |
82 |
83 |
84 |
92 |
93 |
94 |
102 |
103 |
111 | {{ tick.text }}
118 |
119 |
120 |
121 |
122 |
123 |
124 |
345 |
346 |
351 |
--------------------------------------------------------------------------------
/src/main.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue';
2 | import App from './App.vue';
3 |
4 | Vue.config.productionTip = false;
5 |
6 | new Vue({
7 | render: h => h(App),
8 | }).$mount('#app');
9 |
--------------------------------------------------------------------------------
/src/wrapper.js:
--------------------------------------------------------------------------------
1 | // Import vue component
2 | import PureVueChart from './components/PureVueChart.vue';
3 |
4 | // Declare install function executed by Vue.use()
5 | export function install(Vue) {
6 | if (install.installed) return;
7 | install.installed = true;
8 | Vue.component('pure-vue-chart', PureVueChart);
9 | }
10 |
11 | // Create module definition for Vue.use()
12 | const plugin = {
13 | install,
14 | };
15 |
16 | // Auto-install when vue is found (eg. in browser via