Chart.js: Bar chart won't render with specific plots

Created on 17 Nov 2017  路  2Comments  路  Source: chartjs/Chart.js

Expected Behavior

I would expect to be able to load data for a bar chart plotted against the x-axis. For example:

data: [
                            {x:"8/2017",y:2,
                            x:"9/2017",y:5}
                        ]

In this case, the particular dataset will plot on the x-axis for 8/2017 and 9/2017. If there are more possibilities on the x-axis (like 10/2017), it will just not plot there.

Current Behavior

Hard to explain - but basically it doesn't do any plotting on those x-axis points.

Here's a codepen example where Dataset 2 (red) is what I am trying to plot in a predetermined fashion:

https://codepen.io/anon/pen/RjjGZL

Context

Imagine plotting employee hours, where each bar represents an employee in a given month. Bob may show up once for each month he works, and the height of the bar is the hours worked that month. If Bob skips a month, I want to be able to plot accordingly, hence the strict data provided.

Environment

  • Chart.js version: 2.7.1
  • Browser name and version: Chrome 62.0.3202.94
  • Link to your project: private but codepen may help

Most helpful comment

@Farbed you have a typo in the data array. There should be two objects not one. https://codepen.io/etimberg/pen/vWWjRJ

All 2 comments

@Farbed you have a typo in the data array. There should be two objects not one. https://codepen.io/etimberg/pen/vWWjRJ

@etimberg wow. I stared at this for a solid 3 hours. Thank you so much and sorry to flag it as an issue!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

srijitcoder picture srijitcoder  路  3Comments

adriantombu picture adriantombu  路  3Comments

lizbanach picture lizbanach  路  3Comments

HeinPauwelyn picture HeinPauwelyn  路  3Comments

gabrieldesouza picture gabrieldesouza  路  3Comments