New Legend.PaletteLegendMode and associated functionality in 15.1


https://www.nevron.com/Forum/Topic9028.aspx
Print Topic | Close Window

By Kevin Harrison - 9 Years Ago
Hi,

Thanks for adding this new feature.

I allow users to change the legend position from a shortcut menu on the chart. If they change, say, from right to top, the PaletteOrientation doesn't change automatically like a standard legend does.

I achieve the legend position change by having separate chart and legend panels and reorganising them. I could switch the PaletteOrientation myself but I cannot see how to get from the Chart Legend (NLegend chartLegend) to the elements on it to achieve this (as they were added using chart.DisplayOnLegend = chartLegend). Is there a way to do this?

Thanks

Kevin

PS there is a typo in the property NAutoLegend.PaleteScalePosition (missing t)
By Nevron Support - 9 Years Ago
Hi Kevin,

For an automatic legend you need to touch the palette orientation property of the NSeriesLegend for example:

someSeries.Legend.PaletteOrientation = PaletteOrientation.Horizontal;

Let us know if you meet any problems or have any questions.

Thanks for the typo tip Smile...
By Kevin Harrison - 9 Years Ago
Thanks for the reply but you didn't answer my question. I know how to change the PaletteOrientation for a series Legend, but I asked if there was any way to get to the series legends from the chart legend.

Thanks

Kevin
By Nevron Support - 9 Years Ago
Hi Kevin,

Currently there is no way to get the series that display on a legend, however you can easily loop through the chart/series in the control and check which ones display on that particular legend:

   List<NSeriesBase> seriesOnLegend = new List<NSeriesBase>();

   for (int i = 0; i < nChartControl1.Charts.Count; i++)
   {
    NChart chart = nChartControl1.Charts[i];

    for (int j = 0; j < chart.Series.Count; j++)
    {
     NSeriesBase series = chart.Series[j];

     NLegend curLegend = series.Legend.DisplayOnLegend;
     if (curLegend == null)
     {
      curLegend = chart.DisplayOnLegend;
     }

     if (curLegend == myLegend)
     {
      seriesOnLegend.Add(series);
     }
    }
   }

Hope this helps...