+ Some locales (such as German) prefer the centered dot rather than the
+ multiplication sign between the mantissa an exponent. In which
+ case, you can change "#215;" to "#8901;" or other unicode code
+ point as appropriate.
+
+ The . in this string does not and should not be changed, since
+ that is taken care of by the stdc library.
+
+ For information on Pango markup, see
+ http://developer.gnome.org/pango/stable/PangoMarkupFormat.html
+
+ For tables of unicode code points, see http://unicode.org/charts
+ */
+ return xasprintf(_("%%.%dlf×10<sup>%d</sup>"), n_decimals, exponent);
+}
+
+/*
+ * Compute the optimum format string and the scaling
+ * for the tick drawing on a chart axis
+ * Input: lower: the lowest tick
+ * interval:the interval between the ticks
+ * nticks: the number of tick intervals (bins) on the axis
+ * Return: fs: format string for printf to print the tick value
+ * scale: scaling factor for the tick value
+ * The format string has to be freed after usage.
+ * An example format string and scalefactor:
+ * Non Scientific: "%.3lf", scale=1.00
+ * Scientific: "%.2lfe3", scale = 0.001
+ * Usage example:
+ * fs = chart_get_ticks_format(-0.7,0.1,8,&scale);
+ * printf(fs,value*scale);
+ * free(fs);
+ */
+char *
+chart_get_ticks_format (const double lower, const double interval,
+ const unsigned int nticks, double *scale)
+{
+ double logmax = log10(fmax(fabs(lower + (nticks+1)*interval),fabs(lower)));
+ double logintv = log10(interval);
+ int logshift = 0;
+ char *format_string = NULL;
+ int nrdecs = 0;
+
+ if (logmax > 0.0 && logintv < 0.0)
+ {
+ nrdecs = MIN(6,(int)(ceil(fabs(logintv))));
+ logshift = 0;
+ if (logmax < 12.0)
+ format_string = xasprintf("%%.%dlf",nrdecs);
+ else
+ format_string = xasprintf("%%lg");
+ }
+ else if (logmax > 0.0) /*logintv is > 0*/
+ {
+ if (logintv < 5.0 && logmax < 10.0)
+ {
+ logshift = 0; /* No scientific format */
+ nrdecs = 0;
+ format_string = xstrdup("%.0lf");
+ }
+ else