Chart.js: Docs for adding mixed charts - Line and Bar

Created on 2 May 2016  路  2Comments  路  Source: chartjs/Chart.js

I'm unable to find out the docs in version 2 of Charts.js.
Any idea how to go about adding mixed charts ? ( A line and bar graph in the same chart)

help wanted bug documentation

Most helpful comment

@etimberg That didn't seem to work for me!! - It didn't display the bar graph, just the line graph
This instead did work :

var chartInstance = new Chart(ctx, {
  type: 'bar', // Setting this as the default
  data: {
    datasets: [{
      // Makes this dataset bars by default
      data: []
    }, {
      // Makes this dataset a line
      type: 'line'
    }]
  }
});

All 2 comments

@adityaanandmc you would do the following:

var chartInstance = new Chart(ctx, {
  data: {
    datasets: [{
      // Makes this dataset bars
      type: 'bar',
      data: []
    }, {
      // Makes this dataset a line
      type: 'line'
    }]
  }
});

@etimberg That didn't seem to work for me!! - It didn't display the bar graph, just the line graph
This instead did work :

var chartInstance = new Chart(ctx, {
  type: 'bar', // Setting this as the default
  data: {
    datasets: [{
      // Makes this dataset bars by default
      data: []
    }, {
      // Makes this dataset a line
      type: 'line'
    }]
  }
});
Was this page helpful?
0 / 5 - 0 ratings

Related issues

gouthamrv picture gouthamrv  路  3Comments

joebirkin picture joebirkin  路  3Comments

SylarRuby picture SylarRuby  路  3Comments

adriantombu picture adriantombu  路  3Comments

benmccann picture benmccann  路  3Comments