Coder Social home page Coder Social logo

vue-chartist's Introduction

vue-chartist

Plugin Vuejs for Chartist.js

Install

npm install vue-chartist

Setup

This package include Chartist's javascript but not the stylesheet

Vue.use(require('vue-chartist'))

Usage

In your HTML, add <chartist> tag. This tag take the following attributes :

  • ratio - String class ratio of Chartist, see values on Chartist web site

  • type - String (required) chart type, possible values :

    • Line
    • Bar
    • Pie
  • data - Object data object like this

const data = {
    labels: ["A", "B", "C"],
    series:[[1, 3, 2], [4, 6, 5]]
}
  • options - Object options object, see defaultOptions on API Documentation

  • event-handlers - Array a special array to use chart.on(event, function)

const eventHandlers = [{
    event: 'draw',
    fn() {
        //animation
    }
}, {
    //an other event hander
}]
  • responsive-options - Array object for responsive options

Example

<chartist
    ratio="ct-major-second"
    type="Line"
    :data="chartData"
    :options="chartOptions" >
</chartist>

Note: think about using the dynamic props of Vuejs to bind easliy your data or other.

new Vue({
    el:'#app',
    data: {
        chartData: {
            labels: ["A", "B", "C"],
            series:[[1, 3, 2], [4, 6, 5]]
        },
        chartOptions: {
            lineSmooth: false
        }
    }
})

Customize chart with no data

If chart data are empty or not definied the plugin add ct-nodata (or a custom class, see options plugin) class and write a message on the element. That way, you can customize your element with CSS when you have no data to display. To choose your message use the options plugin.

Options Plugin

Vue.use(require('vue-chartist'), {
    messageNoData: "You have not enough data",
    classNoData: "empty"
})

Chartist instance

There is two way to access this Chartist's instance : By Vue instance

Vue.chartist

or in component

this.$chartist

vue-chartist's People

Contributors

bdunn313 avatar horsetoast avatar kartsims avatar nilssolanki avatar yopadd avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.