Bar Chart Border Radius

Bar Chart Border Radius - 图1

config setup actions

  1. const config = {
  2. type: 'bar',
  3. data: data,
  4. options: {
  5. responsive: true,
  6. plugins: {
  7. legend: {
  8. position: 'top',
  9. },
  10. title: {
  11. display: true,
  12. text: 'Chart.js Bar Chart'
  13. }
  14. }
  15. },
  16. };
  1. const DATA_COUNT = 7;
  2. const NUMBER_CFG = {count: DATA_COUNT, min: -100, max: 100};
  3. const labels = Utils.months({count: 7});
  4. const data = {
  5. labels: labels,
  6. datasets: [
  7. {
  8. label: 'Fully Rounded',
  9. data: Utils.numbers(NUMBER_CFG),
  10. borderColor: Utils.CHART_COLORS.red,
  11. backgroundColor: Utils.transparentize(Utils.CHART_COLORS.red, 0.5),
  12. borderWidth: 2,
  13. borderRadius: Number.MAX_VALUE,
  14. borderSkipped: false,
  15. },
  16. {
  17. label: 'Small Radius',
  18. data: Utils.numbers(NUMBER_CFG),
  19. borderColor: Utils.CHART_COLORS.blue,
  20. backgroundColor: Utils.transparentize(Utils.CHART_COLORS.blue, 0.5),
  21. borderWidth: 2,
  22. borderRadius: 5,
  23. borderSkipped: false,
  24. }
  25. ]
  26. };
  1. const actions = [
  2. {
  3. name: 'Randomize',
  4. handler(chart) {
  5. chart.data.datasets.forEach(dataset => {
  6. dataset.data = Utils.numbers({count: chart.data.labels.length, min: -100, max: 100});
  7. });
  8. chart.update();
  9. }
  10. },
  11. ];