Profile Picture

Split DateTime label line

Posted By rich dudley 7 Years Ago
Author
Message
rich dudley
Question Posted 7 Years Ago
View Quick Profile
Forum Guru

Forum Guru (51 reputation)Forum Guru (51 reputation)Forum Guru (51 reputation)Forum Guru (51 reputation)Forum Guru (51 reputation)Forum Guru (51 reputation)Forum Guru (51 reputation)Forum Guru (51 reputation)Forum Guru (51 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 33, Visits: 76
https://www.nevron.com/forum/uploads/images/341904d0-247e-4dd5-8187-e2e2.jpg
How do I split the label row so its Q3 on the first row and 16 below it? If I need to just define a string for each label with a <br/> in it, how do I link it to the data?


Nevron Support
This post has been flagged as an answer
Posted 7 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Today @ 1:54 AM
Posts: 3,054, Visits: 4,009
Hi Rich,
Please provide more information on how you configure the chart - whether this is a categorical or date time scale, code used to configure the control etc. In the case of a categorical scale you can switch the labels to XML formatted text and insert <br/> like you mentioned:

   NChart chart = nChartControl1.Charts[0];

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

   bar.Values.Add(10);
   bar.Values.Add(20);

   chart.Series.Add(bar);

   NOrdinalScaleConfigurator ordinalScale = (NOrdinalScaleConfigurator)chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator;

   ordinalScale.LabelStyle.TextStyle.TextFormat = TextFormat.XML;
   ordinalScale.AutoLabels = false;

   ordinalScale.Labels.Add("Q3<br/>2017");
   ordinalScale.Labels.Add("Q4<br/>2017");

For date time axes the code is similar:

   NChart chart = nChartControl1.Charts[0];

   NLineSeries line = new NLineSeries();
   line.DataLabelStyle.Visible = false;
   line.UseXValues = true;

   Random rand = new Random();
   DateTime dt = DateTime.Now;

   for (int i = 0; i < 10; i++)
   {
    line.Values.Add(10);
    line.XValues.Add(dt.ToOADate());
    dt = dt.AddMonths(3);
   }

   chart.Series.Add(line);

   NDateTimeScaleConfigurator dateTimeScale = new NDateTimeScaleConfigurator();
   dateTimeScale.LabelStyle.TextStyle.TextFormat = TextFormat.XML;
   dateTimeScale.LabelValueFormatter = new NDateTimeValueFormatter("#Q<br/>yy");
   chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = dateTimeScale;

   dateTimeScale.MajorTickMode = MajorTickMode.CustomStep;
   dateTimeScale.EnableUnitSensitiveFormatting = false;
   dateTimeScale.CustomStep = new NDateTimeSpan(3, NDateTimeUnit.Month);


Hope this helps - let us know if you meet any problems or have any questions.


Best Regards,
Nevron Support Team



rich dudley
Posted 7 Years Ago
View Quick Profile
Forum Guru

Forum Guru (51 reputation)Forum Guru (51 reputation)Forum Guru (51 reputation)Forum Guru (51 reputation)Forum Guru (51 reputation)Forum Guru (51 reputation)Forum Guru (51 reputation)Forum Guru (51 reputation)Forum Guru (51 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 33, Visits: 76
I am using a DateTimeScale. adding the br to the value formatter is exactly what I needed. Is there a way to use a datetimescale without resetting the scale configurator with new NDateTimeScaleConfigurator() to keep any already defined settings?

List<NDateTimeUnit> dateTimeUnits = new List<NDateTimeUnit>();
dateTimeUnits.Add(NDateTimeUnit.Quarter);
dateTimeUnits.Add(NDateTimeUnit.Year);

chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = new NDateTimeScaleConfigurator();
NDateTimeScaleConfigurator scale = (NDateTimeScaleConfigurator)chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator;
scale.LabelStyle.ContentAlignment = ContentAlignment.MiddleLeft;
scale.EnableUnitSensitiveFormatting = false;
scale.LabelValueFormatter = new NDateTimeValueFormatter("#Q yy");
scale.AutoDateTimeUnits = dateTimeUnits.ToArray();

line.UseXValues = true;

try
{
  foreach (DataRow row in RLChartData.Rows)
  {
   DateTime date = Convert.ToDateTime(row[valueColumnName[1]].ToString());
   double value = Convert.ToDouble(row[valueColumnName[0]]);
   line.XValues.Add(date);
   line.Values.Add(value);
  }
}
catch (System.Exception e) { }

Nevron Support
Posted 7 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Today @ 1:54 AM
Posts: 3,054, Visits: 4,009

Hi Rich,
Yes you just need to add the following:

scale.LabelStyle.TextStyle.TextFormat = TextFormat.XML;
scale.LabelValueFormatter = new NDateTimeValueFormatter("#Q<br/>yy");

and it should be working.



Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic