data_order.js 1006 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. var chart = c3.generate({
  2. data: {
  3. columns: [
  4. ['data1', 130, 200, 320, 400, 530, 750],
  5. ['data2', -130, 10, 130, 200, 150, 250],
  6. ['data3', -130, -50, -10, -200, -250, -150]
  7. ],
  8. type: 'bar',
  9. groups: [
  10. ['data1', 'data2', 'data3']
  11. ],
  12. order: 'desc' // stack order by sum of values descendantly. this is default.
  13. // order: 'asc' // stack order by sum of values ascendantly.
  14. // order: null // stack order by data definition.
  15. },
  16. grid: {
  17. y: {
  18. lines: [{value:0}]
  19. }
  20. }
  21. });
  22. setTimeout(function () {
  23. chart.load({
  24. columns: [
  25. ['data4', 1200, 1300, 1450, 1600, 1520, 1820],
  26. ]
  27. });
  28. }, 1000);
  29. setTimeout(function () {
  30. chart.load({
  31. columns: [
  32. ['data5', 200, 300, 450, 600, 520, 820],
  33. ]
  34. });
  35. }, 2000);
  36. setTimeout(function () {
  37. chart.groups([['data1', 'data2', 'data3', 'data4', 'data5']])
  38. }, 3000);