Bonjour,

J’ai développé un programme qui trace une fonction sinus avec un Chart (VB Visual studio 2017)
Je fixe maximun et minumun avec les instruction suivantes:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
 
        Chart1.ChartAreas(0).AxisX.Maximum = 20                     ' 20 ms
        Chart1.ChartAreas(0).AxisX.Minimum = 0
        Chart1.ChartAreas(0).AxisY.Maximum = 1.5                    ' 1.5 V
        Chart1.ChartAreas(0).AxisY.Minimum = -1.5
Mais le plot est entre pour X (-1,19) et pour Y (-2,+2).
Donc les instructions ci dessus ne fonctionnent pas.

J'ai beau cherché, je ne trouve pas d'autre méthode pour fixer les axes.
Je n'ai pas trouvé de propriété type "Autoscaling", qui neutraliserait ces instructions.

Quelqu'un a t-il déjà rencontrer ce problème ?

Mon code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
Public Const nb_samples_max As Integer = 4000
    Public xch1(nb_samples_max) As Single
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim chartArea1 As New ChartArea()                       ' Create an Chart Area
        Dim sigch1 As String = "Signal ch1"                     ' signal
 
        chartArea1.Name = sigch1
        Chart1.Legends.Clear()
        Chart1.ChartAreas.Add(chartArea1)
        Chart1.ChartAreas(chartArea1.Name).BackColor = Color.LightGray
        Chart1.Series.Add(sigch1)                               ' display signal
        Chart1.Series(sigch1).ChartArea = chartArea1.Name       'serie is displayed in chartArea1
        Chart1.Series(sigch1).Color = Color.Red
        Chart1.Series(sigch1).ChartType = SeriesChartType.FastLine       ' draw mode line
        Chart1.ChartAreas(0).AxisX.Maximum = 20                     ' 20 ms
        Chart1.ChartAreas(0).AxisX.Minimum = 0
        Chart1.ChartAreas(0).AxisY.Maximum = 1.5                    ' 1.5 V
        Chart1.ChartAreas(0).AxisY.Minimum = -1.5
        Chart1.ChartAreas(0).AxisY.Title = "CH1 SA"
        Chart1.ChartAreas(0).AxisX.Title = "Time (ms)"
        Chart1.Series(0).XValueType = ChartValueType.Int32
        Chart1.Series(0).YValueType = ChartValueType.Single
        Chart1.ChartAreas(0).Position = New ElementPosition(0, 0, 500, 200)
        Chart1.ChartAreas(0).BackColor = Color.LightGray
 
        Dim t As Single
        Dim nsamples = 4000
        Dim acq_per_local As Single = 0.000005
        For i = 0 To nsamples
            t = 1000 * i * acq_per_local
            xch1(i) = 1.5 * Sin(2 * Math.PI * t * 0.75)
            Chart1.Series(0).Points.AddXY(t, xch1(i))
        Next
 
    End Sub
Le plot:
Nom : Plot.PNG
Affichages : 941
Taille : 19,9 Ko