An open API service indexing awesome lists of open source software.

https://github.com/willin/vchart

Vue Chartist.js Component
https://github.com/willin/vchart

chartist component vue

Last synced: 19 days ago
JSON representation

Vue Chartist.js Component

Awesome Lists containing this project

README

        

# vchart

Vue [Chartist.js](https://gionkunz.github.io/chartist-js) Component

[![github](https://img.shields.io/github/followers/willin.svg?style=social&label=Follow)](https://github.com/willin) [![npm](https://img.shields.io/npm/v/vchart.svg)](https://npmjs.org/package/vchart) [![npm](https://img.shields.io/npm/dm/vchart.svg)](https://npmjs.org/package/vchart) [![npm](https://img.shields.io/npm/dt/vchart.svg)](https://npmjs.org/package/vchart) ![size](https://img.shields.io/github/size/willin/vchart/dist/vchart.min.js.svg) ![dep](https://img.shields.io/david/willin/vchart.svg)

> 浏览器版本: 3.78kb, GZip压缩后1.42kb

## Usage / 使用说明

### Installation / 安装

```bash
yarn add vchart
# or
npm i -S vchart
```

### Props

- __ratio__ - `String`
class ratio of Chartist. see values on / 参考: [Chartist web site](https://gionkunz.github.io/chartist-js/getting-started.html#as-simple-as-it-can-get)

- __type__ - `String` (required / 必选)
chart type, possible values: / 支持的类型有:
- `Line`
- `Bar`
- `Pie`

- __data__ - `Object` data object like this:
```js
// 示例:
const data = {
labels: ["A", "B", "C"],
series:[[1, 3, 2], [4, 6, 5]]
}
```

- __options__ - `Object`
options object, see defaultOptions on / 默认配置参考 [API Documentation / API 文档](https://gionkunz.github.io/chartist-js/api-documentation.html)

- __empty__ - `String`
message when no data / 无数据时显示的文字消息

- __event-handlers__ - `Array`
a special array to use `chart.on(event, function)`
```javascript
// 处理 `chart.on(event, function)` 事件
const eventHandlers = [{
event: 'draw',
fn() {
// animation / 动画
}
}, {
// an other event hander / 另一个事件处理器
}]
```

- __responsive-options__ - `Array`
object for responsive options / 响应式参数对象

## Example / 示例

Demo / 在线示例:

### Single File Components / 单文件组件中使用

```vue

import vchart from 'vchart';

exports default {
components: {
vchart
},
data() {
return {
data: {
labels: ["周一", "周二", "周三", "周四", "周五"],
series: [[4, 3.8, 3, 5, 4.1]]
},
type: 'Line',
options: {
fullWidth: true,
lineSmooth: false
}
};
}
}

```

### Browser / 浏览器中使用

```html





new Vue({
el: '#app',
components: {
vchart
},
data() {
return {
data: {
labels: ["周一", "周二", "周三", "周四", "周五"],
series: [[4, 3.8, 3, 5, 4.1]]
},
type: 'Line',
options: {
fullWidth: true,
lineSmooth: false
}
}
}
})

```

### Animation / 动画

Demo / 演示: https://jsfiddle.net/willin/esvw0q91/

常用的三种动画:

- `dashoffset` 跑马灯
- `bouncing-stroke` 弹簧
- `exploding-stroke` 爆炸

```css
* {
transform-origin: 0px 0px 0px;
}
.ct-line {
stroke-dasharray: 5px;
/* change animation name */
animation: dashoffset 1s linear infinite;
}

@keyframes dashoffset {
0% {
stroke-dashoffset: 0px;
}

100% {
stroke-dashoffset: -20px;
}
}

@keyframes bouncing-stroke {
0% {
stroke-width: 5px;
}

50% {
stroke-width: 10px;
}

100% {
stroke-width: 5px;
}
}

@keyframes exploding-stroke {
0% {
stroke-width: 2px;
opacity: 1;
}

100% {
stroke-width: 20px;
opacity: 0;
}
}
```

## License

MIT

通过支付宝捐赠:

![qr](https://cloud.githubusercontent.com/assets/1890238/15489630/fccbb9cc-2193-11e6-9fed-b93c59d6ef37.png)