-
Notifications
You must be signed in to change notification settings - Fork 11
Description
Background
As soon as #27 is merged, we'll have a simple working line plot available to use! However, we would like programmers to be able to decide the scale for themselves (for example, whether every "x" should represent one, two, five, and so on).
Goal
Modify the line_plot helper to take an additional configuration argument that states the scale. Assume that it will be formatted like this -
{
scale: 5 # Every "x" equals five of something
}If the user doesn't specify a scale, then use use some math to determine the scale yourself. Here's the code that does that -
val_per_x = (largest_value.to_f / 10).ceil()
data.each do |object|
object[:length] = object[:value].to_f / val_per_x
endHowever, this isn't ideal because a line plot should be discrete. If you use this math, some marks will need to be fractional. To get around this, it would be ideal to just scale the "x" marks down. For example, if you need every "x" to be worth two, just scale the mark down by half and keep them worth at one. This way...
- You won't have fractional marks (which will be difficult to render and confusing for the user), and
- You will still be able to fit all the data onto the plot
Good luck!