Public Sub LPAllTubesChart( _
ByRef adoDataTable As ADODB.Recordset, _
ByVal strFieldsPane1() As String, _
ByVal strFieldsPane2() As String, _
ByVal strFieldsPane3() As String, _
ByVal strFieldXLabel As String, _
ByVal strChartTitle As String, _
ByVal chrFX As ChartDirector.WinChartViewer)
If Not adoDataTable.BOF Then adoDataTable.MoveFirst()
Dim NumOfSeries As Integer = (strFieldsPane1.Length + _
strFieldsPane2.Length + strFieldsPane3.Length) / 2
Dim NumOfPoints As Integer = adoDataTable.RecordCount
Dim series As Integer
Dim M As New ChartDirector.MultiChart(chrFX.Width, chrFX.Height)
Dim PlotHeight As Integer = M.getHeight() - 55 - 20
Dim SubOffset As Integer = 5
Dim SubHeight As Integer = (PlotHeight \\ 3) - (SubOffset * 2)
Dim C1 As New ChartDirector.XYChart(chrFX.Width, SubHeight)
Dim C2 As New ChartDirector.XYChart(chrFX.Width, SubHeight)
Dim C3 As New ChartDirector.XYChart(chrFX.Width, SubHeight + 20)
C1.setPlotArea(70, 10, C1.getWidth() - 72, C1.getHeight() - 15, -1)
C2.setPlotArea(70, 10, C2.getWidth() - 72, C2.getHeight() - 15, -1)
C3.setPlotArea(70, 10, C3.getWidth() - 72, C3.getHeight() - 30, -1)
M.addChart(0, 20, C1)
M.addChart(0, 20 + SubHeight + SubOffset, C2)
M.addChart(0, 20 + (SubHeight + SubOffset) * 2, C3)
Dim DataX As New List(Of String)
Dim DataY As New List(Of List(Of Double))
For I As Integer = 1 To NumOfSeries
DataY.Add(New List(Of Double))
Next
' setup the chart chrFX to display the data from the adoDataset
'With Chrt
' initialize the chart data
'.ClearData(SoftwareFX.ChartFX.ClearDataFlag.AllData)
'.Panes.Clear()
M.addTitle(strChartTitle)
'.Titles(0).Text = strChartTitle
'.Titles(0).Font = New System.Drawing.Font(.Titles(0).Font, FontStyle.Bold)
' setup for 3 panes
'.Axis(0).Pane = 0
'.Axis(1).Pane = 1
'.Axis(3).Pane = 2
' assign the series to the axes
' First Pane
series = 0
' Second Pane
For i As Integer = 0 To strFieldsPane2.Length / 2 - 1
series += 1
Next
' Third Pane
For i As Integer = 0 To strFieldsPane3.Length / 2 - 1
series += 1
Next
Dim minP1 As Double = Double.MaxValue, maxP1 As Double = Double.MinValue
Dim minP2 As Double = Double.MaxValue, maxP2 As Double = Double.MinValue
Dim minP3 As Double = Double.MaxValue, maxP3 As Double = Double.MinValue
' Axis-Y
' assign the data to chart
Dim valueY As Double
Dim valueX As String
For point As Integer = 0 To NumOfPoints - 1
' Axis-X label
valueX = adoDataTable.Fields(strFieldXLabel).Value
DataX.Add(valueX) '----- .AxisX.Label(point) = valueX
' First Pane
valueY = ChartDirector.Chart.CTime(CDate(adoDataTable.Fields(strFieldsPane1(0)).Value))
series = 0
DataY(series).Add(valueY) '----- .Value(series, point) = valueY
If minP1 > valueY Then minP1 = valueY
If maxP1 < valueY Then maxP1 = valueY
' Second Pane
'.Value(1, point) = adoDataTable.Fields("SiD").Value
'.Value(2, point) = adoDataTable.Fields("SiI").Value
'.Value(3, point) = adoDataTable.Fields("CLP").Value
For i As Integer = 0 To strFieldsPane2.Length / 2 - 1
valueY = adoDataTable.Fields(strFieldsPane2(i * 2)).Value
series += 1
DataY(series).Add(valueY) '----- .Value(series, point) = valueY
If minP2 > valueY Then minP2 = valueY
If maxP2 < valueY Then maxP2 = valueY
Next
' Third Pane
'.Value(4, point) = adoDataTable.Fields("Z1Temp").Value
'.Value(5, point) = adoDataTable.Fields("Z2Temp").Value
'.Value(6, point) = adoDataTable.Fields("Z3Temp").Value
For i As Integer = 0 To strFieldsPane3.Length / 2 - 1
valueY = adoDataTable.Fields(strFieldsPane3(i * 2)).Value
series += 1
DataY(series).Add(valueY) '----- .Value(series, point) = valueY
If minP3 > valueY Then minP3 = valueY
If maxP3 < valueY Then maxP3 = valueY
Next
adoDataTable.MoveNext()
Next
C2.yAxis.setLinearScale(minP2, maxP2)
C3.yAxis.setLinearScale(minP3, maxP3)
series = 0
Dim L As ChartDirector.Layer
L = C1.addLineLayer
L.addDataSet(DataY(series).ToArray(), -1, strFieldsPane1(1))
L = C2.addLineLayer
For i As Integer = 0 To strFieldsPane2.Length / 2 - 1
series += 1
L.addDataSet(DataY(series).ToArray(), -1, strFieldsPane2(i * 2 + 1))
Next
L = C3.addLineLayer
For i As Integer = 0 To strFieldsPane3.Length / 2 - 1
series += 1
L.addDataSet(DataY(series).ToArray(), -1, strFieldsPane3(i * 2 + 1))
Next
C1.xAxis.setLabels(DataX.ToArray)
C1.xAxis.setLabelFormat(" ")
C2.xAxis.setLabels(DataX.ToArray)
C3.xAxis.setLabels(DataX.ToArray)
Call LPChartFormatEx(strFieldsPane1, strFieldsPane2, strFieldsPane3, strFieldXLabel, C1, C2, C3)
chrFX.Chart = M
chrFX.ImageMap = M.getHTMLImageMap("", "", "title='{xLabel}:{dataSetName}: {value}'")
' chrFX.ImageMap = M.getHTMLImageMap("", "", "title='{xLabel}:{dataSetName}: {value|hh:nn:ss}'")
End Sub
Private Sub LPChartFormatEx( _
ByVal strFieldsPane1() As String, _
ByVal strFieldsPane2() As String, _
ByVal strFieldsPane3() As String, _
ByVal strAxisXTitle As String, _
ByVal ParamArray chrFX() As ChartDirector.XYChart)
' point value
'.PointLabels = True
'.AxisX.Staggered = True
' title
With chrFX(0)
.yAxis.setTitle("Times", "", 8)
.yAxis.setDateScale("{value|hh:nn:ss}")
.yAxis.setAutoScale(0.03, 0.03)
End With
With chrFX(1)
.yAxis.setTitle("SCCM", "", 8)
.yAxis.setAutoScale(0.03, 0.03)
End With
With chrFX(2)
.yAxis.setTitle("Degree C", "", 8)
.yAxis.setAutoScale(0.03, 0.03)
.xAxis.setTitle("Entity", "", 8)
End With
' grid lines
'.Axis(0).Gridlines = True
'.Axis(1).Gridlines = True
'.Axis(3).Gridlines = True
End Sub
|