Linear Scale - Suggested Min-Max

Linear Scale - Suggested Min-Max - 图1

config setup

  1. const config = {
  2. type: 'line',
  3. data: data,
  4. options: {
  5. responsive: true,
  6. plugins: {
  7. title: {
  8. display: true,
  9. text: 'Suggested Min and Max Settings'
  10. }
  11. },
  12. scales: {
  13. y: {
  14. // the data minimum used for determining the ticks is Math.min(dataMin, suggestedMin)
  15. suggestedMin: 30,
  16. // the data maximum used for determining the ticks is Math.max(dataMax, suggestedMax)
  17. suggestedMax: 50,
  18. }
  19. }
  20. },
  21. };
  1. const DATA_COUNT = 7;
  2. const NUMBER_CFG = {count: DATA_COUNT, min: 0, max: 100};
  3. const labels = Utils.months({count: 7});
  4. const data = {
  5. labels: labels,
  6. datasets: [
  7. {
  8. label: 'Dataset 1',
  9. data: [10, 30, 39, 20, 25, 34, -10],
  10. borderColor: Utils.CHART_COLORS.red,
  11. backgroundColor: Utils.CHART_COLORS.red,
  12. },
  13. {
  14. label: 'Dataset 2',
  15. data: [18, 33, 22, 19, 11, 39, 30],
  16. borderColor: Utils.CHART_COLORS.blue,
  17. backgroundColor: Utils.CHART_COLORS.blue,
  18. }
  19. ]
  20. };

Docs