Skip to content

Commit 96493ea

Browse files
committed
refactor: extract from github.com/coreui/coreui-vue
1 parent fb100f3 commit 96493ea

15 files changed

+687
-13160
lines changed

.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 ie <= 8

LICENSE

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) 2019 CoreUI
3+
Copyright (c) 2021 creativeLabs Łukasz Holeczek
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: 177 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,184 @@
1-
# Coreui Vue Chartjs library
1+
<p align="center">
2+
<a href="https://coreui.io/">
3+
<img
4+
src="https://coreui.io/images/brand/coreui-signet.svg"
5+
alt="CoreUI logo"
6+
width="200"
7+
/>
8+
</a>
9+
</p>
210

3-
![NPM](https://img.shields.io/npm/v/@coreui/vue-chartjs/latest?style=flat&color=brightgreen)
4-
![Downloads](https://img.shields.io/npm/dm/@coreui/vue-chartjs.svg?style=flat)
5-
![Chart.js](https://img.shields.io/badge/Chart.js-^2.9.3-brightgreen.svg)
6-
![Vue](https://img.shields.io/badge/Vue-^2.6.10-brightgreen.svg)
11+
<h3 align="center">CoreUI Vue.js wrapper for Chart.js</h3>
712

8-
## Description
13+
<p align="center">
14+
<a href="https://coreui.io/vue/docs/components/chart/"><strong>Explore @coreui/vue-chartjs docs & examples »</strong></a>
15+
<br>
16+
<br>
17+
<a href="https://github.com/coreui/coreui-vue/issues/new?template=bug_report.md">Report bug</a>
18+
·
19+
<a href="https://github.com/coreui/coreui-vue/issues/new?template=feature_request.md">Request feature</a>
20+
·
21+
<a href="https://blog.coreui.io/">Blog</a>
22+
</p>
923

10-
Dedicated components used to implement [Chart.js](https://www.chartjs.org/) in Vue.js. You can find the **CoreUI Vue library documentation** here [https://coreui.io/vue/docs »](https://coreui.io/vue/docs/components/charts)
24+
## Status
1125

12-
## Features
26+
[![npm package][npm-badge]][npm]
27+
[![NPM downloads][npm-download]][npm]
1328

14-
- Implementation with ease - **You only need to pass 'datasets' prop and you have your chart working**. Optionally you can pass labels, options and plugins according to
15-
[Chart.js docs](https://www.chartjs.org/docs/latest/getting-started/usage.html). The rest of chart.js configuration issues are already resolved,
16-
- Chart will be rendered, even if you don't pass the labels, as empty labels will be generated automatically. You can also assign months or numeric indexes to labels (see prop description),
17-
- If you don't pass tooltip options, coreui-custom-tooltips, would be used by default. They are resolving the chart.js issue with tooltip beeing cut, when exceeding the canvas.
18-
- Dynamic updates of passed configuration. This feature makes your chart.js configuration automatically reactive to changes.
29+
[npm-badge]: https://img.shields.io/npm/v/@coreui/vue-chartjs/latest?style=flat-square
30+
[npm]: https://www.npmjs.com/package/@coreui/vue-chartjs
31+
[npm-download]: https://img.shields.io/npm/dm/@coreui/vue-chartjs.svg?style=flat-square
1932

20-
## Copyright and license
33+
##### install:
2134

22-
Copyright 2019 creativeLabs Łukasz Holeczek. Code released under the MIT license.
35+
```bash
36+
npm install @coreui/vue-chartjs
37+
38+
# or
39+
40+
yarn add @coreui/vue-chartjs
41+
```
42+
43+
##### import:
44+
45+
```jsx
46+
import { CChart } from '@coreui/vue-chartjs'
47+
```
48+
49+
or
50+
51+
```js
52+
import {
53+
CChart,
54+
CChartBar,
55+
CChartHorizontalBar,
56+
CChartLine,
57+
CChartDoughnut,
58+
CChartRadar,
59+
CChartPie,
60+
CChartPolarArea,
61+
} from '@coreui/vue-chartjs'
62+
```
63+
64+
##### props:
65+
66+
```js
67+
/**
68+
* Enables custom html based tooltips instead of standard tooltips.
69+
*
70+
* @default true
71+
*/
72+
customTooltips: {
73+
type: Boolean,
74+
default: true,
75+
required: false,
76+
},
77+
/**
78+
* The data object that is passed into the Chart.js chart (more info).
79+
*/
80+
data: {
81+
type: [Object, Function] as PropType<ChartData | ((canvas: HTMLCanvasElement) => ChartData)>,
82+
required: true,
83+
},
84+
/**
85+
* Height attribute applied to the rendered canvas.
86+
*
87+
* @default 150
88+
*/
89+
height: {
90+
type: Number,
91+
default: 150,
92+
required: false,
93+
},
94+
/**
95+
* ID attribute applied to the rendered canvas.
96+
*/
97+
id: {
98+
type: String,
99+
default: undefined,
100+
required: false,
101+
},
102+
/**
103+
* The options object that is passed into the Chart.js chart.
104+
*
105+
* {@link https://www.chartjs.org/docs/latest/general/options.html More Info}
106+
*/
107+
options: {
108+
type: Object as PropType<ChartOptions>,
109+
default: undefined,
110+
required: false,
111+
},
112+
/**
113+
* The plugins array that is passed into the Chart.js chart (more info)
114+
*
115+
* {@link https://www.chartjs.org/docs/latest/developers/plugins.html More Info}
116+
*/
117+
plugins: {
118+
type: Array as PropType<Plugin[]>,
119+
default: undefined,
120+
},
121+
/**
122+
* If true, will tear down and redraw chart on all updates.
123+
*/
124+
redraw: Boolean,
125+
/**
126+
* Chart.js chart type.
127+
*
128+
* @type {'line' | 'bar' | 'radar' | 'doughnut' | 'polarArea' | 'bubble' | 'pie' | 'scatter'}
129+
*/
130+
type: {
131+
type: String as PropType<ChartType>,
132+
default: 'bar',
133+
required: false,
134+
},
135+
/**
136+
* Width attribute applied to the rendered canvas.
137+
*
138+
* @default 300
139+
*/
140+
width: {
141+
type: Number,
142+
default: 300,
143+
required: false,
144+
},
145+
/**
146+
* Put the chart into the wrapper div element.
147+
*
148+
* @default true
149+
*/
150+
wrapper: {
151+
type: Boolean,
152+
default: true,
153+
required: false,
154+
},
155+
```
156+
157+
##### usage:
158+
159+
```vue
160+
<CChartLine
161+
:wrapper="false"
162+
:data="{
163+
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
164+
datasets: [
165+
{
166+
label: 'My First dataset',
167+
backgroundColor: 'rgba(220, 220, 220, 0.2)',
168+
borderColor: 'rgba(220, 220, 220, 1)',
169+
pointBackgroundColor: 'rgba(220, 220, 220, 1)',
170+
pointBorderColor: '#fff',
171+
data: [40, 20, 12, 39, 10, 40, 39]
172+
},
173+
{
174+
label: 'My Second dataset',
175+
backgroundColor: 'rgba(151, 187, 205, 0.2)',
176+
borderColor: 'rgba(151, 187, 205, 1)',
177+
pointBackgroundColor: 'rgba(151, 187, 205, 1)',
178+
pointBorderColor: '#fff',
179+
data: [50, 12, 28, 29, 7, 25, 12]
180+
}
181+
]
182+
}"
183+
/>
184+
```

babel.config.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)