google / chartjs.dart

ARCHIVED/UNMAINTAINED Dart API for Chart.js
https://pub.dev/packages/chartjs
Other
143 stars 53 forks source link

Any idea on how to scale the xAxis based on time in hours? #38

Open makayait opened 4 years ago

makayait commented 4 years ago

I have looked at Chartjs examples in Javascript and tried to implement the dart version of it with the following result.

var xAx = charts.ChartXAxe(
    display: true,
    barThickness: 2,
    type: 'time',
    time: charts.TimeScale(
      parser: "HH:mm:ss",
      unit: 'hour',
      unitStepSize: 1,
      //round: 'hour', // this will round the data.
      tooltipFormat: "HH:mm:ss",
      displayFormats: charts.TimeDisplayFormat(hour: 'HH:mm:ss'),
    ),
  );

putting this xAxis configuration inside of my ChartConfiguration;

var config = charts.ChartConfiguration(
    type: 'line',
    data: data,
    options: charts.ChartOptions(
      responsive: true,
      scales:
          charts.ChartScales<charts.TickOptions>(xAxes: [xAx], yAxes: [yAx]),
    ),
  );

This, however, crashes without any error messages.