scriptable-object.js 927 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. module.exports = {
  2. config: {
  3. type: 'bar',
  4. data: {
  5. labels: [0, 1, 2, 3, 4, 5],
  6. datasets: [
  7. {
  8. // option in dataset
  9. data: [0, 5, 10, null, -10, -5],
  10. borderSkipped: false,
  11. borderWidth: function(ctx) {
  12. var value = ctx.dataset.data[ctx.dataIndex] || 0;
  13. return {top: Math.abs(value)};
  14. }
  15. },
  16. {
  17. // option in element (fallback)
  18. data: [0, 5, 10, null, -10, -5]
  19. }
  20. ]
  21. },
  22. options: {
  23. legend: false,
  24. title: false,
  25. elements: {
  26. rectangle: {
  27. backgroundColor: 'transparent',
  28. borderColor: '#80808080',
  29. borderSkipped: false,
  30. borderWidth: function(ctx) {
  31. return {left: ctx.dataIndex * 2};
  32. }
  33. }
  34. },
  35. scales: {
  36. xAxes: [{display: false}],
  37. yAxes: [
  38. {
  39. display: false,
  40. ticks: {
  41. beginAtZero: true
  42. }
  43. }
  44. ]
  45. }
  46. }
  47. },
  48. options: {
  49. canvas: {
  50. height: 256,
  51. width: 512
  52. }
  53. }
  54. };