Description:
Fix tick marks.
Use the range (rather than the domain) so the ticks are spaced appropriately.
Also sets an arbitrary range if the full range is 0 (if the series is always at
the same value) so that the line actually appears.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
@@ -50,23 +50,23 | |||||
|
50 | .Zip(colors, (first, second) => (first, second)) |
|
50 | .Zip(colors, (first, second) => (first, second)) |
|
51 | .ToDictionary(t => t.Item1, t => t.Item2); |
|
51 | .ToDictionary(t => t.Item1, t => t.Item2); |
|
52 |
|
52 | ||
|
53 | public static void DrawLinearAxis(ImDrawListPtr draw_list, Num.Vector2 range, bool vertical, int points, Num.Vector2 position) { |
|
53 | public static void DrawLinearAxis(ImDrawListPtr draw_list, Num.Vector2 range, bool vertical, int points, Num.Vector2 starting_position) { |
|
54 | //See DrawLinearLabels for explanation |
|
54 | //See DrawLinearLabels for explanation |
|
55 | var tick_spacing = (int)Math.Abs((range.Y - range.X) / (points - 1)); |
|
55 | var tick_spacing = (int)Math.Abs((range.Y - range.X) / (points - 1)); |
|
56 | var tick_length = 5; |
|
56 | var tick_length = 5; |
|
57 | var tick_adjust = vertical ? new Num.Vector2(tick_length, 0) : new Num.Vector2(0, tick_length); |
|
57 | var tick_adjust = vertical ? new Num.Vector2(tick_length, 0) : new Num.Vector2(0, tick_length); |
|
58 |
|
58 | ||
|
59 | var tick_position = position; |
|
59 | var tick_position = starting_position; |
|
60 |
|
60 | ||
|
61 | for(int i = 0; i < points; i++) { |
|
61 | for(int i = 0; i < points; i++) { |
|
62 |
draw_list.AddLine(tick_position, Num.Vector2.Add(tick_position, tick_adjust), (uint)ImGuiColor. |
|
62 | draw_list.AddLine(tick_position, Num.Vector2.Add(tick_position, tick_adjust), (uint)ImGuiColor.DARKGREY, 1.0f); |
|
63 |
|
63 | ||
|
64 | if (vertical) { |
|
64 | if (vertical) { |
|
65 | tick_position = new Num.Vector2(position.X, position.Y + ((i + 1) * tick_spacing)); |
|
65 | tick_position = new Num.Vector2(starting_position.X, starting_position.Y + ((i + 1) * tick_spacing)); |
|
66 | } |
|
66 | } |
|
67 | else { |
|
67 | else { |
|
68 | //We increment one, otherwise the first tick is |
|
68 | //We increment one, otherwise the first tick is |
|
69 | tick_position = new Num.Vector2(position.X + ((i + 1) * tick_spacing), position.Y); |
|
69 | tick_position = new Num.Vector2(starting_position.X + ((i + 1) * tick_spacing), starting_position.Y); |
|
70 | } |
|
70 | } |
|
71 | } |
|
71 | } |
|
72 | } |
|
72 | } |
@@ -209,7 +209,7 | |||||
|
209 | } |
|
209 | } |
|
210 | } |
|
210 | } |
|
211 |
|
211 | ||
|
212 | var domain = new Num.Vector2(domain_min, domain_max); |
|
212 | var domain = (domain_min != domain_max) ? new Num.Vector2(domain_min, domain_max) : new Num.Vector2(domain_min-100, domain_max+100) ; |
|
213 | var range = new Num.Vector2(200 - padding, 0 + padding); |
|
213 | var range = new Num.Vector2(200 - padding, 0 + padding); |
|
214 |
|
214 | ||
|
215 | //Zero |
|
215 | //Zero |
@@ -239,7 +239,7 | |||||
|
239 | } |
|
239 | } |
|
240 | } |
|
240 | } |
|
241 |
|
241 | ||
|
242 |
DrawLinearAxis(draw_list, |
|
242 | DrawLinearAxis(draw_list, range /*new Num.Vector2(0, 200)*/, true, 11, Num.Vector2.Add(c, new Num.Vector2(padding, padding))); |
|
243 | DrawLinearLabels(font, draw_list, domain, range /*new Num.Vector2(0, 200)*/, true, 11, c); |
|
243 | DrawLinearLabels(font, draw_list, domain, range /*new Num.Vector2(0, 200)*/, true, 11, c); |
|
244 | DrawLinearAxis(draw_list, new Num.Vector2(0, 350), false, 12, Num.Vector2.Add(c, new Num.Vector2(padding, 200 - padding))); |
|
244 | DrawLinearAxis(draw_list, new Num.Vector2(0, 350), false, 12, Num.Vector2.Add(c, new Num.Vector2(padding, 200 - padding))); |
|
245 |
|
245 |
You need to be logged in to leave comments.
Login now