Nevron Forum

Format numbers

https://www.nevron.com/Forum/Topic7754.aspx

By Luis Miguel Perez Lopez - Tuesday, May 14, 2013

I have the following code:

Dim axisY As NAxis = Chart.Axis(StandardAxis.PrimaryY)
Dim lsc As NLinearScaleConfigurator = CType(axisY.ScaleConfigurator, NLinearScaleConfigurator)

lsc.LabelValueFormatter = New NNumericValueFormatter("#,###,##0.###########")

Chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = lsc

What I want is put the numbers with blanc spaces instead of "comas". I tried this but it doesn't work:

lsc.LabelValueFormatter = New NNumericValueFormatter("# ### ##0.###########")

Is there any solution for that issue ????
By Nevron Support - Tuesday, May 14, 2013

Hi Luis,

You can solve this problem by creating a custom value formatter - for example:

      class CustomValueFormatter : NValueFormatter
      {
         public override string FormatValue(double value)
         {
            return value.ToString("#,###,##0.###########").Replace(",", " ");      
         }

         public override string FormatValue(object value)
         {
            return FormatValue((double)value);
         }
      }

      private void Form1_Load(object sender, EventArgs e)
      {
         NChart chart = nChartControl1.Charts[0];

         NLinearScaleConfigurator scale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator;
         scale.LabelValueFormatter = new CustomValueFormatter();

         NBarSeries bar = new NBarSeries();
         bar.DataLabelStyle.Visible = false;

         DateTime now = DateTime.Now;

         for (int i = 0; i < 100; i++)
         {
            bar.Values.Add(i * i);
         }

         chart.Series.Add(bar);
      }


Let us know if you meet any problems.

By Luis Miguel Perez Lopez - Wednesday, May 15, 2013

It works

Thanks