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

How to create mixed chart types #29

Closed
willbrowningme opened this issue Jan 10, 2017 · 2 comments
Closed

How to create mixed chart types #29

willbrowningme opened this issue Jan 10, 2017 · 2 comments

Comments

@willbrowningme
Copy link

Expected Behaviour

In the chart js documentation http://www.chartjs.org/docs/#chart-configuration-mixed-chart-types there is a section regarding created mixed charts, for example a line chart with bar overlay.

I tried doing the following:

import Chart from 'vue-chartjs';

export default Chart.Line.extend({
    data: function () {
        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)
    }
})

Actual Behaviour

However this shows the chart but without the bar overlay, I believe it may have something to do with the fact the above is extending Chart.Line and not Chart.Bar.

How can I get multiple charts to work correctly?

Environment

  • OS: Windows 10
  • NPM Version: 3.10.8
@apertureless
Copy link
Owner

From the chartjs docs:

When creating the chart you must set the overall type as bar.

So, try to use Chart.Bar.extend()

@willbrowningme
Copy link
Author

Works perfectly now, can't believe I overlooked that. Thanks

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

No branches or pull requests

2 participants