简体   繁体   中英

Chart.js - shrinking legend to fit data

Have a very simple chart, 3 series in the data set, however I want to shrink the chart so it's not scaling to the next month with whitespace, is there an option for this?

I feel like I've tried everything, see on the right hand side how it includes Jun because the date on the last item would be something like 2019-05-02, but I want to hide the whitespace if possible!

我的示例图表

xAxes: [{
  stacked: true,
  beginAtZero: true,
  bounds: 'ticks',
  ticks: {
    stepSize: 1,
    min: 0,
    autoSkip: true
  },
  type: 'time',
  position: 'bottom',
  time: {
    tooltipFormat: 'YYYY/MM/DD',
    unit: 'month',
  },
  scaleLabel: {
    display: true,
    labelString: 'Date Range',
    fontSize: 20
  }
}]

That's because of bounds: 'ticks' .

If you write bounds: 'data' (or simply remove it because data is the default setting) there is no whitespace.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM