Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display multiple charts on one page

Status
Not open for further replies.

tman24m

Programmer
May 21, 2001
93
US
Trying to display more than one chart on a page using ChartDirector. i can only get one chart to display or one chart and 5 missing images. If anyone can help, please do. Thanks

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim SelectedDate As Date = Request("SelectedDate")
Dim WkBeginDate As Date = Request("wkBeginDate")
Dim MoBeginDate As Date = Request("moBeginDate")
Dim YrBeginDate As Date = Request("yrBeginDate")

Build_Chart(SelectedDate, WkBeginDate)
End Sub

Private Sub Build_Chart(ByVal SelectedDate, ByVal wkBegin)

Dim cnnQA As New SqlConnection(ConfigurationSettings.AppSettings("QA_DSN"))

'Dim cmdDef As SqlCommand = New SqlCommand("spCodedDefects", cnnQA)
'cmdDef.CommandType = CommandType.StoredProcedure

Dim strSQL As String = New String("spCodedDefects @begindate='" & wkBegin & "', @enddate='" & SelectedDate & "'")
Dim da As SqlDataAdapter = New SqlDataAdapter(strSQL, cnnQA)
cnnQA.Open()

Dim myDataSet As New System.Data.DataSet()
da.Fill(myDataSet, "Defects")
cnnQA.Close()

Dim dv As DataView = New DataView(myDataSet.Tables("Defects"))
dv.Sort = "Problem"

Dim p As Integer
Dim htmlStr As String
Dim Area As String
For p = 1 To 6 Step 1
Select Case p
Case 1
Area = "Assembly"
Case 2
Area = "Deck Rig"
Case 3
Area = "Lamination"
Case 5
Area = "Small Parts"
Case 6
Area = "Sub Assembly"
End Select
htmlStr = &quot;<asp:image id=&quot;&quot;chartImg&quot; & p & &quot; runat=&quot;&quot;server&quot;&quot;></asp:image>&quot;
dv.RowFilter = &quot;Area = '&quot; & Area & &quot;'&quot;

Dim a As Integer = dv.Count
a = a - 1

Dim Problem(a) As String
Dim Count(a) As Double
Dim drv As DataRowView
Dim i As Integer = 0

For Each drv In dv
Problem(i) = drv.Item(2)
Count(i) = drv.Item(3)
i = i + 1
Next

'Dim c As New XYChart(420, 240)
Dim c(p) As XYChart

c(p) = New XYChart(750, 440)
'Set the chart background
c(p).setBackground(&HFFFFC0, &HFFFFC0, 2)

'Set the plotarea and background color.
c(p).setPlotArea(45, 65, 638, 298, &HFFFFFF, -1, 1, Chart.Transparent)

'Add a title to the chart
c(p).addTitle(&quot;Coded Defects For &quot; & Area, &quot;timesbi.ttf&quot;).setBackground(&HFFFF00)

'Add a legend box at the top of the plotarea
c(p).addLegend(70, 30, 0, &quot;&quot;, 8).setBackground(Chart.Transparent)

'Add a bar chart layer using the supplied data
c(p).addBarLayer(Count, &H3333CC, &quot;Total&quot;).setBorderColor(-1, 1)

'Set the x axis labels.
c(p).xAxis().setLabels(Problem).setFontAngle(90)

'Set the x-axis width to 2 pixels
c(p).xAxis().setWidth(2)

'Set the y axis title
c(p).yAxis().setTitle(&quot;Coded Defects&quot;)

'Set the y-axis width to 2 pixels
c(p).yAxis().setWidth(2)


<!--THIS IS THE HAZEY PART-->
'Output the chart
'Session(&quot;chart&quot;) = c(p).makeChart2(Chart.PNG)
'Session(&quot;imgNo&quot;) = Session(&quot;imgNo&quot;) + p
Response.ContentType = &quot;image/png&quot;
Response.BinaryWrite(c(p).makeChart2(Chart.PNG))
Response.Write(htmlStr)
'Response.Write(&quot;<br><p>Break</p><br>&quot;)
'Response.Write(&quot;<img src = &quot;&quot;myimage.aspx?img=chart&id=&quot;&quot;&quot; & Session.SessionID & &quot;&quot;&quot;_&quot;&quot;&quot; & Session(&quot;imgNo&quot;) > &quot;&quot;)

Next p
End Sub
 
tman: ChartDirector has a forum located at their site, and Peter Kwan, one of the principals at this company, and others, respond within hours (typically) of all chartdirector questions. Try a quick post there also.

The forum at ChartDirector is:


When I post several charts on one page using chartdirector I just break it up in several src tags and call individual aspx pages.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top