如何在按钮中使用ZedGraph [英] How to use ZedGraph in a button click
本文介绍了如何在按钮中使用ZedGraph的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
朋友,
我正在asp.net中做一个项目,我想显示一个使用ZedGraph dll的图形.现在,我在项目中显示与数据相对应的图形
但是现在我遇到了一个问题,就是该页面加载后该图始终可见.
而且我希望该图仅显示一个按钮单击事件..
当我单击按钮时,Friends plz帮助我显示此图.
现在正在使用此代码:
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:
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.
推荐答案
)" 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 字符串 对于 num = 0 >要 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 如果 gvFinancialSummaryReport.Rows(num).Cells( 8 ).Text = " 0 其他 y8(num)= gvFinancialSummaryReport.Rows(num).Cells( 8 ).Text 结束 如果 下一步 ' 生成图例中带有费用"的红色栏 Dim myBar As BarItem = myPane.AddBar(" 收费",新建填充(颜色红色,颜色白色,颜色红色) ' 生成图例中带有保险付款"的蓝条 myBar = myPane.AddBar(" ,没有,y2,Color.Blue) myBar.Bar.Fill = 新建填充(颜色蓝色,颜色白色,颜色蓝色) ' 在图例中生成带有患者付款"的绿色栏 myBar = myPane.AddBar(" ,没有,Y3,Color.Green) myBar.Bar.Fill = 新建填充(颜色绿色,颜色白色,颜色绿色) ' 生成图例中带有"Total Collections"的DarkTurquoise条形图 myBar = myPane.AddBar(" ,没什么,Y4,Color.DarkTurquoise) myBar.Bar.Fill = 新建填充(Color.DarkTurquoise,Color.White,Color.DarkTurquoise) ' 生成图例中带有保险调整/冲销"的黑条 myBar = myPane.AddBar(" ,新建填充(颜色黑色,颜色白色,颜色黑色) ' 生成图例中带有接收调整"的DarkSalmon条形 myBar = myPane.AddBar(" ,没有,y6,Color.DarkSalmon) myBar.Bar.Fill = 新建填充(Color.DarkSalmon,Color.White,Color.DarkSalmon) ' 生成图例中带有"Insurance AR"的DarkMagenta条形 myBar = myPane.AddBar(" ,没什么,y7,Color.DarkMagenta) myBar.Bar.Fill = 新建填充(Color.DarkMagenta,Color.White,Color.DarkMagenta) ' 生成图例中带有"Insurance A/R Days"的DarkKhaki条形 myBar = myPane.AddBar(" ,新建填充(Color.DarkKhaki,Color.White,Color.DarkKhaki) ' 在标签之间而不是在标签之间绘制X标记 myPane.XAxis.MajorTic.IsBetweenLabels = 真 ' 设置XAxis标签 myPane.XAxis.Scale.TextLabels = Xlabels ' 将XAxis设置为文本类型 myPane.XAxis.Type = AxisType.Text ' 用渐变填充轴区域 myPane.Chart.Fill = 新建填充(颜色白色,_ Color.FromArgb( 255 , 255 , 166 ), 90 .0F) ' 用纯色填充窗格区域 myPane.Fill = 新建 Fill(Color.FromArgb( 250 , 250 , 255 )) masterPane.AxisChange(g) ' BarItem.CreateBarLabels(myPane,False,"f0") ' myPane.YAxis.Scale.Max + = myPane.YAxis.Scale.MajorStep 结束 子
)" 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.
没有看到您的绑定代码,我不能百分百确定,但是听起来您是在Page_Load
事件而不是在Button单击中绑定了ZGraph.事件
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
这篇关于如何在按钮中使用ZedGraph的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文