Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combination of Bar and Line Chart #123

Closed
alokpandeyrc opened this issue Jun 19, 2017 · 5 comments
Closed

Combination of Bar and Line Chart #123

alokpandeyrc opened this issue Jun 19, 2017 · 5 comments

Comments

@alokpandeyrc
Copy link

Is it possible to achieve combination of Bar and Line chart ?

Environment

  • vue.js version: <2.0>
  • vue-chart.js version:
  • npm version:
@apertureless
Copy link
Owner

Sure! Check out the docs for that: http://www.chartjs.org/docs/latest/charts/mixed.html

You only need to create chart from the bar basechart

import {Bar} from 'vue-chartjs'

export default Bar.extend({....})

And in your dataset array you can change specific datasets to line.

@alokpandeyrc
Copy link
Author

Thanx @apertureless....it worked...

@riksnelders
Copy link

riksnelders commented Apr 10, 2018

Doesnt seem to work for me..

WEBPACK_IMPORTED_MODULE_0_vue_chartjs_.a.extend is not a function

import {Bar} from 'vue-chartjs'

    export default Bar.extend({
 
        data(){
            return {
                options: {
                    responsive: true,
                    maintainAspectRatio: false
                }
            }
        },
        mounted () {
            this.renderChart({
                labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
                datasets: [
                    {
                        type: 'bar',
                        label: 'Bar Component',
                        data: [10, 20, 30],
                    },
                    {
                        type: 'line',
                        label: 'Line Component',
                        data: [30, 20, 10],
                    }
                ]
            }, this.options)
        }
    })

EDIT:
Should be:

 export default {....

Working now

@apertureless
Copy link
Owner

Yeah with v3 the syntax for chart creation has changed.

@mkstix6
Copy link

mkstix6 commented Sep 4, 2019

Could anyone post a full example of a mixed Bar and Line chart with separate axes here for v3? I'm struggling with this a little. I have managed to get lines to appear but not a bar at the same time.
Wait, never mind. Axes type: 'linear' was the cause of my bar chart not rendering:

// Don't do this if you want a bar chart.
 xAxes: [
    {
        type: 'linear'
    }
],

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants