Pie Chart - Label Mode


Author
Message
Jerry Jacob
Jerry Jacob
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: 15, Visits: 78
This may be a silly question but how do I get a NChartControl in to the chart? I can't seem to find it.

Thanks!
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 Jerry,
One solution would be to use anchor panels for the labels that you wish to exclude from automatic layout. The following code snippet shows how to achieve this:

   nChartControl1.Panels.Clear();

   NPieChart pieChart = new NPieChart();

   nChartControl1.Panels.Add(pieChart);

   NPieSeries pieSeries = new NPieSeries();
   pieChart.Series.Add(pieSeries);

   pieSeries.Values.Add(10);
   pieSeries.Values.Add(10);
   pieSeries.Values.Add(10);
   pieSeries.LabelMode = PieLabelMode.SpiderNoOverlap;

   pieSeries.Labels.Add("One");
   pieSeries.Labels.Add("");
   NDataLabelStyle dls = new NDataLabelStyle();
   dls.Visible = false;
   pieSeries.DataLabelStyles[1] = dls;
   pieSeries.Labels.Add("Three");

   NLabel label = new NLabel("Two");
   label.ContentAlignment = ContentAlignment.MiddleCenter;
   label.TextStyle = (NTextStyle)dls.TextStyle.Clone();
   NAnchorPanel anchorPanel = new NAnchorPanel();
   anchorPanel.ChildPanels.Add(label);
   anchorPanel.Anchor = new NPieDataPointAnchor(pieSeries, 1, 1, StringAlignment.Center);

   nChartControl1.Panels.Add(anchorPanel);

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


Best Regards,
Nevron Support Team


Jerry Jacob
Jerry Jacob
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: 15, Visits: 78
I tried different ranges of numbers, however for my current situation I am trying to make the lines smaller which does not seem to be working.

The problem stems from not being able to switch the Label mode, because if I use center, there are some pie pieces that are too small for the text, and if i use spider then the chart shrinks to allow the words to appear on the side and then the chart is too small.

Do you have any suggestions on how to try to get around this so that it can work out?  I was considering trying to make a whole new pie series for each piece so that way theoretically they would have independent labelmodes.  Would that work?  If so, what would be the best way to do that.  I figured if there was a way to get the percentage of each block, then basically transform each pie piece to its own series with that percentage as the max for the pie and let it consume the whole thing.



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 Jerry,

Probably you started experimenting with zero value - that's why you don't see a difference - try to insert larger values - like 10, 12, 15... etc.


Best Regards,
Nevron Support Team


Jerry Jacob
Jerry Jacob
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: 15, Visits: 78
I have tried

      pieSeries.LabelMode = PieLabelMode.SpiderNoOverlap;
       pieSeries.LeadOffArrowLength = new NLength(0.25f);
       pieSeries.ConnectorLength = new NLength(0.25f);

And changed the length to be different numbers but I haven't noticed any change in the size of the line.
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 Jerry,

You can control the length of the connectors using the LeadOffArrowLength and ConnectorLength properties of the pie series (the lines that connect pie sectors with their data labels consist of several parts). As for the labels - all labels in the pie use the same style so there is no way to mix them. Hope this helps let us know if you meet any problems or have any questions.

Best Regards,
Nevron Support Team


Jerry Jacob
Jerry Jacob
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: 15, Visits: 78
Is there a way to change the labelmode based on the data?

Something along the lines of

     
if (pieSeries.Values[i] > .1){
        //I want to change the labelMode of this value to Center on the pie chart
        pieSeries.LabelMode = PieLabelMode.Center;
       }else {
        //I want to change the labelMode of this value to SpiderNoOverlap on the pie chart
        pieSeries.LabelMode = PieLabelMode.SpiderNoOverlap;
       }


Also how can I adjust the lengths of the lines for SpiderNoOverlap.  I tried the following without success.

      pieSeries.DataLabelStyle.ArrowLength = new NLength(1.0f,NRelativeUnit.ParentPercentage);
      pieSeries.DataLabelStyle.ArrowPointerLength = new NLength(1.0f,NRelativeUnit.ParentPercentage);




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