Radar Chart Stacked

Radar Chart Stacked - 图1

config setup actions

  1. const config = {
  2. type: 'radar',
  3. data: data,
  4. options: {
  5. plugins: {
  6. filler: {
  7. propagate: false
  8. },
  9. 'samples-filler-analyser': {
  10. target: 'chart-analyser'
  11. }
  12. },
  13. interaction: {
  14. intersect: false
  15. }
  16. }
  17. };
  1. const inputs = {
  2. min: 8,
  3. max: 16,
  4. count: 8,
  5. decimals: 2,
  6. continuity: 1
  7. };
  8. const generateLabels = () => {
  9. return Utils.months({count: inputs.count});
  10. };
  11. const generateData = () => {
  12. const values = Utils.numbers(inputs);
  13. inputs.from = values;
  14. return values;
  15. };
  16. const labels = Utils.months({count: 8});
  17. const data = {
  18. labels: generateLabels(),
  19. datasets: [
  20. {
  21. label: 'D0',
  22. data: generateData(),
  23. borderColor: Utils.CHART_COLORS.red,
  24. backgroundColor: Utils.transparentize(Utils.CHART_COLORS.red),
  25. },
  26. {
  27. label: 'D1',
  28. data: generateData(),
  29. borderColor: Utils.CHART_COLORS.orange,
  30. hidden: true,
  31. backgroundColor: Utils.transparentize(Utils.CHART_COLORS.orange),
  32. fill: '-1'
  33. },
  34. {
  35. label: 'D2',
  36. data: generateData(),
  37. borderColor: Utils.CHART_COLORS.yellow,
  38. backgroundColor: Utils.transparentize(Utils.CHART_COLORS.yellow),
  39. fill: 1
  40. },
  41. {
  42. label: 'D3',
  43. data: generateData(),
  44. borderColor: Utils.CHART_COLORS.green,
  45. backgroundColor: Utils.transparentize(Utils.CHART_COLORS.green),
  46. fill: false
  47. },
  48. {
  49. label: 'D4',
  50. data: generateData(),
  51. borderColor: Utils.CHART_COLORS.blue,
  52. backgroundColor: Utils.transparentize(Utils.CHART_COLORS.blue),
  53. fill: '-1'
  54. },
  55. {
  56. label: 'D5',
  57. data: generateData(),
  58. borderColor: Utils.CHART_COLORS.purple,
  59. backgroundColor: Utils.transparentize(Utils.CHART_COLORS.purple),
  60. fill: '-1'
  61. },
  62. {
  63. label: 'D6',
  64. data: generateData(),
  65. borderColor: Utils.CHART_COLORS.grey,
  66. backgroundColor: Utils.transparentize(Utils.CHART_COLORS.grey),
  67. fill: {value: 85}
  68. }
  69. ]
  70. };
  1. let smooth = false;
  2. let propagate = false;
  3. const actions = [
  4. {
  5. name: 'Randomize',
  6. handler(chart) {
  7. inputs.from = [];
  8. chart.data.datasets.forEach(dataset => {
  9. dataset.data = generateData();
  10. });
  11. chart.update();
  12. }
  13. },
  14. {
  15. name: 'Propagate',
  16. handler(chart) {
  17. propagate = !propagate;
  18. chart.options.plugins.filler.propagate = propagate;
  19. chart.update();
  20. }
  21. },
  22. {
  23. name: 'Smooth',
  24. handler(chart) {
  25. smooth = !smooth;
  26. chart.options.elements.line.tension = smooth ? 0.4 : 0;
  27. chart.update();
  28. }
  29. }
  30. ];
DatasetFillTarget (visibility)
0undefinedboundary “start”
1“-1”(hidden)
21dataset 1
3falsenone
4“-1”dataset 3
5“-1”dataset 4
6{“value”:85}boundary “[object Object]”