hi,
I am creating chart from code in excel. Below are few of the issues I am facing while working with charts, Chart is Line chart.
1) Right now all lines before 1st point it starts from zero and then taking that zero to 1st point. I want all lines start from its 1st point value and not zero.
2) I am saving chart to an image and then showing that image in chart. Here after converting chart to an image, it shows the watermark on image saying "Evalution only. Created with Aspose.Cells for .Net (c) 2003-2012 Aspose pty ltd.".
I am using Aspose license with generate so why is showing like this?
3) My chart appears correct but once chart is converted to an image, it cuts the Chart title.
4) I want to make line bit more thick. Width of the line should be 2. Its taking 1 currently. I tried this but did not work.
oChart.NSeries[iSeriesCtr].SeriesLines.WeightPt = 2;
Below is the code to generate chart, and attached the report template and also report output file.
--------------------------------------------------------------------------------------------------
Workbook oWB = new Workbook(@"C:\Working\Report1.xls");
Worksheet oSheet = oWB.Worksheets[0];
Cells oCells = oSheet.Cells;
// Link chart data
string sSeriesStart = "M4";
string sSeriesEnd = "R41";
string sCategoryStart = "L5";
string sCategoryEnd = "L41";
Int32 iStartRow = 3;
Int32 iStartColumn = 11;
Chart oChart = oSheet.Charts["Chart 1"];
oChart.NSeries.Add(string.Concat(sSeriesStart, ":", sSeriesEnd), true);
oChart.NSeries.CategoryData = string.Concat(sCategoryStart, ":", sCategoryEnd);
oChart.NSeries.IsColorVaried = true;
for (int iSeriesCtr = 0; iSeriesCtr < oChart.NSeries.Count; iSeriesCtr++)
oChart.NSeries[iSeriesCtr].Name = oCells[iStartRow, iStartColumn + iSeriesCtr + 1].Value.ToString();
// Format chart
oChart.Type = ChartType.Line;
oChart.CategoryAxis.IsAutomaticMajorUnit = true;
oChart.CategoryAxis.IsAutomaticMinorUnit = true;
oChart.CategoryAxis.BaseUnitScale = TimeUnit.Days;
oChart.CategoryAxis.CategoryType = CategoryType.TimeScale;
oChart.Title.Text = "Test Title";
oChart.Title.Font.Size = 10;
oChart.Title.Font.Name = "Calibri";
oChart.Title.Font.IsBold = true;
oChart.Title.Font.Color = Color.Black;
oChart.PlotArea.X = 100;
oChart.PlotArea.InnerX = 105;
oChart.PlotArea.Y = 50;
oChart.PlotArea.InnerY = 55;
oChart.PlotArea.Height = 3500;
oChart.PlotArea.Width = 4000;
oChart.ShowLegend = true;
oChart.Legend.Position = LegendPositionType.Top;
oChart.Legend.Border.IsVisible = false;
oChart.Legend.Font.Size = 5;
// Convert chart to an image
string sChartImageFilePath = string.Concat("ChartImage", ".PNG");
Aspose.Cells.Rendering.ImageOrPrintOptions oImageOrPrintOptions = new Aspose.Cells.Rendering.ImageOrPrintOptions();
oImageOrPrintOptions.IsCellAutoFit = false;
oImageOrPrintOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Png;
for (int iCtr = 0; iCtr < oSheet.Shapes.Count; iCtr++)
{
if (oSheet.Shapes[iCtr].Name == "Chart 1")
{
oSheet.Shapes[iCtr].ToImage(sChartImageFilePath, oImageOrPrintOptions);
oSheet.Shapes.DeleteShape(oSheet.Shapes[iCtr]);
oSheet.Pictures.Add(3, 0, 27, 9, sChartImageFilePath);
File.Delete(sChartImageFilePath);
break;
}
}
// Save file
oWB.Save(@"C:\Working\Report1Output.xls");
--------------------------------------------------------------------------------------------------