MSChart graphs unexisting point

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • necalabria
    New Member
    • Nov 2012
    • 1

    MSChart graphs unexisting point

    Hellow:

    I have the following VB6 code to get a scatter chart with MSChart:

    Code:
    Private Sub Form_Load()
    Form1.Show
    ' POINTS
    Dim Graph(1 To 41, 1 To 2) As Single
    
                Graph(1, 1) = -9   ' value for X-axis
                Graph(2, 1) = -5
                Graph(3, 1) = 9
                Graph(4, 1) = 9
                Graph(5, 1) = 18
                Graph(6, 1) = 9
                Graph(7, 1) = 9
                Graph(8, 1) = 0
                Graph(9, 1) = 0
                Graph(10, 1) = -18
                Graph(11, 1) = -9
                Graph(12, 1) = -9
                
                Graph(1, 2) = -15   ' value for X-axis
                Graph(2, 2) = -11
                Graph(3, 2) = -14
                Graph(4, 2) = -6
                Graph(5, 2) = -3
                Graph(6, 2) = 0
                Graph(7, 2) = 8
                Graph(8, 2) = 12
                Graph(9, 2) = 4
                Graph(10, 2) = -4
                Graph(11, 2) = -7
                Graph(12, 2) = -15
      
     ' GRAPH
             MSChart1.chartType = VtChChartType2dXY  ' set to X Y Scatter chart
             MSChart1 = Graph
       
       ' DATA POINTS SHOW
        With MSChart1
          .Plot.Axis(VtChAxisIdX).Labels(1).VtFont.Size = 8
          End With
              
        'PLOT AREA COLOR
           With MSChart1.Plot
          ' Set style to solid.
          .Wall.Brush.Style = VtBrushStyleSolid
          ' Set color .
          .Wall.Brush.FillColor.Set 221, 217, 195
         
        'DATA POINTS SHOW & COLOR AND SERIE COLOR
            With .SeriesCollection
            With .Item(1).DataPoints(-1)
             .DataPointLabel.LocationType = VtChLabelLocationTypeAbovePoint
             .DataPointLabel.VtFont.VtColor.Set 0, 0, 0 '# black
             .Brush.FillColor.Set 165, 0, 33
            End With
            End With '#seriescoll
           End With
          
          With MSChart1.Plot.Backdrop
         ' Property to VtFillStyleBrush.
          .Fill.Style = VtFillStyleBrush
          .Fill.Brush.FillColor.Set 197, 190, 151
          ' Border.
          .Frame.Style = VtFrameStyleThickInner
          ' Set shadow.
          .Shadow.Style = VtShadowStyleDrop
        End With
    
    End Sub
    The problem: the chart plots a line from an unxisting Graph (0,0) point to the one my example begins with, Graph (1,1=-9;Graph(1,2)=-15).

    Unsuccessfully, I have been trying to get rid off that.

    I thank any help I could get.

    Nelson
    Last edited by Rabbit; Nov 21 '12, 04:42 PM. Reason: Please use code tags when posting code.
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Sorry I'm not familiar with the MSchart control (dabbled briefly but it was years ago), but I was wondering... could it simply require your array to begin at 0 rather than 1?

    Comment

    Working...