Jump to content
Software FX Community

Realtime Line Chart


User (Legacy)
 Share

Recommended Posts

Hi,

I've been using ChartFX (latest service pack with financial extension) for

some time now and recently have had to create a chart that displays 2

real-time lines... I've tried many ways to do this, and found that the best

way is to:

(First Setup The Chart)

################################################

Private Sub SetupLine()

'

Dim dblBid As Double

Dim dblStep As Double

'

With ChartFX

'

.Gallery = LINES

'

.MaxValues = 10000

.OpenDataEx COD_VALUES Or COD_REMOVE, 2, 30

.CloseData COD_VALUES

.TypeMask = ChartFX.TypeMask Or CT_EVENSPACING

.RealTimeStyle = CRT_NOWAITARROW

.TypeEx = ChartFX.TypeEx Or CTE_NOLEGINVALIDATE

.Axis(AXIS_X).AutoScale = False

.Axis(AXIS_X).Min = 0

.Axis(AXIS_X).Max = 30

.Axis(AXIS_X).STEP = 5

.Axis(AXIS_X).MinorStep = 1

.Series(0).MarkerShape = MK_CIRCLE

.Series(0).MarkerSize = 1

.Series(0).PointLabels = False

.Series(1).MarkerShape = MK_CIRCLE

.Series(1).MarkerSize = 1

.Series(1).PointLabels = False

'.RGBFont(CHART_VALUESFT) = RGB(255, 255, 255)

'

.Axis(AXIS_Y).Decimals = 4

.Axis(AXIS_Y).Notify = False

'

dblBid = RateGrid(CurrencyPairs.GBP_USD, RateGridMap.Bid)

.Axis(AXIS_Y).Min = dblBid - 0.001

.Axis(AXIS_Y).Max = dblBid + 0.001

dblStep = Round(((dblBid + 0.001) - (dblBid - 0.001)) / 10, 4)

.Axis(AXIS_Y).STEP = dblStep

.Axis(AXIS_Y).MinorStep = Round(dblStep / 2, 4)

'

.Axis(AXIS_X).SetScrollView 0, 30

.Scrollable = True

'

lngOffset = 0

.Commands(310).Enabled = True

'

.Axis(AXIS_X).TitleColor = &H8F5C00

.RGBBk = &H8F5C00

.Axis(AXIS_X).TextColor = vbWhite

.Axis(AXIS_Y).TextColor = vbWhite

.Axis(AXIS_X2).Title = ""

'

End With

'

End Sub

(Now Call this everytime there is an update)

######################################################################

Public Function AddTick()

'

On Error GoTo Err_Init

'

Dim dblBid As Double

Dim dblAsk As Double

Dim strDate As String

'

dblBid = RateGrid(CurrencyPairs.GBP_USD, RateGridMap.Bid)

dblAsk = RateGrid(CurrencyPairs.GBP_USD, RateGridMap.Ask)

strDate = RateGrid(CurrencyPairs.GBP_USD, RateGridMap.CurLastUpdate)

'

If dblBid > ChartFX.Axis(AXIS_Y).Max Then

'

ChartFX.Axis(AXIS_Y).Max = dblBid

'

ElseIf dblBid < ChartFX.Axis(AXIS_Y).Min Then

'

ChartFX.Axis(AXIS_Y).Min = dblBid

'

End If

'

If dblAsk > ChartFX.Axis(AXIS_Y).Max Then

'

ChartFX.Axis(AXIS_Y).Max = dblAsk

'

ElseIf dblAsk < ChartFX.Axis(AXIS_Y).Min Then

'

ChartFX.Axis(AXIS_Y).Min = dblAsk

'

End If

'

If lngOffset = 29 Or 30 Or 31 Then

'

ChartFX.Scroll CHART_ML(7, 0), 0

'

End If

'

Select Case m_TickOnlyChange

'

Case False

'

If lngOffset < 30 Then

'

ChartFX.OpenDataEx COD_VALUES, COD_UNCHANGE, COD_UNCHANGE

'

ChartFX.ValueEx(0, lngOffset) = dblBid

ChartFX.ValueEx(1, lngOffset) = dblAsk

'

ChartFX.CloseData COD_VALUES Or COD_SMOOTH

'

Else

'

ChartFX.OpenDataEx COD_VALUES Or COD_ADDPOINTS, 2, 1

'

ChartFX.ValueEx(0, 0) = dblBid

ChartFX.ValueEx(1, 0) = dblAsk

'

ChartFX.CloseData COD_VALUES Or COD_REALTIMESCROLL

'

End If

'

