charts: changed scientifc number display from e+6 type to pango markup
authorFriedrich Beckmann <friedrich.beckmann@gmx.de>
Thu, 4 Jun 2015 05:35:00 +0000 (07:35 +0200)
committerFriedrich Beckmann <friedrich.beckmann@gmx.de>
Thu, 11 Jun 2015 12:17:35 +0000 (14:17 +0200)
src/math/chart-geometry.c
src/output/cairo-chart.c
tests/math/chart-geometry.at
tests/math/chart-get-ticks-format-test.c

index 26268fd2f32c89032ebb4b5673cc21032b7dfbf5..49b1ed6a8d243341d768e9d9b0695f4a2804de8f 100644 (file)
@@ -167,7 +167,7 @@ chart_get_scale (double highdbl, double lowdbl,
  * Non Scientific: "%.3lf", scale=1.00
  * Scientific:     "%.2lfe3", scale = 0.001
  * Usage example:
- *   fs = chart_get_ticks_format(95359943.3,34434.9,8,&scale,&long);
+ *   fs = chart_get_ticks_format(95359943.3,34434.9,8,&scale);
  *   printf(fs,value*scale);
  *   free(fs);
  */
@@ -191,7 +191,7 @@ chart_get_ticks_format (const double max, const double min,
     }
   else if (logmax > 0.0) /*logintv is > 0*/
     {
-      if (logintv < 3.0)
+      if (logintv < 5.0)
        {
          logshift = 0; /* No scientific format */
          nrdecs = 0;
@@ -201,12 +201,12 @@ chart_get_ticks_format (const double max, const double min,
        {
          logshift = (int)logmax;
          nrdecs = MIN(6,(int)(logmax-logintv)+1);
-         format_string = xasprintf("%%.%dlfe%d",nrdecs,logshift);
+         format_string = xasprintf("%%.%dlf&#8729;10<sup>%d</sup>",nrdecs,logshift);
        }
     }
   else /* logmax and logintv are < 0 */
     {
-      if (logmax > -3.0)
+      if (logmax > -4.0)
        {
          logshift = 0; /* No scientific format */
          nrdecs = (int)(-logintv) + 1;
@@ -216,7 +216,7 @@ chart_get_ticks_format (const double max, const double min,
        {
          logshift = (int)logmax-1;
          nrdecs = MIN(6,(int)(logmax-logintv)+1);
-         format_string = xasprintf("%%.%dlfe%d",nrdecs,logshift);
+         format_string = xasprintf("%%.%dlf&#8729;10<sup>%d</sup>",nrdecs,logshift);
        }
     }
   *scale = pow(10.0,-(double)logshift);
index fbb1d77c1de75abb23f46a86e66b51a2c4a2c6d9..e0591723b7df0663dbb670b0b4dfd93795311fc8 100644 (file)
@@ -196,7 +196,7 @@ xrchart_label_rotate (cairo_t *cr, int horz_justify, int vert_justify,
 
   layout = pango_cairo_create_layout (cr);
   pango_layout_set_font_description (layout, desc);
-  pango_layout_set_text (layout, string, -1);
+  pango_layout_set_markup (layout, string, -1);
   if (horz_justify != 'l')
     {
       int width_pango;
@@ -586,7 +586,7 @@ xrchart_text_extents (cairo_t *cr, const struct xrchart_geometry *geom,
   pango_font_description_set_absolute_size (desc, geom->font_size * PANGO_SCALE);
   layout = pango_cairo_create_layout (cr);
   pango_layout_set_font_description (layout, desc);
-  pango_layout_set_text (layout, utf8, -1);
+  pango_layout_set_markup (layout, utf8, -1);
   pango_layout_get_size (layout, &width_pango, &height_pango);
   *width = (double) width_pango / PANGO_SCALE;
   *height = (double) height_pango / PANGO_SCALE;
index e15560b69dbe9d09721bdb0408d948b78429f3e6..96bf02db736952bac2b61c7f717121e65120cc88 100644 (file)
@@ -40,23 +40,27 @@ AT_SETUP([Chart Ticks Format])
 AT_CHECK([../../math/chart-get-ticks-format-test], [0], [dnl
 max: 1000, min: 10, nticks: 10, fs: %.0lf, scale: 1, example: 505
 max: 10000, min: 10, nticks: 10, fs: %.0lf, scale: 1, example: 5005
-max: 100000, min: 10, nticks: 10, fs: %.2lfe5, scale: 1e-05, example: 0.50e5
-max: 1e+06, min: 10, nticks: 10, fs: %.2lfe6, scale: 1e-06, example: 0.50e6
-max: 1e+07, min: 10, nticks: 10, fs: %.2lfe7, scale: 1e-07, example: 0.50e7
-max: 1e+08, min: 10, nticks: 10, fs: %.2lfe8, scale: 1e-08, example: 0.50e8
+max: 100000, min: 10, nticks: 10, fs: %.0lf, scale: 1, example: 50005
+max: 1e+06, min: 10, nticks: 10, fs: %.0lf, scale: 1, example: 500005
+max: 1e+07, min: 10, nticks: 10, fs: %.2lf&#8729;10<sup>7</sup>, scale: 1e-07, example: 0.50&#8729;10<sup>7</sup>
+max: 1e+08, min: 10, nticks: 10, fs: %.2lf&#8729;10<sup>8</sup>, scale: 1e-08, example: 0.50&#8729;10<sup>8</sup>
 max: 0.1, min: 0.01, nticks: 10, fs: %.3lf, scale: 1, example: 0.055
-max: 1e-05, min: 1e-06, nticks: 10, fs: %.2lfe-6, scale: 1e+06, example: 5.50e-6
-max: 1.00001e-05, min: 1e-05, nticks: 10, fs: %.6lfe-5, scale: 100000, example: 1.000005e-5
+max: 0.01, min: 0.001, nticks: 10, fs: %.4lf, scale: 1, example: 0.0055
+max: 0.001, min: 0.0001, nticks: 10, fs: %.5lf, scale: 1, example: 0.00055
+max: 0.0001, min: 1e-05, nticks: 10, fs: %.2lf&#8729;10<sup>-5</sup>, scale: 100000, example: 5.50&#8729;10<sup>-5</sup>
+max: 1e-05, min: 1e-07, nticks: 10, fs: %.2lf&#8729;10<sup>-6</sup>, scale: 1e+06, example: 5.05&#8729;10<sup>-6</sup>
+max: 1e-07, min: 1e-08, nticks: 10, fs: %.2lf&#8729;10<sup>-8</sup>, scale: 1e+08, example: 5.50&#8729;10<sup>-8</sup>
+max: 1.00001e-05, min: 1e-05, nticks: 10, fs: %.6lf&#8729;10<sup>-5</sup>, scale: 100000, example: 1.000005&#8729;10<sup>-5</sup>
 max: 1e+08, min: 1e+08, nticks: 10, fs: %.0lf, scale: 1, example: 100000005
-max: 100000, min: -500000, nticks: 10, fs: %.1lfe5, scale: 1e-05, example: -2.0e5
+max: 100000, min: -500000, nticks: 10, fs: %.0lf, scale: 1, example: -200000
 max: 5, min: -5, nticks: 10, fs: %.0lf, scale: 1, example: 0
 max: 5, min: -4.999, nticks: 10, fs: %.1lf, scale: 1, example: 0.0
 max: 5, min: -4.999, nticks: 9, fs: %.0lf, scale: 1, example: 0
 max: 5, min: 0, nticks: 10, fs: %.1lf, scale: 1, example: 2.5
 max: 0, min: -5, nticks: 9, fs: %.1lf, scale: 1, example: -2.5
-max: 1.001e-95, min: 1e-95, nticks: 10, fs: %.5lfe-95, scale: 1e+95, example: 1.00050e-95
-max: 1.001e+98, min: 1e+98, nticks: 10, fs: %.5lfe98, scale: 1e-98, example: 1.00050e98
-max: 1.001e+33, min: 1e-22, nticks: 10, fs: %.2lfe33, scale: 1e-33, example: 0.50e33
+max: 1.001e-95, min: 1e-95, nticks: 10, fs: %.5lf&#8729;10<sup>-95</sup>, scale: 1e+95, example: 1.00050&#8729;10<sup>-95</sup>
+max: 1.001e+98, min: 1e+98, nticks: 10, fs: %.5lf&#8729;10<sup>98</sup>, scale: 1e-98, example: 1.00050&#8729;10<sup>98</sup>
+max: 1.001e+33, min: 1e-22, nticks: 10, fs: %.2lf&#8729;10<sup>33</sup>, scale: 1e-33, example: 0.50&#8729;10<sup>33</sup>
 ])
 
 AT_CLEANUP
index a1b155e329933a548b46fefb056f1f8e628f1fc5..6dcab5077462ca2aa95ae729f4064bb59837921f 100644 (file)
@@ -34,7 +34,11 @@ struct range tv[] = {
   {   10000000.0,            10.0,     10},
   {  100000000.0,            10.0,     10},
   {          0.1,            0.01,     10},
-  {      0.00001,        0.000001,     10},
+  {         0.01,           0.001,     10},
+  {        0.001,          0.0001,     10},
+  {       0.0001,         0.00001,     10},
+  {      0.00001,       0.0000001,     10},
+  {    0.0000001,      0.00000001,     10},
   { 0.0000100001,         0.00001,     10},
   {  100000010.0,     100000000.0,     10},
   {     100000.0,       -500000.0,     10},