Copied chart does not display data

Hi,

copying chart to another sheet does not include data. See code sample below

regards

Workbook wb = new Workbook();

wb.Worksheets.Clear();

Worksheet ws = wb.Worksheets.Add("New");

Style style = wb.Styles[wb.Styles.Add()];

style.Name = "DateTimeStyle";

style.Custom = "dd-mm hh:mm:ss";

DateTime dt = DateTime.Now.Date;

ws.Cells[23, 2].PutValue(dt);

ws.Cells[23, 2].SetStyle(style);

ws.Cells[24, 2].PutValue(dt.AddHours(1));

ws.Cells[24, 2].SetStyle(style);

ws.Cells[25, 2].PutValue(dt.AddHours(2));

ws.Cells[25, 2].SetStyle(style);

ws.Cells[26, 2].PutValue(dt.AddHours(3));

ws.Cells[26, 2].SetStyle(style);

ws.Cells[27, 2].PutValue(dt.AddHours(4));

ws.Cells[27, 2].SetStyle(style);

ws.Cells[28, 2].PutValue(dt.AddHours(5));

ws.Cells[28, 2].SetStyle(style);

ws.Cells[29, 2].PutValue(dt.AddHours(6));

ws.Cells[29, 2].SetStyle(style);

ws.Cells[23, 3].PutValue(3);

ws.Cells[24, 3].PutValue(4);

ws.Cells[25, 3].PutValue(9);

ws.Cells[26, 3].PutValue(13);

ws.Cells[27, 3].PutValue(16);

ws.Cells[28, 3].PutValue(3);

ws.Cells[29, 3].PutValue(7);

Chart chart = ws.Charts[ws.Charts.Add(ChartType.ScatterConnectedByLinesWithoutDataMarker, 1, 1, 22, 12)];

chart.Name = "MyChart1";

chart.CategoryAxis.TickLabels.NumberFormat = "dd-mm hh:mm;@";

chart.CategoryAxis.TickLabels.Rotation = 45;

chart.CategoryAxis.TickLabels.Font.Size = 8;

chart.CategoryAxis.MinValue = dt;

chart.CategoryAxis.MaxValue = dt.AddHours(6);

chart.CategoryAxis.MajorUnit = 0.04166666;

chart.Legend.Position = LegendPositionType.Bottom;

chart.ValueAxis.TickLabels.NumberFormat = "0";

chart.ValueAxis.MinValue = 0;

chart.ValueAxis.MaxValue = 20;

chart.Placement = PlacementType.Move;

String chartSubTitle = DateTime.Now.ToString();

chart.Title.Text = "Data" + "\n" + chartSubTitle;

Characters chars = chart.Title.Characters(chart.Title.Text.Length - chartSubTitle.Length, chartSubTitle.Length);

chars.Font.Size = 10;

chart.ValueAxis.Title.Text = "unit";

ASeries aSerie = chart.NSeries[chart.NSeries.Add(String.Format("{0}!{1}{2}:{1}{3}", ws.Name, "D", 24, 30), true)];

aSerie.XValues = String.Format("{0}!{1}{2}:{1}{3}", ws.Name, "C", 24, 30);

aSerie.Name = "Date";

Worksheet wsChart = wb.Worksheets.Add("ChartSheet");

Chart shortPeriodChart = wb.Worksheets["New"].Charts["MyChart1"];

Shape chartShape = shortPeriodChart.ChartObject as Shape;

wsChart.Shapes.AddCopy(chartShape, 1, 1, 1, 31);

wb.Save(@"Result.xlsx", FileFormatType.Excel2007Xlsx);

Hi,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

We have found your mentioned issue after an initial test. We will look into it and get back to you soon. Your issue has been registered in our internal issue tracking system with issue id: CELLSNET-14591.

Thank You & Best Regards,

Is there an alternative way to copy chart across sheets?

Hi,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Well, I am afraid there is no alternate way to copy charts at the moment. But we are working on your reported issue and we will hopefully provide a fix by the end of this week.

Thank You & Best Regards,

Please also see/compare the title on original and copied chart

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

We have found the difference in the font size between the title of original and copied chart. We will look into it and get back to your soon.

Thank You & Best Regards,

Hi,

Please try the attached version, we have fixed your issue.

Thank you.

the title formatting is still wrong

Hi,

Thanks for your feedback.

Yes, we noticed the font size is 12 instead of 10 in the copied chart, we have re-opened the issue. We will figure it out soon.

Thank you.

Hi,

Please try the attached version, we have resolved your issue now.

Thank you.

The issues you have found earlier (filed as 14591) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.