ChartFX.Axis(AXIS_X).Label(lngOffset) = strDate

lngOffset = lngOffset + 1

'

Case True

'

If ChartFX.Value(dblBid) <> ChartFX.Series(0).Yvalue(lngOffset)

Then

'

If lngOffset < 30 Then

'

ChartFX.OpenDataEx COD_VALUES, COD_UNCHANGE,

COD_UNCHANGE

'

ChartFX.ValueEx(0, lngOffset) = dblBid

ChartFX.ValueEx(1, lngOffset) = dblAsk

'

ChartFX.CloseData COD_VALUES Or COD_SMOOTH

'

Else

'

ChartFX.OpenDataEx COD_VALUES Or COD_ADDPOINTS, 2, 1

'

ChartFX.ValueEx(0, 0) = dblBid

ChartFX.ValueEx(1, 0) = dblAsk

'

ChartFX.CloseData COD_VALUES Or COD_REALTIMESCROLL

'

End If

'

ChartFX.Axis(AXIS_X).Label(lngOffset) = strDate

lngOffset = lngOffset + 1

'

End If

'

End Select

'

Exit Function

Err_Init:

'

HandleError CurrentModule, "AddTick", Err.Number, Err.Description

'

End Function

You'll notice I set a maxpoints of 10000, and a view of 30 points... When

adding the first 30, I simply modify the existing points; however, when I

get beyond 30 I use addpoints with COD_REALTIMESCROLL to keep it moving. The

problem is my manager doesn't want to see that scroll bar on the bottom, he

wants to see just a chart and axis labels. I have tried many ways of doing

this and all have produced results, but when I use COD_SCROLLLEGEND, I get a

loop rather than the new values I assign.

For Now I am using a workaround: I'm just Resizing the chart so that the

scrollbar is out of the form... I would like to do this the proper way

though, and any insight would be greatly appreciated.

Chase Gale

Quantrex

Link to comment
Share on other sites

There is a style called CS_SCROLLBARS that you can turn off to hide them.

You can do it as follows:

ChartFX1.Style = ChartFX1.Style and not CS_SCROLLBARS

This hides the scrollbar while keeping the scroll functionality (you can

still scroll the chart through code).

--

FP

Software FX Support

"Chase Gale" <cgale@fxsol.com> wrote in message

news:hPYpQqUoCHA.3108@webserver1.softwarefx.com...

> Hi,

>

> I've been using ChartFX (latest service pack with financial extension) for

> some time now and recently have had to create a chart that displays 2

> real-time lines... I've tried many ways to do this, and found that the

best

> way is to:

>

> (First Setup The Chart)

> ################################################

> Private Sub SetupLine()

> '

> Dim dblBid As Double

> Dim dblStep As Double

> '

> With ChartFX

> '

> .Gallery = LINES

> '

> .MaxValues = 10000

> .OpenDataEx COD_VALUES Or COD_REMOVE, 2, 30

> .CloseData COD_VALUES

> .TypeMask = ChartFX.TypeMask Or CT_EVENSPACING

> .RealTimeStyle = CRT_NOWAITARROW

> .TypeEx = ChartFX.TypeEx Or CTE_NOLEGINVALIDATE

> .Axis(AXIS_X).AutoScale = False

> .Axis(AXIS_X).Min = 0

> .Axis(AXIS_X).Max = 30

> .Axis(AXIS_X).STEP = 5

> .Axis(AXIS_X).MinorStep = 1

> .Series(0).MarkerShape = MK_CIRCLE

> .Series(0).MarkerSize = 1

> .Series(0).PointLabels = False

> .Series(1).MarkerShape = MK_CIRCLE

> .Series(1).MarkerSize = 1

> .Series(1).PointLabels = False

> '.RGBFont(CHART_VALUESFT) = RGB(255, 255, 255)

> '

> .Axis(AXIS_Y).Decimals = 4

> .Axis(AXIS_Y).Notify = False

> '

> dblBid = RateGrid(CurrencyPairs.GBP_USD, RateGridMap.Bid)

> .Axis(AXIS_Y).Min = dblBid - 0.001

> .Axis(AXIS_Y).Max = dblBid + 0.001

> dblStep = Round(((dblBid + 0.001) - (dblBid - 0.001)) / 10, 4)

> .Axis(AXIS_Y).STEP = dblStep

> .Axis(AXIS_Y).MinorStep = Round(dblStep / 2, 4)

> '

> .Axis(AXIS_X).SetScrollView 0, 30

> .Scrollable = True

> '

> lngOffset = 0

> .Commands(310).Enabled = True

> '

> .Axis(AXIS_X).TitleColor = &H8F5C00

