This is a migrated thread and some comments may be shown as answers.

Exporting Report Chart not displaying Correctly

3 Answers 130 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 2
Scott asked on 20 Sep 2010, 06:02 PM
When running a report, my line chart displays fine, but when exporting the chart to any format (PDF, Excel, ect...) the lines on the graph no longer show up.  The graph itself appears along with the key, x-axis information, y-axis information, but the actual lines are missing.

The chart is being built programmatic.

This code passes in a telerik chart, and the corresponding text file.

Private Sub LoadChart(ByVal sFileName As String, ByRef sChart As Telerik.Reporting.Chart)
       Dim inFile As StreamReader = File.OpenText(sFileName)
       Try
           Dim j As Integer
           Dim sLine As String
           Dim sValues() As String
           Dim chartSeries() As Telerik.Reporting.Charting.ChartSeries
           Dim bFirstLoad As Boolean = False
           Dim yMax, yMin As Double
 
           Do While inFile.Peek <> -1
               sLine = inFile.ReadLine
               sValues = Split(sLine, vbTab)
 
               If UCase(Trim(sValues(0))) = "TEMPERATURE" Then
                   'Create an array of Series for length of value
                   'Create Chart Series Names
                   For j = 0 To sValues.Length - 1
                       ReDim Preserve chartSeries(j)
                       chartSeries(j) = New Telerik.Reporting.Charting.ChartSeries
                       If j > 0 Then
                           If sValues(j) <> "" Then
                               chartSeries(j).Name = sValues(j)
                               chartSeries(j).Type = Charting.ChartSeriesType.Line
                               chartSeries(j).Appearance.PointMark.Dimensions.Width = 1
                               chartSeries(j).Appearance.PointMark.Dimensions.Height = 1
                               chartSeries(j).Appearance.PointMark.FillStyle.MainColor = chartSeries(j).Appearance.LineSeriesAppearance.Color
                               chartSeries(j).Appearance.PointMark.Visible = True
                               chartSeries(j).DefaultLabelValue = ""
                               chartSeries(j).YAxisType = Charting.ChartYAxisType.Primary
                           End If
                       End If
                   Next
               ElseIf IsNumeric(sValues(0)) Then
                   For j = 0 To sValues.Length - 1
                       If sValues(j) <> "" Then
                           If j > 0 Then
                               If bFirstLoad = False Then
                                   If yMax = 0 Then
                                       yMax = CDbl(sValues(j))
                                   End If
                                   If yMin = 0 Then
                                       yMin = CDbl(sValues(j))
                                   End If
                                   bFirstLoad = True
                               End If
 
                               'Add the values to the chart series
                               chartSeries(j).AddItem(CDbl(sValues(j)))
 
                               chartSeries(j).Item(chartSeries(j).Items.Count - 1).XValue = CDbl(sValues(0))
                               chartSeries(j).Item(chartSeries(j).Items.Count - 1).YValue = CDbl(sValues(j))
 
                               chartSeries(j).Item(chartSeries(j).Items.Count - 1).ActiveRegion.Tooltip = CDbl(sValues(j))
 
                               'Update Min and Max Values
                               If yMin > CDbl(sValues(j)) Then
                                   yMin = CDbl(sValues(j))
                               End If
 
                               If yMax < CDbl(sValues(j)) Then
                                   yMax = CDbl(sValues(j))
                               End If
                           End If
                       End If
                   Next
               End If
           Loop
 
           For j = 0 To chartSeries.Length - 1
               If j > 0 Then
                   sChart.Series.Add(chartSeries(j))
               End If
           Next
 
           sChart.PlotArea.XAxis.AxisLabel.TextBlock.Text = "Temperature"
           sChart.PlotArea.XAxis.AxisLabel.TextBlock.Appearance.TextProperties.Color = Color.Black
           sChart.PlotArea.XAxis.Appearance.Visible = Charting.Styles.ChartAxisVisibility.True
           sChart.PlotArea.XAxis.VisibleValues = Charting.Styles.ChartAxisVisibleValues.All
           sChart.PlotArea.XAxis.Appearance.Width = 3
           sChart.PlotArea.XAxis.MinValue = 10
           sChart.PlotArea.XAxis.MaxValue = 100
           sChart.PlotArea.XAxis.LabelStep = 10
           sChart.PlotArea.XAxis.MaxItemsCount = 100 + 1
           sChart.PlotArea.XAxis.AutoScale = False
 
 
           sChart.PlotArea.YAxis.AxisLabel.TextBlock.Text = "Concentration"
           sChart.PlotArea.YAxis.AxisLabel.TextBlock.Appearance.TextProperties.Color = Color.Black
           sChart.PlotArea.YAxis.Appearance.Visible = Charting.Styles.ChartAxisVisibility.True
           sChart.PlotArea.YAxis.Appearance.Width = 3
           sChart.PlotArea.YAxis.IsZeroBased = False
           sChart.PlotArea.YAxis.VisibleValues = Charting.Styles.ChartAxisVisibleValues.All
           sChart.PlotArea.YAxis.MaxValue = yMax
           sChart.PlotArea.YAxis.MinValue = yMin
           sChart.PlotArea.YAxis.AutoScale = False
 
           sChart.ChartTitle.TextBlock.Text = "Concentration vs Temperature"
 
       Catch ex As Exception
           VOMsgBox(ex.ToString)
 
       Finally
           inFile.Close()
           inFile = Nothing
       End Try
   End Sub

Any Idea on why it doesn't display when exported?

Thanks,
-Scott Cline

3 Answers, 1 is accepted

Sort by
0
Scott
Top achievements
Rank 2
answered on 21 Sep 2010, 03:06 PM
Here are the screen shots of it working in the report.  The first screen shot called report.jpg is the view of the chart from the report itself.  The second image is the view of the report after being exported to pdf.  Notice the lines for the graph are missing.

0
Accepted
Steve
Telerik team
answered on 22 Sep 2010, 05:06 PM
Hello Scott,

Every time the report is previewed, paged or exported it is processed and rendered from scratch. Thus if the chart is fine on initial load and differs on other action (i.e. export) then it must be caused by your code - check where and how many times the LoadChart method is invoked and whether it is necessary to invoke it on all operations or whether you're not clearing series or piling them up on subsequent actions such as refresh or export.

Kind regards,
Steve
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Scott
Top achievements
Rank 2
answered on 22 Sep 2010, 05:57 PM
Thanks Steve that Helped.  I was only loading my chart on new.  Its strange that it remembered the chart series names and creates the legends when exporting the chart but doesn't remember the actual data for the lines.

Thanks,
-Scott
Tags
General Discussions
Asked by
Scott
Top achievements
Rank 2
Answers by
Scott
Top achievements
Rank 2
Steve
Telerik team
Share this question
or