Free Support Forum - aspose.com

Problem with charts

I have writen below code to generate mixed chart with colum and line type charts.

when i run my program i could not able to see column chart.

If i manully set y-axis in secondary axis option by clicking right click under chart options.I could able to see column chart.How to solve this problem.

we are evaluating the aspose.excel product to purchase.

Thanks,

Arun

'Generate the second chart sheet

Dim sheetIndex As Integer = excel.Worksheets.Add(SheetType.Chart)

Dim sheet2 As Worksheet = excel.Worksheets(sheetIndex)

sheet2.Name = "Chart"

Dim chartIndex As Integer = sheet2.Charts.Add(ChartType.Column, 0, 0, 0, 0)

Dim chart As Chart = sheet2.Charts(chartIndex)

chart.Title.Text = "Revenue Distribution"

chart.Title.TextFont.IsBold = True 'Set chart title font

chart.Title.TextFont.Size = 16

'Set series

Dim series As String = "Summary!B2:B" & (ds.Tables(0).Rows.Count + 1)

chart.NSeries.Add(series, True)

chart.NSeries(0).Name = "Revenue"

Dim series1 As String = "Summary!D2:D" & (ds.Tables(0).Rows.Count + 1)

chart.NSeries.Add(series1, True)

chart.NSeries(1).Name = "sales"

chart.NSeries(1).Type = ChartType.Line

chart.NSeries(0).DataLabels.IsValueShown = True

chart.NSeries(1).DataLabels.IsValueShown = True

'Set category

chart.NSeries.CategoryData = "Summary!A2:A" & (ds.Tables(0).Rows.Count + 1)

excel.ChangePalette(Color.FromArgb(255, 255, 200), 53)

chart.PlotArea.Area.ForegroundColor = Color.FromArgb(255, 255, 200)

'Set major grid line color

excel.ChangePalette(Color.FromArgb(121, 117, 200), 54)

chart.MajorGridLines.Color = Color.FromArgb(121, 117, 200)

chart.MajorGridLines.IsVisible = False

The following is my sample code and all work fine. Which version are you using?

Dim excel As Excel = New Excel()

Dim cells As Cells = excel.Worksheets(0).Cells


cells("A1").PutValue(1)


cells("A2").PutValue(2)


cells("A3").PutValue(3)


cells("B1").PutValue(4)


cells("B2").PutValue(5)


cells("B3").PutValue(6)

cells("C1").PutValue("a")

cells("C2").PutValue("b")

cells("C3").PutValue("c")



excel.Worksheets.Add(SheetType.Chart)

Dim chartIndex As Integer = excel.Worksheets(1).Charts.Add(ChartType.Column,0,0,0,0)

Dim chart As Chart = excel.Worksheets(1).Charts(chartIndex)

chart.Title.Text = "Revenue Distribution"

chart.Title.TextFont.IsBold = True

chart.Title.TextFont.Size = 16




chart.NSeries.Add("Sheet1!A1:A3", True)
chart.NSeries(0).Name = "Revenue"

chart.NSeries.Add("Sheet1!B1:B3", True)
chart.NSeries(1).Name = "sales"


chart.NSeries(1).Type = ChartType.Line

chart.NSeries(0).DataLabels.IsValueShown = True
chart.NSeries(1).DataLabels.IsValueShown = True