ngrapher
  • Overview
  • Repository
  • Tickets
  • Statistics
  • Projects

Repository

Display scalings

Parent commits : 48a7f89e69fda470fbb3d6bb141482f5f7a216ee,
Children commits : ac21fd7b49517f8fdc8fb3573f87d2bd5de7de56,

By Laurent Defert on 2013-02-24 18:41:01
Display scalings

Browse content
Difference with parent commit 48a7f89e69fda470fbb3d6bb141482f5f7a216ee
Files modified:
ngrapher.c
--- 
+++ 
@@ -81,9 +81,33 @@
 
 	/* Draw Y axis scalings */
 	scaling_val = log10(max_value - min_value);
-	scaling_val = exp10(roundl(scaling_val));
-
-	mvprintw(0, 0, "scaling %.2f", scaling_val);
+	scaling_val = exp10(roundl(scaling_val) - 1.0);
+
+	/* Negatives scalings */
+	i = 0;
+	while(1)
+	{
+		double scaling = (double)i * (-scaling_val);
+		int h = (int) ((scaling/(max_value - min_value)) * graph_height);
+		if(scaling < min_value)
+			break;
+		mvprintw(x_axis_top-h, 0, "%.1f", scaling);
+		i++;
+	}
+
+	/* Positives scalings */
+	i = 0;
+	while(1)
+	{
+		double scaling = (double)i * scaling_val;
+		int h = (int) ((scaling/(max_value - min_value)) * graph_height);
+		if(scaling > max_value)
+			break;
+		mvprintw(x_axis_top-h, 0, "%.1f", scaling);
+		i++;
+	}
+
+	mvprintw(0, 0, "%.2f", scaling_val);
 
 	/* Draw curves */
 	for (i = 0; i < lines_count; ++i)
@@ -98,7 +122,7 @@
 		{
 			if(window_x + j < 0)
 				continue;
-	
+
 			int x = graph_left + j;
 			int h = (int) ((values[i][window_x + j]/(max_value - min_value)) * graph_height);
 			mvaddch(x_axis_top-h, x, (chtype)('a' + i));

Generated with KisssPM