V
Vergassivellaunus
Guest
In this example i want to position the label "1" exactely at the beginnig of chart, but the position is not correct, it's always a little more; you need to add a chart and a label to form:
Imports System.Windows.Forms.DataVisualization.Charting
Public Class Form1
Dim startgraph, graphend As Integer
Dim x, y As Single
Dim posiz As PointF
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Label1.Left = Chart1.Left
End Sub
Private Sub Chart1_PostPaint(sender As Object, e As ChartPaintEventArgs) Handles Chart1.PostPaint
x = CSng(e.ChartGraphics.GetPositionFromAxis(Chart1.ChartAreas(0).Name, AxisName.X, Chart1.ChartAreas(0).AxisX.Minimum))
y = CSng(e.ChartGraphics.GetPositionFromAxis(Chart1.ChartAreas(0).Name, AxisName.Y, 0))
posiz = New PointF(x, y)
posiz = e.ChartGraphics.GetAbsolutePoint(posiz)
startgraph = posiz.X
x = CSng(e.ChartGraphics.GetPositionFromAxis(Chart1.ChartAreas(0).Name, AxisName.X, Chart1.ChartAreas(0).AxisX.Maximum))
y = CSng(e.ChartGraphics.GetPositionFromAxis(Chart1.ChartAreas(0).Name, AxisName.Y, 0))
posiz = New PointF(x, y)
posiz = e.ChartGraphics.GetAbsolutePoint(posiz)
graphend = posiz.X
End Sub
End Class
The process for determining the position may be wrong.
Continue reading...
Imports System.Windows.Forms.DataVisualization.Charting
Public Class Form1
Dim startgraph, graphend As Integer
Dim x, y As Single
Dim posiz As PointF
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Label1.Left = Chart1.Left
End Sub
Private Sub Chart1_PostPaint(sender As Object, e As ChartPaintEventArgs) Handles Chart1.PostPaint
x = CSng(e.ChartGraphics.GetPositionFromAxis(Chart1.ChartAreas(0).Name, AxisName.X, Chart1.ChartAreas(0).AxisX.Minimum))
y = CSng(e.ChartGraphics.GetPositionFromAxis(Chart1.ChartAreas(0).Name, AxisName.Y, 0))
posiz = New PointF(x, y)
posiz = e.ChartGraphics.GetAbsolutePoint(posiz)
startgraph = posiz.X
x = CSng(e.ChartGraphics.GetPositionFromAxis(Chart1.ChartAreas(0).Name, AxisName.X, Chart1.ChartAreas(0).AxisX.Maximum))
y = CSng(e.ChartGraphics.GetPositionFromAxis(Chart1.ChartAreas(0).Name, AxisName.Y, 0))
posiz = New PointF(x, y)
posiz = e.ChartGraphics.GetAbsolutePoint(posiz)
graphend = posiz.X
End Sub
End Class
The process for determining the position may be wrong.
Continue reading...