Giter Site home page Giter Site logo

toast-ui.vue-chart's Introduction

TOAST UI Chart for Vue

This is Vue component wrapping TOAST UI Chart.

vue2 github version npm version license PRs welcome code with hearth by NHN

๐Ÿšฉ Table of Contents

Collect statistics on the use of open source

Vue Wrapper of TOAST UI Chart applies Google Analytics (GA) to collect statistics on the use of open source, in order to identify how widely TOAST UI Chart is used throughout the world. It also serves as important index to determine the future course of projects. location.hostname (e.g. > โ€œui.toast.com") is to be collected and the sole purpose is nothing but to measure statistics on the usage. To disable GA, use the following usageStatistics options when declare Vue Wrapper compoent.

var options = {
    ...
    usageStatistics: false
}

Or, include tui-code-snippet.js (v1.4.0 or later) and then immediately write the options as follows:

tui.usageStatistics = false;

๐Ÿ’พ Install

Using npm

npm install --save @toast-ui/vue-chart

๐Ÿ“Š Usage

Load

You can use Toast UI Chart for Vue as moudule format or namespace. When using module format, you should load tui-chart.css in the script. Also, map files are not included, so if you want to use a map chart, you have to import map files in the same way.

  • Using Ecmascript module

    import 'tui-chart/dist/tui-chart.css'
    import { barChart, lineChart } from '@toast-ui/vue-chart'
  • Using Commonjs module

    require('tui-chart/dist/tui-chart.css');
    var toastui = require('@toast-ui/vue-chart');
    var barChart = toastui.barChart;
    var lineChart = toastui.lineChart;
  • Using namespace

    var barChart = toastui.barChart;
    var lineChart = toastui.lineChart;
  • Using map files

    import 'tui-chart/dist/maps/south-korea';
    import { mapChart } from '@toast-ui/vue-chart'

Components

You can use all kinds of charts in tui.chart. Vue Components for each chart types are:

  • barChart
  • columnChart
  • lineChart
  • areaChart
  • bubbleChart
  • scatterChart
  • pieChart
  • comboChart
  • mapChart
  • heatmapChart
  • treemapChart
  • radialChart
  • boxplotChart
  • bulletChart

Implement

  1. If you want to use barChart, insert <bar-chart> in the template or html. data prop is required.

    <bar-chart :data="chartData"/>
  2. Load chart component and then add it to the components in your component or Vue instance.

    If you want to use barChart, implement like this:

    import 'tui-chart/dist/tui-chart.css'
    import { barChart } from '@toast-ui/vue-chart'
    
    export default {
        components: {
            'bar-chart': barChart
        },
        data() {
            return {
                chartData: { // for 'data' prop of 'bar-chart'
                    categories: ['July', 'Aug', 'Sep', 'Oct', 'Nov'],
                    series: [
                        {
                            name: 'Budget',
                            data: [3000, 5000, 7000, 6000, 4000]
                        },
                        {
                            name: 'Income',
                            data: [1000, 7000, 2000, 5000, 3000]
                        }
                    ]
                }
            }
        }
    }

    or

    import 'tui-chart/dist/tui-chart.css'
    import { barChart } from '@toast-ui/vue-chart'
    
    new Vue({
        el: '#app',
        components: {
            'bar-chart': barChart
        },
        data() {
            return {
                chartData: { // for 'data' prop of 'bar-chart'
                    categories: ['July', 'Aug', 'Sep', 'Oct', 'Nov'],
                    series: [
                        {
                            name: 'Budget',
                            data: [3000, 5000, 7000, 6000, 4000]
                        },
                        {
                            name: 'Income',
                            data: [1000, 7000, 2000, 5000, 3000]
                        }
                    ]
                }
            }
        }
    });

Props

You can use data, options, theme props for initailize tui.chart.

If you want to use other maps, you should use map prop.

For more detail with example, see Getting-Started

Name Type Required Description
data Object O This prop is for data of the chart. When you change data, chart is rendering for changing data.
options Object X This prop is for options of tui.chart. You can configuration about chart.
theme Object X This prop can change theme of the chart.
map Object X If you want to use other maps, you set Object that is required name and value.

Event

For more detail with example, see Getting-Started

Name Description
load This event occurs when the chart is loaded, except options has showLabel: true in the series.
selectLegend This event occurs when the label of legend is clicked.
selectSeries This event occurs when options has allowSelect: true in the series and then the series is selected.
unselectSeries This event occurs when options has allowSelect: true in the series and then the series is unselected.
beforeShowTooltip This event occurs before tooltip show.
afterShowTooltip This event occurs after tooltip show.
beforeHideTooltip This event occurs before tooltip hide.
zoom This event occurs when change rate of zoom.
changeCheckedLegends This event occurs when the legend's checkbox changes.

Method

For use method, first you need to assign ref attribute of element like this:

<bar-chart ref="tuiBarChart" data="chartData"/>

After then you can use methods through this.$refs. We provide invoke method. You can use invoke method to call the method of tui.chart. First argument of invoke is name of the method and second argument is parameters of the method.

this.$refs.tuiBarChart.invoke('resize', {
    width: 500,
    height: 500
});
const checkedLegend = this.$refs.tuiBarChart.invoke('getCheckedLegend');

In the api document, check the methods for each chart type.

๐Ÿ”ง Pull Request Steps

TOAST UI products are open source, so you can create a pull request(PR) after you fix issues. Run npm scripts and develop yourself with the following process.

Setup

Fork develop branch into your personal repository. Clone it to local computer. Install node modules. Before starting development, you should check to haveany errors.

$ git clone https://github.com/{your-personal-repo}/[[repo name]].git
$ cd [[repo name]]
$ npm install

Develop

Let's start development!

Pull Request

Before PR, check to test lastly and then check any errors. If it has no error, commit and then push it!

For more information on PR's step, please see links of Contributing section.

๐Ÿ“™ Documents

๐Ÿ’ฌ Contributing

๐Ÿ“œ License

This software is licensed under the MIT ยฉ NHN.

toast-ui.vue-chart's People

Contributors

1ambda avatar jungeun-cho avatar

Watchers

 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.