Page 1 of 1

add window bars to simple x-y chart?

Posted: Sun Nov 19, 2006 8:52 pm
by 9532946
Hi: I have a simple plot of x-y data. I want to add two vertical bars (making a window) a specific number of x-axis units apart. How can I do this?

This picture should show what I'm after.

Image

Posted: Mon Nov 20, 2006 9:14 am
by narcis
Hi Russ,

The easiest way to achieve that is using ColorBand or ColorLine tools.

add window bars to simple x-y chart (access violation)

Posted: Mon Nov 27, 2006 8:31 pm
by 9532946
Hi: I am having difficulty in figuring out how to draw two vertical bars on an x-y chart. I can't find much in the way of examples of ColorBand useage. Here is some code that I have attempted but it results in an access violation in "TeeChart7.ocx" as seen in the attached picture (with the code).

Image

Best Regards,
russ

Posted: Tue Nov 28, 2006 8:46 am
by narcis
Hi Russ,

The same code works fine here using v7.0.1.3, which is the latest version available at the client area, provided bottom axis, at least, ranges from 25 to 75. Otherwise the band is not visible.

Which TeeChart version are you using? If the problem persists could you please send us a simple example project we can run "as-is" to reproduce the problem here?

You can post your files at news://www.steema.net/steema.public.attachments newsgroup.

Thanks in advance.

add window bars to simple x-y chart?

Posted: Wed Nov 29, 2006 2:32 pm
by 9532946
I finally figured out what the problem was. The line of code ".Tools.Items(0).asColorband.Axis" made specific reference to tool 0 of the present set of tools for this particular chart. Well, the ColorBand tool wasn't my only tool so I was referencing the wrong tool by the "Items(0)" part.

Is there a way to reference the ColorBand tool without using the "Items(0)" method?

Thanks a bunch for your help. I have been very please with your software and support.

Regards,
russ

Posted: Wed Nov 29, 2006 3:41 pm
by narcis
Hi Russ,

Thank you very much. I'm glad to hear it works fine for you.

Regarding your question, at the snippet below you have 2 example on how to do that:

Code: Select all

Private Sub Form_Load()
    Dim ColorBandIndex As Integer
    Dim ColorBand As IColorBandTool
    
    TChart1.Series(0).FillSampleValues 100
    
    ColorBandIndex = TChart1.Tools.Add(tcColorband)
    
    With TChart1.Tools.Items(ColorBandIndex).asColorband
        .Axis = TChart1.Axis.Bottom
        .StartValue = 10
        .EndValue = 20
        .ResizeEnd = True
        .ResizeStart = True
    End With
    
    'or
    
    TChart1.Tools.Add tcColorband
    Set ColorBand = TChart1.Tools.Items(TChart1.Tools.Count - 1).asColorband
    
    With ColorBand
        .Axis = TChart1.Axis.Left
        .StartValue = 100
        .EndValue = 150
    End With
End Sub