- Public Sub MultiGraphicDrawing(CourbePlacement As String)
- Dim UBval As Integer: UBval = UBound(CotationsValues) - 1
- Dim i As Integer
- Dim StartC As Integer
- Dim j As Byte: j = 1
- Dim MyRowCount As Byte
- Dim YearAverage As Double
- Dim ValTemp As Double
- Dim MyPlacement As clsPlacement
-
- frmMain.MSChart1.AllowSelections = False ' Interdit la sélection dans le graphe
- frmMain.lstValues.Clear
-
- If ActionInfos.CotationsNumber <= 52 Then
- StartC = 1: MyRowCount = ActionInfos.CotationsNumber
- Else
- StartC = ActionInfos.CotationsNumber - 52: MyRowCount = 53
- End If
-
- '********************************************************************************
- ' Choix de la courbe à afficher
- '********************************************************************************
-
- For Each MyPlacement In ActionInfos
- If CourbePlacement = MyPlacement.NamePlacement Then
- ValTemp = Val(MyPlacement.PlacementValue)
- Exit For
- Else
- ValTemp = 1
- End If
- Next MyPlacement
-
- With frmMain.MSChart1
- .chartType = VtChChartType2dLine ' type de graphe (ici en ligne)
- .ColumnCount = 1 ' nombre de ligne
- .RowCount = MyRowCount ' nombre de semaine
-
- For i = StartC To ActionInfos.CotationsNumber
- .Row = j
- .Column = 1
- .RowLabel = CotationsDates(i) ' les dates
- .Data = MyCDbl(CotationsValues(i)) * ValTemp ' les valeurs
- YearAverage = YearAverage + .Data ' cumul des valeurs pour calculer la moyenne annuelle
- j = j + 1
-
- ' incrémentation des valeurs dans la liste de droite dans la form principale
- If frmMain.lstPlacements.Text <> ActionInfos.NameAction Then
- frmMain.lstValues.AddItem CotationsDates(i) & vbTab & .Data
- End If
- Next i
- End With
-
- Set MyPlacement = Nothing
-
- frmMain.ucAverageAction2.Caption = "Moyenne du placement (12 derniers mois) : " & CStr(Format(YearAverage / 53, "#0.00"))
-
- ' Pour que le curseur soit différent lorsque la souris passe sur le graphe
- frmMain.MSChart1.DoSetCursor = True
- frmMain.MSChart1.MousePointer = VtMousePointerCross
-
- '********************************************************************************
- ' Paramètres de la légende
- '********************************************************************************
-
- frmMain.MSChart1.ShowLegend = True
-
- ' Texte de la légende
- With frmMain.MSChart1.Plot.SeriesCollection(1)
- .LegendText = "Valeur de " & CourbePlacement
- End With
-
- With frmMain.MSChart1.Legend
- .Location.LocationType = VtChLocationTypeRight ' La légende sera au-dessus
- .TextLayout.HorzAlignment = VtVerticalAlignmentCenter ' Alignement centré
- .VtFont.VtColor.Set 255, 255, 0 ' Texte jaune.
- .Backdrop.Fill.Style = VtFillStyleBrush ' Style de fond
- .Backdrop.Fill.Brush.Style = VtBrushStyleHatched ' Style de remplissage
- .Backdrop.Fill.Brush.FillColor.Set 159, 0, 255 ' Couleur de remplissage du fond de la
- End With ' légende
-
-
- '********************************************************************************
- ' Titre et mise en forme
- '********************************************************************************
-
- frmMain.MSChart1.TitleText = "Courbe de suivi d'action sur les 50 dernières valeurs"
- With frmMain.MSChart1.Title.VtFont
- .Name = "Comic Sans MS"
- .Size = 15
- .Effect = VtFontEffectUnderline
- End With
-
- ' Titre pour l'axe des Y côté gauche
- With frmMain.MSChart1.Plot.Axis(1, 1)
- .AxisTitle.VtFont.Size = 14
- .AxisTitle.Visible = True
- .AxisTitle.Text = "Valeurs"
- End With
-
- ' Virer les nombres côté droit
- frmMain.MSChart1.Plot.Axis(2, 1).AxisScale.Hide = True
-
- ' Titre pour l'axe des X côté bas
- With frmMain.MSChart1.Plot.Axis(0, 1)
- .AxisTitle.VtFont.Size = 14
- .AxisTitle.Visible = True
- .AxisTitle.Text = "Date"
- End With
-
-
- '********************************************************************************
- ' Couleurs et traits du graphe
- '********************************************************************************
-
- ' Changer la couleur du graphe
- With frmMain.MSChart1.Plot.SeriesCollection(1)
- .DataPoints(-1).Brush.FillColor.Set 255, 0, 0 ' couleur RGB
- End With
-
- ' Changer la couleur du fond du graphe
- With frmMain.MSChart1.Backdrop.Fill
- .Style = VtFillStyleBrush
- .Brush.FillColor.Set 255, 255, 255 'fond blanc
- End With
-
- ' Placer une ligne colorée entre les éléments de la légende de l'axe Y ainsi que la ligne 0
- With frmMain.MSChart1.Plot.Axis(VtChAxisIdX, 1)
- .Pen.VtColor.Set 237, 44, 78
- End With
- End Sub
Public Sub MultiGraphicDrawing(CourbePlacement As String)
Dim UBval As Integer: UBval = UBound(CotationsValues) - 1
Dim i As Integer
Dim StartC As Integer
Dim j As Byte: j = 1
Dim MyRowCount As Byte
Dim YearAverage As Double
Dim ValTemp As Double
Dim MyPlacement As clsPlacement
frmMain.MSChart1.AllowSelections = False ' Interdit la sélection dans le graphe
frmMain.lstValues.Clear
If ActionInfos.CotationsNumber <= 52 Then
StartC = 1: MyRowCount = ActionInfos.CotationsNumber
Else
StartC = ActionInfos.CotationsNumber - 52: MyRowCount = 53
End If
'********************************************************************************
' Choix de la courbe à afficher
'********************************************************************************
For Each MyPlacement In ActionInfos
If CourbePlacement = MyPlacement.NamePlacement Then
ValTemp = Val(MyPlacement.PlacementValue)
Exit For
Else
ValTemp = 1
End If
Next MyPlacement
With frmMain.MSChart1
.chartType = VtChChartType2dLine ' type de graphe (ici en ligne)
.ColumnCount = 1 ' nombre de ligne
.RowCount = MyRowCount ' nombre de semaine
For i = StartC To ActionInfos.CotationsNumber
.Row = j
.Column = 1
.RowLabel = CotationsDates(i) ' les dates
.Data = MyCDbl(CotationsValues(i)) * ValTemp ' les valeurs
YearAverage = YearAverage + .Data ' cumul des valeurs pour calculer la moyenne annuelle
j = j + 1
' incrémentation des valeurs dans la liste de droite dans la form principale
If frmMain.lstPlacements.Text <> ActionInfos.NameAction Then
frmMain.lstValues.AddItem CotationsDates(i) & vbTab & .Data
End If
Next i
End With
Set MyPlacement = Nothing
frmMain.ucAverageAction2.Caption = "Moyenne du placement (12 derniers mois) : " & CStr(Format(YearAverage / 53, "#0.00"))
' Pour que le curseur soit différent lorsque la souris passe sur le graphe
frmMain.MSChart1.DoSetCursor = True
frmMain.MSChart1.MousePointer = VtMousePointerCross
'********************************************************************************
' Paramètres de la légende
'********************************************************************************
frmMain.MSChart1.ShowLegend = True
' Texte de la légende
With frmMain.MSChart1.Plot.SeriesCollection(1)
.LegendText = "Valeur de " & CourbePlacement
End With
With frmMain.MSChart1.Legend
.Location.LocationType = VtChLocationTypeRight ' La légende sera au-dessus
.TextLayout.HorzAlignment = VtVerticalAlignmentCenter ' Alignement centré
.VtFont.VtColor.Set 255, 255, 0 ' Texte jaune.
.Backdrop.Fill.Style = VtFillStyleBrush ' Style de fond
.Backdrop.Fill.Brush.Style = VtBrushStyleHatched ' Style de remplissage
.Backdrop.Fill.Brush.FillColor.Set 159, 0, 255 ' Couleur de remplissage du fond de la
End With ' légende
'********************************************************************************
' Titre et mise en forme
'********************************************************************************
frmMain.MSChart1.TitleText = "Courbe de suivi d'action sur les 50 dernières valeurs"
With frmMain.MSChart1.Title.VtFont
.Name = "Comic Sans MS"
.Size = 15
.Effect = VtFontEffectUnderline
End With
' Titre pour l'axe des Y côté gauche
With frmMain.MSChart1.Plot.Axis(1, 1)
.AxisTitle.VtFont.Size = 14
.AxisTitle.Visible = True
.AxisTitle.Text = "Valeurs"
End With
' Virer les nombres côté droit
frmMain.MSChart1.Plot.Axis(2, 1).AxisScale.Hide = True
' Titre pour l'axe des X côté bas
With frmMain.MSChart1.Plot.Axis(0, 1)
.AxisTitle.VtFont.Size = 14
.AxisTitle.Visible = True
.AxisTitle.Text = "Date"
End With
'********************************************************************************
' Couleurs et traits du graphe
'********************************************************************************
' Changer la couleur du graphe
With frmMain.MSChart1.Plot.SeriesCollection(1)
.DataPoints(-1).Brush.FillColor.Set 255, 0, 0 ' couleur RGB
End With
' Changer la couleur du fond du graphe
With frmMain.MSChart1.Backdrop.Fill
.Style = VtFillStyleBrush
.Brush.FillColor.Set 255, 255, 255 'fond blanc
End With
' Placer une ligne colorée entre les éléments de la légende de l'axe Y ainsi que la ligne 0
With frmMain.MSChart1.Plot.Axis(VtChAxisIdX, 1)
.Pen.VtColor.Set 237, 44, 78
End With
End Sub