Home > Enterprise >  Livecharts showing "-100000000000000 μ" instead of -100 M in a StackedColumnSeries
Livecharts showing "-100000000000000 μ" instead of -100 M in a StackedColumnSeries

Time:11-19

When a value of -1e8 is added to a StackedColumnSeries in a SKCartesianChart, the value is labelled with -100000000000000 μ instead of -100 M as expected.

I suspect this is a bug in the prerelease version of livecharts. I've enter image description here

CodePudding user response:

Thanks for the report on Github, this is a bug, it is already fixed, and this fix fill be included in the next version of the library.

For now, you can build your own formatter in the YAxis:

var chart = new SKCartesianChart
{
  Series = new List<ISeries>
  {
    new StackedColumnSeries<decimal> {Values = new [] {1e8m}},
    new StackedColumnSeries<decimal> {Values = new [] {-1e8m}}
  },
  YAxes = new[]
  {
    new Axis
    {
      Labeler = value =>
      {
        var l = value == 0 ? 0 : (int)Math.Log10(Math.Abs(value));

        if (l >= 6)
        {
          value /= Math.Pow(10, 6);
          return value.ToString($"######0.####### M");
        }

        return value.ToString($"######0.#######");
      }
    }
  }
};
  • Related