Page 1 of 1

Cross-hatching regions in graph

Posted: Thu May 27, 2004 7:12 pm
by 32639
Hello group,
I am new to this forum, but have been using TeeChart for around two years. I have a project that requires a graph that shows a safe operating region for a product. The safe operating region needs to be cross-hatched or filled with a color to make it very noticeable. The region is always a multi-sided polygon. I am wondering if there is a method for cross-hatching a region. I know the Shapes method allows a Fill, but Shapes can only be regular, like a square or a rectangle or circle. I am preparing to write the cross-hatching routines myself, but don't have a lot of time to spend on it, so if anyone knows of a method in TeeChart to do this I would appreciate your comments.

Thanks,
Bob

Posted: Fri May 28, 2004 9:30 am
by Chris
Hi Bob,
I know the Shapes method allows a Fill, but Shapes can only be regular, like a square or a rectangle or circle. I am preparing to write the cross-hatching routines myself, but don't have a lot of time to spend on it, so if anyone knows of a method in TeeChart to do this I would appreciate your comments.
Have you thought about using a Map series? The following maybe the sort of thing you're looking for:

Code: Select all

Private Sub AddShape(X, Y As Variant, Color As OLE_COLOR, Label As String)
Dim tmpIndex
  With TChart1.Series(0).asMap
    tmpIndex = .Shapes.Add
    For i = 0 To UBound(X)
    .Shapes.Polygon(tmpIndex).AddXY X(i), Y(i)
    Next i
    .Shapes.Polygon(tmpIndex).ParentBrush = False
    If i < 20 Then
        .Shapes.Polygon(tmpIndex).Brush.Style = i
    End If
    .Shapes.Polygon(tmpIndex).Color = Color
    .Shapes.Polygon(tmpIndex).Text = Label
    .Shapes.Polygon(tmpIndex).Z = Rnd * 1000 / 1000
  End With
End Sub

Private Sub Form_Load()
TChart1.AddSeries scMap
TChart1.Aspect.View3D = False
    
 AX = Array(1, 3, 4, 4, 5, 5, 6, 6, 4, 3, 2, 1, 2, 2)
 AY = Array(7, 5, 5, 7, 8, 9, 10, 11, 11, 12, 12, 11, 10, 8)
 BX = Array(5, 7, 8, 8, 7, 6, 5, 4, 4)
 By = Array(4, 4, 5, 6, 7, 7, 8, 7, 5)
 CX = Array(9, 10, 11, 11, 12, 9, 8, 7, 6, 6, 5, 5, 6, 7, 8, 8)
 CY = Array(5, 6, 6, 7, 8, 11, 11, 12, 11, 10, 9, 8, 7, 7, 6, 5)
 DX = Array(12, 14, 15, 14, 13, 12, 11, 11)
 DY = Array(5, 5, 6, 7, 7, 8, 7, 6)
 EX = Array(4, 6, 7, 7, 6, 6, 5, 4, 3, 3, 2)
 EY = Array(11, 11, 12, 13, 14, 15, 16, 16, 15, 14, 13)
 FX = Array(7, 8, 9, 11, 10, 8, 7, 6, 5, 5, 6, 6)
 FY = Array(13, 14, 14, 16, 17, 17, 18, 18, 17, 16, 15, 14)
 GX = Array(10, 12, 12, 14, 13, 11, 9, 8, 7, 7, 8, 9)
 GY = Array(10, 12, 13, 15, 16, 16, 14, 14, 13, 12, 11, 11)
 HX = Array(17, 19, 18, 18, 17, 15, 14, 13, 15, 16)
 HY = Array(11, 13, 14, 16, 17, 15, 15, 14, 12, 12)
 IX = Array(15, 16, 17, 16, 15, 14, 14, 13, 12, 11, 10, 11, 12, 13, 14)
 IY = Array(6, 6, 7, 8, 8, 9, 10, 11, 12, 11, 10, 9, 8, 7, 7)
 JX = Array(15, 16, 16, 17, 17, 16, 15, 13, 12, 12, 14, 14)
 JY = Array(8, 8, 9, 10, 11, 12, 12, 14, 13, 12, 10, 9)
 KX = Array(17, 19, 20, 20, 19, 17, 16, 16, 17, 16)
 KY = Array(5, 5, 6, 8, 8, 10, 9, 8, 7, 6)
 LX = Array(19, 20, 21, 21, 19, 17, 17)
 LY = Array(8, 8, 9, 11, 13, 11, 10)
 
 AddShape AX, AY, vbBlue, "A"
 AddShape BX, By, vbRed, "B"
 AddShape CX, CY, vbYellow, "C"
 AddShape DX, DY, vbGreen, "D"
 AddShape EX, EY, vbCyan, "E"
 AddShape FX, FY, vbBlue, "F"
 AddShape GX, GY, vbMagenta, "G"
 AddShape HX, HY, vbWhite, "H"
 AddShape IX, IY, vbYellow, "I"
 AddShape JX, JY, vbBlack, "J"
 AddShape KX, KY, vbGreen, "K"
 AddShape LX, LY, vbRed, "L"
End Sub

Private Sub TChart1_OnClickSeries(ByVal SeriesIndex As Long, ByVal ValueIndex As Long, ByVal Button As TeeChart.EMouseButton, ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
TChart1.StopMouse
MsgBox TChart1.Series(0).PointLabel(ValueIndex)
End Sub

Posted: Fri May 28, 2004 3:49 pm
by 32639
Chris,

Thanks for the suggestion. The code you sent appears to be doing what I was needing, but, it won't run on the version of TeeChart that I have (version 4.02). At least that is what it seems to be. The .asMap method doesn't appear in my Graph list. When I try to run your sample code I get run time error 438, "Object doesn't support this property or method". What version does the Map method appear in?

Best regards,
Bob

Posted: Sun May 30, 2004 11:52 pm
by Pep
Hi Bob,
code I get run time error 438, "Object doesn't support this property or method". What version does the Map method appear in?
The "asMap" method has been added in the TeeChart Pro v5 and above.

Posted: Tue Jun 01, 2004 1:03 pm
by 32639
Thanks Josep, I guess I need to upgrade.
-Bob

Posted: Fri Jun 04, 2004 2:56 pm
by 32639
I have upgraded to v6.0 and have had success filling the safe region with a color. Unfortunately, the color is opaque and you can't see the information on the graph. Is there a way to get a transparent color to work?
-Bob

Same approach for .NET?

Posted: Thu Sep 22, 2005 3:55 pm
by 8884730
Actually this is the same thing I need to do, but I have the TeeChart for .NET v 1. Is this approach available in that version? I do not need the transparancy(right now any way)

Posted: Fri Sep 23, 2005 8:44 am
by narcis
Hi tekwiz,

No, map series were implemented in TeeChart for .NET v2. So if you want to use them you'll need to upgrade your license.