how to 'draw' this on a chart...

TeeChart for ActiveX, COM and ASP
Post Reply
amueller
Newbie
Newbie
Posts: 30
Joined: Tue Jul 26, 2005 4:00 am

how to 'draw' this on a chart...

Post by amueller » Mon Oct 03, 2005 7:07 pm

Hello,

I have a chart, which I will have several lines on with real time data. I have no problem with that portion..

However, I would like to create an 'area' on the chart which will represent 'good' data. This 'area' should go from the left hand side of the chart to the right hand side of the chart.

For example... If the chart had a y-axis from 5.0 to 6.0 and an x-axis of 0.0 to 11.0.

The 'good area' should be a semi-transparent trapezoid which would go from (0,5.1) to (0,5.3) to (11,5.2) to (11,5.4) {represented in (x,y)}

Hope this makes sense..

Thanks!

Andrew

TTL
Newbie
Newbie
Posts: 36
Joined: Thu Aug 04, 2005 4:00 am

Post by TTL » Mon Oct 03, 2005 7:38 pm

Hello,

You can add Map series to your TeeChart. Then programmatically add a Polygon to that series. Something like the following:

Code: Select all

m_PolygonSeries = m_TeeChart.Series(0);
m_PolygonMapSeries = m_PolygonSeries.GetAsMap();
// Add a single polygon to the map series.
long lPolygonIdx = m_PolygonMapSeries.GetShapes().Add();
// There must be only one shape in this series at index 0.
ASSERT(lPolygonIdx == 0);
m_Polygon = m_PolygonMapSeries.GetShapes().GetPolygon(0);
m_Polygon.SetTransparency(33);
m_Polygon.SetColor(RGB(255, 0, 0));

m_Polygon.AddXY(dXMin, dYMin);
m_Polygon.AddXY(dXMax, dYMin);
m_Polygon.AddXY(dXMax, dYMax);
m_Polygon.AddXY(dXMin, dYMax);
You will have to play with the order of your series. The region you want should probably be series(0).

Alex

TTL
Newbie
Newbie
Posts: 36
Joined: Thu Aug 04, 2005 4:00 am

Post by TTL » Mon Oct 03, 2005 7:40 pm

Or, better yet, use a Series Band tool? Never used that though...

Alex

amueller
Newbie
Newbie
Posts: 30
Joined: Tue Jul 26, 2005 4:00 am

Post by amueller » Mon Oct 03, 2005 7:53 pm

Hmm..

I tried the first solution there, but maybe I don't have the same methods with Visual Basic? I do not see the GetAsMap.

I will keep trying with that, though.

Thanks,

Andrew

TTL
Newbie
Newbie
Posts: 36
Joined: Thu Aug 04, 2005 4:00 am

Post by TTL » Mon Oct 03, 2005 8:25 pm

Visual Basic names don't have the "Get" and "Set" prefixes. In VB it's asMap instead of GetAsMap(). So GetShapes() becomes Shapes and GetPolygon() becomes Polygon etc.

Alex

amueller
Newbie
Newbie
Posts: 30
Joined: Tue Jul 26, 2005 4:00 am

Post by amueller » Mon Oct 03, 2005 9:09 pm

Thanks Alex! That worked perfectly.

Andrew

PS - code was:

With TChart1

.AddSeries scMap
.Series(0).asMap.Shapes.Add
.Series(0).asMap.Shapes.Polygon(0).Transparency = 66
.Series(0).asMap.Shapes.Polygon(0).Color = vbGreen
.Series(0).asMap.Shapes.Polygon(0).AddXY 0, 4.99
.Series(0).asMap.Shapes.Polygon(0).AddXY 11, 5.12
.Series(0).asMap.Shapes.Polygon(0).AddXY 11, 5.23
.Series(0).asMap.Shapes.Polygon(0).AddXY 0, 5.1

.Legend.Visible = False

.Axis.Bottom.Minimum = 0
.Axis.Bottom.Maximum = 11
.Axis.Bottom.Increment = 1

.Axis.Left.Minimum = 4.98
.Axis.Left.Maximum = 5.25
.Axis.Left.Increment = 0.03

End With

End Sub

Post Reply