Get rid of label for specific datapoint


Author
Message
Torsten Tiedt
Torsten Tiedt
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
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
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K
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


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search