chart.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. export default (({
  2. data
  3. }) => {
  4. return _jsxs(Chart, {
  5. data,
  6. children: [
  7. _jsx(Axis, {
  8. field: "label",
  9. tickCount: 12,
  10. style: {
  11. label: {
  12. align: 'between'
  13. },
  14. }
  15. }),
  16. _jsx(Axis, {
  17. field: "value",
  18. tickCount: 5
  19. }),
  20. _jsx(Line, {
  21. x: "label",
  22. y: "value",
  23. lineWidth: "4px",
  24. color: "type"
  25. }),
  26. _jsx(Legend, {
  27. position: "top",
  28. style: {
  29. justifyContent: 'space-around',
  30. },
  31. triggerMap: {
  32. press: (items, records, legend) => {
  33. const map = {};
  34. items.forEach((item) => (map[item.name] = _.clone(item)));
  35. records.forEach((record) => {
  36. map[record.type].value = record.value;
  37. });
  38. legend.setItems(_.values(map));
  39. },
  40. pressend: (items, records, legend) => {
  41. legend.setItems(items);
  42. },
  43. },
  44. })
  45. ]
  46. });
  47. });