anchor-scriptable.js 599 B

12345678910111213141516171819202122232425262728293031323334353637
  1. export default {
  2. config: {
  3. type: 'bar',
  4. data: {
  5. labels: [0, 1, 2, 3, 4],
  6. datasets: [{
  7. data: [-1, 1, 2, 1, -2],
  8. datalabels: {
  9. backgroundColor: '#00ff77'
  10. }
  11. }]
  12. },
  13. options: {
  14. plugins: {
  15. datalabels: {
  16. anchor: function(context) {
  17. var data = context.dataset.data[context.dataIndex];
  18. return data > 1 ? 'start' : data < -1 ? 'end' : 'center';
  19. },
  20. borderColor: 'black',
  21. borderWidth: 2,
  22. font: {
  23. size: 0
  24. },
  25. offset: 0,
  26. padding: 8
  27. }
  28. }
  29. }
  30. },
  31. options: {
  32. canvas: {
  33. height: 256,
  34. width: 256
  35. }
  36. }
  37. };