Profile Picture

Get rid of label for specific datapoint

Posted By Torsten Tiedt 9 Years Ago
Author
Message
Torsten Tiedt
Question Posted 9 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)

Group: Forum Members
Last Active: 9 Years Ago
Posts: 1, Visits: 6
Hi,

in your help section "Controlling the labels visibility" you show how to hide specific labels. Unfortunately, I can't get it work. I want the first datapoint to have no label.

Here is my code (watch for 2 comments).

Thanks for your help!

=======================


var chart = new NCartesianChart();

NDateTimeScaleConfigurator dateTimeScale = new NDateTimeScaleConfigurator();
dateTimeScale.MajorTickMode = MajorTickMode.CustomStep;
dateTimeScale.CustomStep = new NDateTimeSpan(1, NDateTimeUnit.Year);
dateTimeScale.EnableUnitSensitiveFormatting = false;
dateTimeScale.LabelValueFormatter = new NDateTimeValueFormatter("yyyy");
chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = dateTimeScale;

NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar);

bar.UseXValues = true;

var dataPoint = new NDataPoint(new DateTime(1999, 1, 1).ToOADate(), 0);

bar.AddDataPoint(dataPoint); // this point shall have no label

bar.AddDataPoint(new NDataPoint(new DateTime(2000,1,1).ToOADate(), 1, "2000 / 1"));
bar.AddDataPoint(new NDataPoint(new DateTime(2001, 1, 1).ToOADate(), 2, "2011 / 2"));
bar.AddDataPoint(new NDataPoint(new DateTime(2002, 1, 1).ToOADate(), 5, "2011 / 2"));
bar.AddDataPoint(new NDataPoint(new DateTime(2003, 1, 1).ToOADate(), 4, "2011 / 2"));

NDataLabelStyle dataLabel = new NDataLabelStyle();
dataLabel.Visible = true;
dataLabel.Format = "";

bar.DataLabelStyle.Visible = false;
bar.DataLabelStyles[0] = dataLabel; // trying to get rid of label for point at index 0

this.ChartControl.Charts.Clear();
this.ChartControl.Charts.Add(chart);

NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.NevronMultiColor);
styleSheet.Apply(this.ChartControl.Document);

this.ChartControl.Refresh();



Nevron Support
Posted 9 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 3,039, Visits: 3,746
Hi Torsten,
Most likely you end up with no data labels given the code below. You simply need to assign non visible data label style to the first data point. You should not turn off labeling for all data points if you wish to hide the first one only. The following code snippet shows how to achieve that:

   NChart chart = nChartControl1.Charts[0];
   NBarSeries bar = new NBarSeries();
   chart.Series.Add(bar);
         
   var dataPoint = new NDataPoint(new DateTime(1999, 1, 1).ToOADate(), 0);
  
   bar.AddDataPoint(dataPoint); // this point shall have no label
   bar.AddDataPoint(new NDataPoint(new DateTime(2000,1,1).ToOADate(), 1, "2000 / 1"));
   bar.AddDataPoint(new NDataPoint(new DateTime(2001, 1, 1).ToOADate(), 2, "2011 / 2"));
   bar.AddDataPoint(new NDataPoint(new DateTime(2002, 1, 1).ToOADate(), 5, "2011 / 2"));
   bar.AddDataPoint(new NDataPoint(new DateTime(2003, 1, 1).ToOADate(), 4, "2011 / 2"));

   
   NDataLabelStyle dataLabel = new NDataLabelStyle();

   dataLabel.Visible = false;

   bar.DataLabelStyles[0] = dataLabel; // trying to get rid of label for point at index 0

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




Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic