JohnUUU / code.pyret.org

Website for serving Pyret to folks.
Other
0 stars 0 forks source link

Axes sometimes exclude interval values #12

Open eyanje opened 3 years ago

eyanje commented 3 years ago

In stacked bar charts, intervals can be drawn out of bounds of the calculated axes, which makes them not visible in the interactive chart:

include chart
import lists as L

example-data = from-list.stacked-bar-chart(
  [list: "Year 1"],
  [list: [list: 100, 10]],
  [list: "A", "B"])
intervals = [list: [list: [list: ], [list: -12, 50]]]

with-intervals = example-data.intervals(intervals)

rendered-chart = render-chart(with-intervals)
rendered-chart.display()

Interactive chart: image Final render (using getImageURI): image

Typically, the axis bounds are determined in stacked bar charts by adding up the positive and the negative values in each column of the data table, then using the largest and smallest sums to compute bounds that include all of the data. Intervals are part of the table, but they don't stack the same way, so our method of adding up values in a column won't account for them.