angular-chart.js icon indicating copy to clipboard operation
angular-chart.js copied to clipboard

problem with type:'time'

Open blurry-code opened this issue 9 years ago • 4 comments

Hi, I am using angular-chart.js in an mobile app. Whenever I change the settings for the chart (data, labels, datasetOverride) the change takes very long. Depending on the device it takes up to 5 seconds while the required data is available after milliseconds.

I am not sure, but I believe it is caused by type:'time' on my x-axis. I tried to create a fiddle for testing/showing the delay. For some reason the fiddle is not working with type:'time'. Please have a look at my fiddle: https://jsfiddle.net/blurry_code/fwpq1x5n/ and try to uncomment the scale type in $scope.options.

Now fixing the fiddle is not the main objective here. But the mere fact that it's not working at all using type:'time' indicates that there's something wrong. (unless I have a typo somewhere).

I am using:

  • AngularJS 1.6.1
  • chart.js 2.4.0
  • angular-chart.js 1.1.0

blurry-code avatar Jan 05 '17 16:01 blurry-code

You need to include moment.js for the time type. See message in console and Chart.js docs

Error: Chart.js - Moment.js could not be found! You must include it before Chart.js to use the time scale. Download at https://momentjs.com at a.initialize (VM185 Chart.min.js:14) at a.t.Element (VM185 Chart.min.js:12) at a [as constructor] (VM185 Chart.min.js:12) at new a (VM185 Chart.min.js:12) at VM185 Chart.min.js:11 at Object.o.each (VM185 Chart.min.js:12) at t.Controller.buildScales (VM185 Chart.min.js:11) at t.Controller.initialize (VM185 Chart.min.js:11) at new t.Controller (VM185 Chart.min.js:11) at new t (VM185 Chart.min.js:12)

On Fri, Jan 6, 2017 at 3:10 AM, Tobias Philipp [email protected] wrote:

Hi, I am using angular-chart.js in an mobile app. Whenever I change the settings for the chart (data, labels, datasetOverride) the change takes very long. Depending on the device it takes up to 5 seconds while the required data is available after milliseconds.

I am not sure, but I believe it is caused by type:'time' on my x-axis. I tried to create a fiddle for testing/showing the delay. For some reason the fiddle is not working with type:'time'. Please have a look at my fiddle: https://jsfiddle.net/blurry_code/fwpq1x5n/ and try to uncomment the scale type in $scope.options.

Now fixing the fiddle is not the main objective here. But the mere fact that it's not working at all using type:'time' indicates that there's something wrong. (unless I have a typo somewhere).

I am using:

  • AngularJS 1.6.1
  • chart.js 2.4.0
  • angular-chart.js 1.1.0

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jtblin/angular-chart.js/issues/579, or mute the thread https://github.com/notifications/unsubscribe-auth/ABUxrm9r-MpYr5pCPngn2UJ2aKeyXpHQks5rPRYQgaJpZM4Lb2MW .

jtblin avatar Jan 06 '17 10:01 jtblin

Ah thanks! I updated the fiddle: https://jsfiddle.net/blurry_code/fwpq1x5n/10/.

Now on a computer the performance of switching the data is OK. But on a mobile device it is quite slow. Why is that?

And while we're at it. Why are there white stripes in the chart on a mobile device?

(I tested all of this using an iPod Touch 5th Gen)

blurry-code avatar Jan 06 '17 12:01 blurry-code

I installed moment.js with bower, but I am still getting the same error

ohad-bpal avatar Jan 22 '17 14:01 ohad-bpal

@blurry-code dataset is pretty large, the js engine on mobile is probably struggling to draw that.

@ohad-bpal sorry but that's definitely the issue usually.

jtblin avatar Apr 28 '17 10:04 jtblin