Hi,
In older versions you could append item's to LegendLabelList, e.g.:
rightLegend.LegendLabelList.Add(label);
Currently Legend.LegendLabelList is read-only and there is no method to append items to the list. Was this functionality just dropped or is there another way of doing this?
We are trying to upgrade but this is a major road block.
Thank you,
Mario Tiscareno
LegendLabelList
Re: LegendLabelList
Support · Apr 13, 2017Hello Mario,
Can you please send over the following details to [^a|mailto:support@cete.com|opennewwindow|support@cete.com^] so we can look into it further?
1.Code sample or console application which uses static data to recreate.
2.Exact version and build number of the older DynamicPDF DLL file. You can get this information in DLL references properties (Version and Description fields) in Visual Studio.
3.Exact version and build number of the new DynamicPDF DLL file.
Thanks,
ceTe Software Support Team.
Re: LegendLabelList
Forum member · Apr 13, 20171. Code Sample:
/////////////////////////////////////////////////
Document document = new Document();
Page page = new Page();
document.Pages.Add(page);
Chart chart = new Chart(0, 0, 400, 200);
IndexedBarSeries barSeries1 = new IndexedBarSeries("Website A");
chart.PrimaryPlotArea.Series.Add(barSeries1);
barSeries1.Values.Add(new float[] { 5, 7, 9, 6 });
IndexedBarSeries barSeries2 = new IndexedBarSeries("Website B");
chart.PrimaryPlotArea.Series.Add(barSeries2);
barSeries2.Values.Add(new float[] { 4, 2, 5, 8 });
IndexedBarSeries barSeries3 = new IndexedBarSeries("Website C");
chart.PrimaryPlotArea.Series.Add(barSeries3);
barSeries3.Values.Add(new float[] { 2, 4, 6, 9 });
IndexedBarSeries barSeries4 = new IndexedBarSeries("Website D");
chart.PrimaryPlotArea.Series.Add(barSeries4);
barSeries1.Values.Add(new float[] { 5, 3, 5, 6 });
IndexedBarSeries barSeries5 = new IndexedBarSeries("Website E");
chart.PrimaryPlotArea.Series.Add(barSeries5);
barSeries2.Values.Add(new float[] { 2, 2, 4, 8 });
IndexedBarSeries barSeries6 = new IndexedBarSeries("Website F");
chart.PrimaryPlotArea.Series.Add(barSeries6);
barSeries3.Values.Add(new float[] { 3, 4, 8, 9 });
Legend defaultLegend = chart.Legends[0];
defaultLegend.Visible = false;
Legend lefthandLegend = chart.Legends.Add();
lefthandLegend.BackgroundColor = RgbColor.SkyBlue;
// the following code will not compile with recent versions but is working as of v. 5.1.2.35
lefthandLegend.LegendLabelList.Add(defaultLegend.LegendLabelList[0]);
lefthandLegend.LegendLabelList.Add(defaultLegend.LegendLabelList[1]);
lefthandLegend.LegendLabelList.Add(defaultLegend.LegendLabelList[2]);
Legend righthandLegend = chart.Legends.Add();
righthandLegend.BackgroundColor = RgbColor.Pink;
righthandLegend.LegendLabelList.Add(defaultLegend.LegendLabelList[3]);
righthandLegend.LegendLabelList.Add(defaultLegend.LegendLabelList[4]);
righthandLegend.LegendLabelList.Add(defaultLegend.LegendLabelList[5]);
page.Elements.Add(chart);
document.Draw(@"C:\Temp\Simplechart.pdf");
/////////////////////////////////////////////////
2. Old version (works): 5.1.2.35
3. New version: 8.0.3 build 32767
Re: LegendLabelList
Support · Apr 14, 2017Hello,
Thanks for sharing the information. We looked into the code. The Add method to include the Legends to LegendLabelList is deprecated in v5.1 and it is not available in v7 and later versions of DynamicPDF Generator API.
You can achieve your requirements using latest DynamicPDF Generator API. You will need to create custom legends and then assign them to the bar series and add the series to the plot area. This will work for you. Below is the modified code.
Document document = new Document();
Page page = new Page();
document.Pages.Add(page);
Chart chart = new Chart(0, 0, 400, 200);
PlotArea plotArea = chart.PrimaryPlotArea;
Legend lefthandLegend = chart.Legends.Add();
lefthandLegend.BackgroundColor = RgbColor.SkyBlue;
Legend righthandLegend = chart.Legends.Add();
righthandLegend.BackgroundColor = RgbColor.Pink;
IndexedBarSeries barSeries1 = new IndexedBarSeries("Website A");
barSeries1.Values.Add(new float[] { 5, 7, 9, 6 });
barSeries1.Legend = lefthandLegend;
plotArea.Series.Add(barSeries1);
IndexedBarSeries barSeries2 = new IndexedBarSeries("Website B");
barSeries2.Values.Add(new float[] { 4, 2, 5, 8 });
barSeries2.Legend = lefthandLegend;
plotArea.Series.Add(barSeries2);
IndexedBarSeries barSeries3 = new IndexedBarSeries("Website C");
barSeries3.Values.Add(new float[] { 2, 4, 6, 9 });
barSeries3.Legend = lefthandLegend;
plotArea.Series.Add(barSeries3);
IndexedBarSeries barSeries4 = new IndexedBarSeries("Website D");
barSeries4.Values.Add(new float[] { 5, 3, 5, 6 });
barSeries4.Legend = righthandLegend;
plotArea.Series.Add(barSeries4);
IndexedBarSeries barSeries5 = new IndexedBarSeries("Website E");
barSeries5.Values.Add(new float[] { 2, 2, 4, 8 });
barSeries5.Legend = righthandLegend;
plotArea.Series.Add(barSeries5);
IndexedBarSeries barSeries6 = new IndexedBarSeries("Website F");
barSeries6.Values.Add(new float[] { 3, 4, 8, 9 });
barSeries6.Legend = righthandLegend;
plotArea.Series.Add(barSeries6);
chart.Layout();
chart.AutoLayout = false;
righthandLegend.Y = lefthandLegend.Y + lefthandLegend.RequiredHeight;
page.Elements.Add(chart);
document.Draw(@"C:\Temp\Simplechart.pdf");
Thanks,
ceTe Software Support Team.
Re: LegendLabelList
Forum member · Apr 17, 2017This should work, thank you!