Closed pooriajr closed 3 years ago
Oh, just had another issue with an invalid time object. This time from simply using
<%= line_chart @event.visits.group_by_hour(:created_at).count %>
which generated:
<div id="chart-1" style="height: 300px; width: 100%; text-align: center; color: #999; line-height: 300px; font-size: 14px; font-family: 'Lucida Grande', 'Lucida Sans Unicode', Verdana, Arial, Helvetica, sans-serif;">Loading...</div>
<script>
(function() {
if (document.documentElement.hasAttribute("data-turbolinks-preview")) return;
var createChart = function() { new Chartkick["LineChart"]("chart-1", [["2021-04-23T20:00:00.000Z",4],["2021-04-23T21:00:00.000Z",1]], {}); };
if ("Chartkick" in window) {
createChart();
} else {
window.addEventListener("chartkick:load", createChart, true);
}
})();
</script>
So this probably isn't related to xmin/xman specifically. But I don't know what could be causing it...
Hey @pooriar, I'm having trouble reproducing the errors with the same code. A few questions:
chartkick
, chart.js
, chartjs-adapter-date-fns
, and date-fns
NPM packages? If Sprockets, what version of the chartkick
Ruby gem?Hi @ankane, thank you for responding!
I am using Webpacker
Versions:
4.0.3
3.1.1
2.0.0
2.21.1
Browsers:
Thanks. Still not able to reproduce unfortunately. Can you try creating a fresh Rails app to see if it still appears?
Ok, so everything I said above was irrelevant.
Here's the problem, and it's extremely easy to replicate, I just did it in a fresh rails app:
That gives me the error on my initial app and the fresh test app
I'm going to get around it by using height: 0
instead of display: none
.
I have simillar issue. My charts are inside Bootstrap accordion. If I put it outside, it will just work.
Thank you both for reporting. Fixed in the latest release.
Ref: https://github.com/ankane/chartkick.js/commit/b1f3c337094f41393245d8104b59934625f77f8f
Describe the bug I was trying to use the xmin and xmax attributes as show in documentation:
This broke the chart, giving an invalid time error
If I remove those attributes, the chart renders fine.
I fiddled around with many different time formats to get it working but nothing worked. Not sure how to set the limits on X axis. Help would be greatly appreciated 😄
Backtrace:
To reproduce
HTML generated by Chartkick