Chart.js: Wrong data passed into custom renderer in 2.9.x

Created on 20 Nov 2019  ·  2Comments  ·  Source: chartjs/Chart.js

Expected Behavior

Expected behavior as it was in Chart.js 2.8.x.
draw method in my applyCustomRenderer should get correct data in this._model.x and this._model.width.
See values in the console in following codepen, there are correct float values.
https://codepen.io/Misticek/pen/jOOJNgv

Current Behavior

Chart.js 2.9.x
draw method getting NaN values in this._model.x and this._model.width instead of correctly calculated values as it is in 2.8.0.
https://codepen.io/Misticek/pen/jOOJNvx

Steps to Reproduce (for bugs)

Codepen links above, see console.log for both code pens.

Context

Trying to render rounded corner bars like this (version 2.8.0):
image
With version 2.9.x I am unable to render these rounded bars because of NaN values in this._model.x and this._model.width. No bars are being rendered at all.

Environment

  • Chart.js version: 2.9.x
  • Browser name and version: All browsers
bug

Most helpful comment

This is a very nice looking chart!

This seems like a duplicate of https://github.com/chartjs/Chart.js/issues/6636. Please see there for details on how to solve

Also make sure you've read the documentation on this page: https://www.chartjs.org/docs/latest/developers/charts.html#bar-controller

All 2 comments

This is a very nice looking chart!

This seems like a duplicate of https://github.com/chartjs/Chart.js/issues/6636. Please see there for details on how to solve

Also make sure you've read the documentation on this page: https://www.chartjs.org/docs/latest/developers/charts.html#bar-controller

Hey Ben,

yes you are right, it's duplicate. Sorry, did not notice that one.
So yeah, I have fixed that by adding default dataset for new bar type.
Here is my fixed codepen for other users, new added line is commented.
https://codepen.io/Misticek/pen/XWWGqWK

Thanks!

Was this page helpful?
0 / 5 - 0 ratings