I tried to use Annotation but I am not able to plot Annotation in the middle of the points.
It works fine when I run the cod eand view the output but when I Export that image to jpeg the points are not on the same Location.
Also I have attached both the screenshot.
Following is Code whcih I am using for Graph generation :
Private Sub Command1_Click()
With TChart1.Export.asGIF
.Width = 850
.Height = 300
.SaveToFile ("C:\Test.gif")
End With
End Sub
Private Sub Form_Load()
TChart1.ClearChart
With TChart1
.AddSeries (scLine)
.Series(0).Clear
'.Series(0).Marks.Visible = True
.Panel.Color = vbWhite
.Panel.BevelOuter = bvNone
.Panel.Gradient.Visible = False
.Header.Text.Clear
'.Header.Text.Add m_sHeader
.Header.Font.Color = vbRed
.Header.Font.Bold = False
.Header.Font.Name = "Verdana"
.Header.Font.Size = 8
.Tools.Clear
.Footer.Text.Clear
.Footer.Text.Add m_sFooter
.Legend.Visible = False
.Legend.TextStyle = ltsLeftValue
.Legend.Font.Color = vbBlack
.Legend.Font.Name = "Verdana"
.Legend.Font.Size = 8
.Legend.ShapeStyle = fosRoundRectangle
.Legend.ShadowSize = 0
.Walls.Visible = False
.Aspect.View3D = False
.Axis.Left.Title.Caption = "Bps from Arrival Price"
.Axis.Left.Title.Font.Bold = True
.Axis.Left.Title.Font.Name = "Verdana"
.Axis.Left.Title.Font.Size = 10
.Axis.Left.Title.Font.Color = vbBlack
.Axis.Left.AxisPen.Color = RGB(51, 51, 51)
.Axis.Left.labels.Font.Color = vbBlack
.Axis.Left.labels.Font.Name = "Verdana"
.Axis.Left.labels.Font.Size = 8
.Axis.Left.labels.Font.Bold = False
.Axis.Left.GridPen.Visible = False
.Axis.Bottom.AxisPen.Color = RGB(77, 77, 77)
.Axis.Bottom.labels.Font.Name = "Verdana"
.Axis.Bottom.labels.Font.Size = 8
.Axis.Bottom.labels.Font.Color = vbWhite
.Axis.Bottom.labels.OnAxis = False
.Axis.Bottom.Title.Caption = m_sXAxisTitle
.Axis.Bottom.Title.Font.Bold = False
.Axis.Bottom.Title.Font.Color = vbBlack
.Axis.Bottom.GridPen.Visible = True
.Axis.Bottom.GridPen.Style = psSolid
.Axis.Bottom.GridPen.Color = RGB(143, 143, 143)
.Axis.Right.Visible = True
.Axis.Right.AxisPen.Color = RGB(77, 77, 77)
.Axis.Right.labels.Font.Name = "Verdana"
.Axis.Right.labels.Font.Size = 8
.Axis.Right.Title.Caption = m_sXAxisTitle
.Axis.Right.Title.Font.Bold = False
.Axis.Right.Title.Font.Color = vbBlack
.Axis.Right.GridPen.Visible = False
.Axis.Top.Visible = False
.Axis.Top.AxisPen.Color = RGB(77, 77, 77)
.Axis.Top.labels.Visible = False
End With
'TChart1.Aspect.View3D = False
'TChart1.ClearChart
TChart1.AddSeries scLine
TChart1.Series(0).asLine.Pointer.Visible = True
m_lMinLeftAxis = 0
m_lMaxLeftAxis = 0
Dim Point1, Point2, Point3, Point4, Point4TPlusOne, Point4TPlusFive
Dim zeroCorrectingFigure, tmpNumber
tmpNumber = 0
zeroCorrectingFigure = 0
With TChart1
Dim points, labels, i, calcMethodType, CalcCol
.Series(0).asLine.LinePen.Width = 1
.Series(0).asLine.LinePen.Style = psSolid
.Series(0).asLine.LinePen.EndStyle = esFlat
.Axis.Bottom.labels.Visible = True
.Axis.Bottom.labels.Font.Name = "Arial"
.Axis.Bottom.labels.Font.Size = 8
.Axis.Bottom.labels.OnAxis = True
.Axis.Bottom.labels.Font.Color = vbBlack
.Axis.Bottom.labels.Style = talText
.Axis.Bottom.MinorTicks.Visible = False
Point1 = -81.11
Point2 = -90.45
Point3 = 23.9
Point4 = 57.87
Point4TPlusOne = 22.88
Point4TPlusFive = -15.23
.Series(0).Add Round(Point1, 2), "P1", RGB(0, 64, 128)
If m_lMinLeftAxis > Point1 Then m_lMinLeftAxis = Point1
If m_lMaxLeftAxis < Point1 Then m_lMaxLeftAxis = Point1
m_lMaxBottomAxis = m_lMaxBottomAxis + 1
.Series(0).Add Round(Point2, 2), "P2", RGB(0, 64, 128)
If m_lMinLeftAxis > Point2 Then m_lMinLeftAxis = Point2
If m_lMaxLeftAxis < Point2 Then m_lMaxLeftAxis = Point2
m_lMaxBottomAxis = m_lMaxBottomAxis + 1
.Series(0).Add 0, "P3", RGB(0, 64, 128)
m_lMaxBottomAxis = m_lMaxBottomAxis + 1
.Series(0).Add Round(Point3, 2), "P4", RGB(0, 64, 128)
If m_lMinLeftAxis > Point3 Then m_lMinLeftAxis = Point3
If m_lMaxLeftAxis < Point3 Then m_lMaxLeftAxis = Point3
m_lMaxBottomAxis = m_lMaxBottomAxis + 1
.Series(0).Add Round(Point4, 2), "P5", RGB(0, 64, 128)
If m_lMinLeftAxis > Point4 Then m_lMinLeftAxis = Point4
If m_lMaxLeftAxis < Point4 Then m_lMaxLeftAxis = Point4
m_lMaxBottomAxis = m_lMaxBottomAxis + 1
.Series(0).Add Round(Point4TPlusOne, 2), "P6", RGB(0, 64, 128)
If m_lMinLeftAxis > Point4TPlusOne Then m_lMinLeftAxis = Point4TPlusOne
If m_lMaxLeftAxis < Point4TPlusOne Then m_lMaxLeftAxis = Point4TPlusOne
m_lMaxBottomAxis = m_lMaxBottomAxis + 1
.Series(0).Add Round(Point4TPlusFive, 2), "P7", RGB(0, 64, 128)
If m_lMinLeftAxis > Point4TPlusFive Then m_lMinLeftAxis = Point4TPlusFive
If m_lMaxLeftAxis < Point4TPlusFive Then m_lMaxLeftAxis = Point4TPlusFive
m_lMaxBottomAxis = m_lMaxBottomAxis + 1
.Series(0).VerticalAxis = aBothVertAxis
.Series(0).asLine.Pointer.Visible = True
.Series(0).asLine.Pointer.Style = psCircle
With .Axis.Left
.SetMinMax m_lMinLeftAxis, m_lMaxLeftAxis + 20
If (((m_lMaxLeftAxis + 20) - (m_lMinLeftAxis - 5)) / 6) > 0 Then
.Increment = Int(((m_lMaxLeftAxis + 20) - (m_lMinLeftAxis - 5)) / 6)
End If
End With
With .Axis.Bottom
.labels.Visible = True
.labels.OnAxis = True
.SetMinMax 0, m_lMaxBottomAxis
End With
With .Axis.Right
.SetMinMax m_lMinLeftAxis, m_lMaxLeftAxis + 20
If (((m_lMaxLeftAxis + 20) - (m_lMinLeftAxis - 5)) / 6) > 0 Then
.Increment = Int(((m_lMaxLeftAxis + 20) - (m_lMinLeftAxis - 5)) / 6)
End If
End With
End With
TChart1.Environment.InternalRepaint
For i = 0 To TChart1.Series(0).Count - 2
TChart1.Tools.Add tcAnnotate
With TChart1.Tools.Items(i).asAnnotation
.Text = "Test"
.Shape.Left = ((TChart1.Series(0).CalcXPos(i + 1) - TChart1.Series(0).CalcXPos(i)) / 2) + TChart1.Series(0).CalcXPos(i) - (TChart1.Canvas.TextWidth(.Text) / 2)
.Shape.Top = ((TChart1.Series(0).CalcYPos(i + 1) - TChart1.Series(0).CalcYPos(i)) / 2) + TChart1.Series(0).CalcYPos(i) - (TChart1.Canvas.TextHeight(.Text) / 2)
.Shape.Transparent = False
End With
Next i
End Sub
- LineGraphExport.gif (22.39 KiB) Viewed 14317 times
- LineGraph.JPG (28.38 KiB) Viewed 14336 times