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

I am doing a project in asp.net, and I want to show a graph using ZedGraph dll. Now I show the graph in my project corresponding to the data
but now I faced a problem that is that graph is always visible when that page is loaded.

And I want that graph shows only a button click event..

Friends plz help me to show this graph when I clicked a button.

Now am using This Code:

VB
Private Sub OnRenderGraph1(ByVal zgw As ZedGraphWeb, ByVal g As System.Drawing.Graphics, _
    ByVal masterPane As ZedGraph.MasterPane) Handles ZedGraphWeb1.RenderGraph

    'Dim myPane As GraphPane = zgc.GraphPane
    Dim myPane As GraphPane = masterPane(0)
    Dim num As Integer
    Dim Xcount As Integer

    ' Set the titles and axis labels
    myPane.Title.Text = "LBS Financials – All Practices - April 2011 - November 2010"
    myPane.XAxis.Title.Text = "Month/Year"
    myPane.YAxis.Title.Text = "Values In ($)"

    Xcount = gvFinancialSummaryReport.Rows.Count - 1

    Dim y1(Xcount), y2(Xcount), Y3(Xcount), Y4(Xcount), y5(Xcount), y6(Xcount), _
    y7(Xcount), y8(Xcount) As Double
    Dim Xlabels(Xcount) As String

    For num = 0 To Xcount
        Xlabels(num) = gvFinancialSummaryReport.Rows(num).Cells(0).Text

        y1(num) = gvFinancialSummaryReport.Rows(num).Cells(1).Text
        y2(num) = gvFinancialSummaryReport.Rows(num).Cells(2).Text
        Y3(num) = gvFinancialSummaryReport.Rows(num).Cells(3).Text
        Y4(num) = gvFinancialSummaryReport.Rows(num).Cells(4).Text
        y5(num) = gvFinancialSummaryReport.Rows(num).Cells(5).Text
        y6(num) = gvFinancialSummaryReport.Rows(num).Cells(6).Text
        y7(num) = gvFinancialSummaryReport.Rows(num).Cells(7).Text

        If gvFinancialSummaryReport.Rows(num).Cells(8).Text = "" Then
            y8(num) = 0
        Else
            y8(num) = gvFinancialSummaryReport.Rows(num).Cells(8).Text
        End If
    Next
    ' Generate a red bar with "Charges" in the legend

    Dim myBar As BarItem = myPane.AddBar("Charges", Nothing, y1, Color.Red)
    myBar.Bar.Fill = New Fill(Color.Red, Color.White, Color.Red)


    ' Generate a blue bar with "Insurance Payments" in the legend
    myBar = myPane.AddBar("Insurance Payments", Nothing, y2, Color.Blue)
    myBar.Bar.Fill = New Fill(Color.Blue, Color.White, Color.Blue)

    ' Generate a green bar with "Patient Payments" in the legend
    myBar = myPane.AddBar("Patient Payments", Nothing, Y3, Color.Green)
    myBar.Bar.Fill = New Fill(Color.Green, Color.White, Color.Green)

    ' Generate a DarkTurquoise bar with "Total Collections" in the legend
    myBar = myPane.AddBar("Total Collections", Nothing, Y4, Color.DarkTurquoise)
    myBar.Bar.Fill = New Fill(Color.DarkTurquoise, Color.White, Color.DarkTurquoise)

    ' Generate a Black bar with "Insurance Adjustments / Write-offs" in the legend
    myBar = myPane.AddBar("Insurance Adjustments / Write-offs", Nothing, y5, Color.Black)
    myBar.Bar.Fill = New Fill(Color.Black, Color.White, Color.Black)

    ' Generate a DarkSalmon bar with "Receipt Adjustments" in the legend
    myBar = myPane.AddBar("Receipt Adjustments", Nothing, y6, Color.DarkSalmon)
    myBar.Bar.Fill = New Fill(Color.DarkSalmon, Color.White, Color.DarkSalmon)

    ' Generate a DarkMagenta bar with "Insurance AR" in the legend
    myBar = myPane.AddBar("Insurance AR", Nothing, y7, Color.DarkMagenta)
    myBar.Bar.Fill = New Fill(Color.DarkMagenta, Color.White, Color.DarkMagenta)

    ' Generate a DarkKhaki bar with "Insurance A/R Days" in the legend
    myBar = myPane.AddBar("Insurance A/R Days", Nothing, y8, Color.DarkKhaki)
    myBar.Bar.Fill = New Fill(Color.DarkKhaki, Color.White, Color.DarkKhaki)


    ' Draw the X tics between the labels instead of at the labels
    myPane.XAxis.MajorTic.IsBetweenLabels = True

    ' Set the XAxis labels
    myPane.XAxis.Scale.TextLabels = Xlabels
    ' Set the XAxis to Text type
    myPane.XAxis.Type = AxisType.Text

    ' Fill the axis area with a gradient
    myPane.Chart.Fill = New Fill(Color.White, _
       Color.FromArgb(255, 255, 166), 90.0F)
    ' Fill the pane area with a solid color
    myPane.Fill = New Fill(Color.FromArgb(250, 250, 255))

    masterPane.AxisChange(g)
    'BarItem.CreateBarLabels(myPane, False, "f0")

    'myPane.YAxis.Scale.Max += myPane.YAxis.Scale.MajorStep
End Sub



Please help me.

Thanks.
Posted
Updated 10-Feb-11 1:47am
v3
Comments
m@dhu 10-Feb-11 6:37am    
Always wrap your code in pre tags.
Sunasara Imdadhusen 10-Feb-11 6:55am    
Where is code to bind ZGraph?

1 solution

Without seeing your binding code I can't be 100% sure but it sounds like you're binding the ZGraph in your Page_Load event rather than in your Button Click event
 
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