> .RGBBk = &H8F5C00

> .Axis(AXIS_X).TextColor = vbWhite

> .Axis(AXIS_Y).TextColor = vbWhite

> .Axis(AXIS_X2).Title = ""

> '

> End With

> '

> End Sub

>

> (Now Call this everytime there is an update)

> ######################################################################

> Public Function AddTick()

> '

> On Error GoTo Err_Init

> '

> Dim dblBid As Double

> Dim dblAsk As Double

> Dim strDate As String

> '

> dblBid = RateGrid(CurrencyPairs.GBP_USD, RateGridMap.Bid)

> dblAsk = RateGrid(CurrencyPairs.GBP_USD, RateGridMap.Ask)

> strDate = RateGrid(CurrencyPairs.GBP_USD, RateGridMap.CurLastUpdate)

> '

> If dblBid > ChartFX.Axis(AXIS_Y).Max Then

> '

> ChartFX.Axis(AXIS_Y).Max = dblBid

> '

> ElseIf dblBid < ChartFX.Axis(AXIS_Y).Min Then

> '

> ChartFX.Axis(AXIS_Y).Min = dblBid

> '

> End If

> '

> If dblAsk > ChartFX.Axis(AXIS_Y).Max Then

> '

> ChartFX.Axis(AXIS_Y).Max = dblAsk

> '

> ElseIf dblAsk < ChartFX.Axis(AXIS_Y).Min Then

> '

> ChartFX.Axis(AXIS_Y).Min = dblAsk

> '

> End If

> '

> If lngOffset = 29 Or 30 Or 31 Then

> '

> ChartFX.Scroll CHART_ML(7, 0), 0

> '

> End If

> '

> Select Case m_TickOnlyChange

> '

> Case False

> '

> If lngOffset < 30 Then

> '

> ChartFX.OpenDataEx COD_VALUES, COD_UNCHANGE, COD_UNCHANGE

> '

> ChartFX.ValueEx(0, lngOffset) = dblBid

> ChartFX.ValueEx(1, lngOffset) = dblAsk

> '

> ChartFX.CloseData COD_VALUES Or COD_SMOOTH

> '

> Else

> '

> ChartFX.OpenDataEx COD_VALUES Or COD_ADDPOINTS, 2, 1

> '

> ChartFX.ValueEx(0, 0) = dblBid

> ChartFX.ValueEx(1, 0) = dblAsk

> '

> ChartFX.CloseData COD_VALUES Or COD_REALTIMESCROLL

> '

> End If

> '

> ChartFX.Axis(AXIS_X).Label(lngOffset) = strDate

> lngOffset = lngOffset + 1

> '

> Case True

> '

> If ChartFX.Value(dblBid) <>

ChartFX.Series(0).Yvalue(lngOffset)

> Then

> '

> If lngOffset < 30 Then

> '

> ChartFX.OpenDataEx COD_VALUES, COD_UNCHANGE,

> COD_UNCHANGE

> '

> ChartFX.ValueEx(0, lngOffset) = dblBid

> ChartFX.ValueEx(1, lngOffset) = dblAsk

> '

> ChartFX.CloseData COD_VALUES Or COD_SMOOTH

> '

> Else

> '

> ChartFX.OpenDataEx COD_VALUES Or COD_ADDPOINTS, 2, 1

> '

> ChartFX.ValueEx(0, 0) = dblBid

> ChartFX.ValueEx(1, 0) = dblAsk

> '

> ChartFX.CloseData COD_VALUES Or COD_REALTIMESCROLL

> '

> End If

> '

> ChartFX.Axis(AXIS_X).Label(lngOffset) = strDate

> lngOffset = lngOffset + 1

> '

> End If

> '

> End Select

> '

> Exit Function

>

> Err_Init:

> '

> HandleError CurrentModule, "AddTick", Err.Number, Err.Description

> '

> End Function

>

>

>

> You'll notice I set a maxpoints of 10000, and a view of 30 points... When

> adding the first 30, I simply modify the existing points; however, when I

> get beyond 30 I use addpoints with COD_REALTIMESCROLL to keep it moving.

The

> problem is my manager doesn't want to see that scroll bar on the bottom,

he

> wants to see just a chart and axis labels. I have tried many ways of doing

> this and all have produced results, but when I use COD_SCROLLLEGEND, I get

a

> loop rather than the new values I assign.

>

> For Now I am using a workaround: I'm just Resizing the chart so that the

> scrollbar is out of the form... I would like to do this the proper way

> though, and any insight would be greatly appreciated.

>

> Chase Gale

> Quantrex

>

>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...