You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

stacked_and_mixed.md 1.3 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. ## Adding more datasets
  2. As we have seen, chart can have [multiple datasets](). In an axis chart, every dataset is represented individually.
  3. ```js
  4. data: {
  5. labels: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
  6. datasets: [
  7. { name: "Dataset 1", values: [18, 40, 30, 35, 8, 52, 17, -4] },
  8. { name: "Dataset 2", values: [30, 50, -10, 15, 18, 32, 27, 14] }
  9. ]
  10. }
  11. ```
  12. <div class="demo" id="multi-dataset-line-bar"></div>
  13. ## Stacked Bar Chart
  14. Bars have two ways to show multiple data point values. The property [`stacked`]() in `barOptions` renders a stacked bar chart instead of the default adjacent bars:
  15. ```js
  16. barOptions: {
  17. stacked: 1 // default 0
  18. }
  19. ```
  20. [stacked/adjacent]
  21. ## Mixed Bar/Line Chart
  22. Each dataset can also have a different `chartType`, which if specified, will take precedence over the `type` property.
  23. ```js
  24. data: {
  25. labels: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
  26. datasets: [
  27. { name: "Dataset 1", values: [18, 40, 30, 35, 8, 52, 17, -4] },
  28. { name: "Dataset 2", values: [30, 50, -10, 15, 18, 32, 27, 14] }
  29. ]
  30. }
  31. ```
  32. All the `lineOptions` and `barOptions` apply to mix and match datasets as well.
  33. [mix and match demo, no buttons]
  34. In [Aggregation Charts]() however, instead of being rendered individually, each data point in aggregated accross every dataset. We'll cover those next.