1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
| Private Sub FaireGraph(ByVal Data As DataTable, ByVal Str As String)
Chart1.ChartAreas.Clear()
Chart1.Series.Clear()
'Dim ChartArea1 As New ChartArea()
Chart1.ChartAreas.Add("ChartArea1")
Chart1.Series.Add("Prix")
'Type de graphique
Select Case TSCBoxGenreGraph.SelectedItem
'Ajustement des propriétés du graphique
Case Is = "Air"
Chart1.Series("Prix").ChartType = SeriesChartType.Area
'Couleur du graphique
Chart1.ChartAreas(0).BackColor = My.Settings.CouleurFond
Chart1.ChartAreas(0).AxisX.MajorGrid.LineColor = My.Settings.CouleurAxe
Chart1.ChartAreas(0).AxisY.MajorGrid.LineColor = My.Settings.CouleurAxe
'Chart1.ChartAreas(0).AxisX.Crossing = Data.Rows.Count
'Chart1.ChartAreas(0).AxisY.IsMarksNextToAxis = True
Chart1.Series("Prix").Color = Color.FromArgb(128, Color.Aqua)
Chart1.Series("Prix").BackSecondaryColor = Color.FromArgb(128, Color.Yellow)
Chart1.Series("Prix").BackGradientStyle = GradientStyle.TopBottom
Chart1.Series("Prix").BorderColor = My.Settings.CouleurLigne1
Chart1.Series("Prix").BorderWidth = 4
Case Is = "Ligne"
Chart1.Series("Prix").ChartType = SeriesChartType.Line
Chart1.ChartAreas(0).BackColor = My.Settings.CouleurFond1
Chart1.ChartAreas(0).AxisX.MajorGrid.LineColor = My.Settings.CouleurAxe
Chart1.ChartAreas(0).AxisY.MajorGrid.LineColor = My.Settings.CouleurAxe
'Chart1.ChartAreas(0).AxisX.Crossing = Data.Rows.Count
Chart1.Series("Prix").BorderColor = My.Settings.CouleurLigne1
Chart1.Series("Prix").BorderWidth = 4
End Select
'Chargement du graphique
Dim Prix As Double = 0
Dim DaGra As Date = Nothing
Dim HMax As Double = 0
Dim BMax As Double = 0
Dim EcartHB As Double = 0
Dim Serie1 As New Series
Serie1.Name = "Prix"
Serie1.ChartArea = "ChartArea1"
For y As Integer = 0 To Data.Rows.Count - 1
DaGra = CDate(Data.Rows(y).Item(0)).ToShortDateString
Prix = Data.Rows(y).Item(9)
If y = 0 Then
HMax = Prix
BMax = Prix
End If
If Prix > HMax Then
HMax = Prix
End If
If Prix < BMax Then
BMax = Prix
End If
Chart1.Series("Prix").XValueType = ChartValueType.DateTime
Chart1.Series("Prix").Points.AddXY(CDate(DaGra).ToShortDateString, Prix)
Next
'Ajustement de l'axe du prix
'-----------------------------
EcartHB = HMax - BMax
If EcartHB > 0.12 Then
EcartHB = EcartHB / 6
End If
Select Case EcartHB
Case 0 To 0.2
'Console.WriteLine(EcartHB.ToString & " " & 0.2)
EcartHB = 0.02
Case 0.21 To 0.5
'Console.WriteLine(EcartHB.ToString & " " & 0.5)
EcartHB = 0.5
Case 0.51 To 1
'Console.WriteLine(EcartHB.ToString & " " & 1)
EcartHB = 1
Case 1.01 To 5
'Console.WriteLine(EcartHB.ToString & " " & 5)
EcartHB = 5
Case 5.01 To 10
'Console.WriteLine(EcartHB.ToString & " " & 5)
EcartHB = 10
Case Is > 10.01
'Console.WriteLine(EcartHB.ToString & " " & 10)
EcartHB = 20
End Select
Dim FloorGr As Double
If BMax < EcartHB Then
FloorGr = 0
Else
Dim Intnbr1 As Integer = System.Math.Floor(BMax / EcartHB)
FloorGr = Intnbr1 * EcartHB
End If
'---------------------------------
'Ajustement de l'Axe de la date
'???????
Chart1.ChartAreas(0).AxisY.Interval = EcartHB.ToString("0.00")
Chart1.ChartAreas(0).AxisY.Minimum = FloorGr.ToString("0.00")
End Sub |
Partager