Click here to Skip to main content
15,884,177 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hi ,

I have a requirement to export the chart to Excel and PDF.

I can able to export the chart with 2 axis to pdf using itextsharp and SQLDATASOURCE. The thing is I have 3 axis(X,Y,Secondary Y) Chart so I couldn't able to export the chart to PDF/Excel.And I am using Sql server 2008 to pull values for chart axis.

Can anyone please guide me on this..its ruin my head :(

Thanks in Advance.
Posted
Comments
Member 2707515 9-Apr-13 9:06am    
means u want to create a pie daigram
venkatesun 16-Apr-13 2:28am    
any kind of chart with 3 axis but no 3D :)

SQL
Imports System.Web.UI.DataVisualization
Imports System.Web.UI.DataVisualization.Charting

Dim srs As Series = chtTotal.Series.Add("srsTotal")
        Dim lgn As Legend = chtTotal.Legends.Add("legTotal")
        Dim ds As DataSet = Bugs.GetCallListForReviewChartPie(Session("user_id"), lblClients.Text, txtFromDate.Text, txtToDate.Text)
        If ds.Tables(0).Rows.Count > 0 Then
            chtTotal.DataSource = ds.Tables(0)

            lgn.LegendStyle = LegendStyle.Table
            lgn.Alignment = StringAlignment.Center
            lgn.Docking = Docking.Bottom

            srs.ChartType = SeriesChartType.Pie
            srs.ShadowOffset = 2
            srs.Font = New Font("Times New Format", 7.0F)
            srs.IsValueShownAsLabel = True
            Dim yValues(1) As Integer
            Dim xValues(1) As String

            For j As Integer = 0 To ds.Tables(0).Rows.Count - 1
                xValues(j) = ds.Tables(0).Rows(j).Item("Category")
                If ds.Tables(0).Rows.Count = 1 Then
                    xValues(j + 1) = IIf(ds.Tables(0).Rows(j).Item("Category") = "CR", "PR", "CR")
                End If
            Next
            For i As Integer = 0 To ds.Tables(0).Rows.Count - 1
                yValues(i) = ds.Tables(0).Rows(i).Item("Total")
            Next

            srs.Points.DataBindY(yValues)
            For pointIndex As Integer = 0 To srs.Points.Count - 1
                srs.Points(pointIndex).LegendText = xValues(pointIndex)
                srs.Points(pointIndex).ToolTip = xValues(pointIndex) & " (" & yValues(pointIndex) & ")"
                srs.Points(pointIndex).LegendToolTip = xValues(pointIndex) & " (" & yValues(pointIndex) & ")"
            Next


            srs.PostBackValue = "#INDEX"
            srs.LegendPostBackValue = "#INDEX"
            srs.Points(0).Font = New Font("Times New Format", 7.0F)
            chtTotal.Series("srsTotal").SetCustomProperty("PieLabelStyle", "Disabled")

            For pointIndex As Integer = 0 To srs.Points.Count - 1
                If yValues(pointIndex) = "0" Then
                    srs.Points(pointIndex).PostBackValue = ""
                    srs.Points(pointIndex).LegendPostBackValue = ""
                End If
            Next

            If Not txtID.Text = "" Then
                srs.Points(IIf(txtID.Text = "PR", 1, 0)).Font = New Font("Times New Format", 9.0F, FontStyle.Bold)
                srs.Points(IIf(txtID.Text = "PR", 1, 0)).BorderColor = Color.Black
                srs.Points(IIf(txtID.Text = "PR", 1, 0)).BorderWidth = 4
            End If

            chtTotal.Width = 500

            If File.Exists(tmpChartName) Then File.Delete(tmpChartName)
            chtTotal.SaveImage(tmpChartName, ChartImageFormat.Png)
            chtTotal.Legends.RemoveAt(0)

            chtTotal.Width = 200
        Else
            chtTotal.Visible = False
            Session("Message") = "No Records."
            Master.ShowMessage()
        End If


i create dynamically, this with the help of mschart.
 
Share this answer
 
My charts automatically exported into a file. I don't know how to solve that problem. Because export coding is not included in my application.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900