Free Support Forum -

Problems importing the correct chart

I am attempting to take a document and replace a certain text placeholder with a pie chart. I am able to import a chart, but it is the wrong chart type and contains no values (but the chart title has been changed). The chart displays a y- and x-axis from 2 to 9 and -1 to 6 respectively with no values.

Any assistance would be much appreciated. The code seems straightforward (the chart code is from one of your demo's):

' Main call

Dim CPI As New ReplaceEvaluator(AddressOf IncludeCPIEvaluator)

doc.Range.Replace(New Regex("<>"), CPI, False)

Private Function IncludeCPIEvaluator(ByVal sender As Object, ByVal e As ReplaceEvaluatorArgs) As ReplaceAction

Dim obuilder As New DocumentBuilder(e.MatchNode.Document)



e.Replacement = ""

Return ReplaceAction.Replace

End Function

Public function DetermineCPIValue() as drawing.image

Dim c As Aspose.Chart.Chart = New Aspose.Chart.Chart

c.Titles.Add(New Aspose.Chart.Title)

c.Titles(0).Text = "Doughnut 2D, All Exploded"

c.BackColor = Color.FromArgb(153, 204, 255)

c.ChartArea.BackColor = Color.FromArgb(247, 243, 233)

c.ChartArea.LegendBox.BackColor = Color.FromArgb(255, 255, 204)

c.ChartArea.PaletteType = Aspose.Chart.PaletteType.Fresh

c.ChartArea.LegendBox.LegendPositionType = LegendPositionType.Bottom

c.ChartArea.LegendBox.LayoutType = Aspose.Chart.LayoutType.Row

Dim s As Aspose.Chart.Series = New Aspose.Chart.Series

s.ChartType = ChartType.Doughnut

s.CustomAttributes.ExplodedWidthRate = 0.1F

s.CustomAttributes.IsAllExploded = True

s.DefaultDataPoint.IsLabelVisible = True

s.DefaultDataPoint.LabelValue = Aspose.Chart.DataLabelValueType.DataPointName

s.DataPoints.Add(New Aspose.Chart.DataPoint("Point 0", 0, 5))

s.DataPoints.Add(New Aspose.Chart.DataPoint("Point 1", 1, 7))

s.DataPoints.Add(New Aspose.Chart.DataPoint("Point 2", 2, 3))

s.DataPoints.Add(New Aspose.Chart.DataPoint("Point 3", 3, 8))

s.DataPoints.Add(New Aspose.Chart.DataPoint("Point 4", 4, 4))

s.DataPoints.Add(New Aspose.Chart.DataPoint("Point 5", 5, 6))


Return c.GetChartImage

End Function

The chart is displayed correctly in my test (see attached file). I am using Aspose.Words 3.7.1 and Aspose.Chart 3.0.4.

miklovan, thanks for taking time to look at this.

Finally discovered the problem. I was setting the charttype to be charttype.doughnut, but it should have been aspose.chart.charttype.doughnut!Embarrassed [:$] (I also had a unused reference to cells, and so this was used instead)