Profile Picture

Is a varied format possible?

Posted By inhyuk son 14 Years Ago
Author
Message
inhyuk son
Posted 14 Years Ago
View Quick Profile
Junior Member

Junior Member (21 reputation)Junior Member (21 reputation)Junior Member (21 reputation)Junior Member (21 reputation)Junior Member (21 reputation)Junior Member (21 reputation)Junior Member (21 reputation)Junior Member (21 reputation)Junior Member (21 reputation)

Group: Forum Members
Last Active: 12 Years Ago
Posts: 21, Visits: 1
Hi~
I want to set a varied format to a axis.
For example, A axis has labels, 600K, 800K, 1,000K
I want to use 1M instead of 1,000K.
Is it possible?
Thanks~

Attachments
chart.bmp (45 views, 232.00 KB)
bob milanov
Posted 14 Years Ago
View Quick Profile
Supreme Being

Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)

Group: Forum Members
Last Active: 6 Months Ago
Posts: 153, Visits: 11

Hi Inhyuk,

You can use a custom value formatter for this purpose - for example:

public class NCustomValueFormatter : NValueFormatter
{
  public override string FormatValue(object value)
  {
    double dValue = (double)value;
    double millions = dValue / 1000000;
    if (millions > 1)
    {
      return ((int)millions).ToString() + "M";
    }
    double thousands = dValue / 1000;
    return ((int)thousands).ToString() + "K";
  }
}

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

  NBarSeries bar = new NBarSeries();
  bar.Values.Add(1200000);
  bar.Values.Add(1100000);
  bar.Values.Add(1000000);
  chart.Series.Add(bar);

  NLinearScaleConfigurator scale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator;
  scale.LabelValueFormatter = new NCustomValueFormatter();
  nChartControl1.Refresh ();
}

Let me know if you meet any problems.

Best regards,
Bob





Similar Topics


Reading This Topic