Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

In VB6, how to do comething like MSChart1.chartType = xlXYScatter

Status
Not open for further replies.

greathope123

Programmer
Nov 1, 2011
84
GB
Hi,

In VB6, I got MSChart1, set its chartType to VtChChartType2dXY and it shows a curve line.
Now, I want MSChart1 only shows the dot marks without the curve line.
I noticed it can be down in Excel and I recorded, that is:
ActiveChart.ChartType = xlXYScatter
My question is: how can I do that in VB6?

I will be very appreciated for any suggestions.
 
The example there probably will disappoint you if just used blindly. MSChart has a rather complex object model.


Worse yet, if you have installed any of the Microsoft "Security Rollup" patches, starting in December 2008 with multiple attempts every 3 to 6 months up through (most recently) August 2012... you're screwed.

These "fixes" break tons of things and as far as I know they have never gotten them right. There are numerous "off by one" errors with all sorts of consequences. The Winsock control will return LocalIP and RemoteIP values truncated by one character for example. Other controls woth complex collections in their object model often have collection indexes off by one - so that the first entry is Index = 0 instead of 1. These bugs are inconsistent so you can find that one collection is still 1-based while others are now 0-based.

Chaos!

And the sad part is these "fixes" can't be uninstalled. Can you say "reinstall Wiondows from scratch and start over?" I'll bet you can, and you'll also say a few more choice things beyond that when this strikes you.


In any case, hoping you haven't installed any of those failed attempts at security fixes, here's an example that might be more helpful:

Code:
Option Explicit

'Just plop an instance of MSChart as MSChart1 onto a Form.

Private Sub Form_Load()
    Dim Series1 As Variant
    Dim Series2 As Variant
    Dim Series3 As Variant
    Dim Series As Integer
    Dim I As Integer
    Dim Row As Integer

    'Hold series data in Variant arrays here, as (X, Y) pairs
    'that follow each other:
    Series1 = Array(12, 20, 3, 10, 15, 20, 4, 50, 50, 27)
    Series2 = Array(1, 12, 23, 9, 48, 25, 16, 16, 30, 37)
    Series3 = Array(1, 43, 45, 45, 4, 25, 39, 5, 13, 6)
    
    With MSChart1
        .chartType = VtChChartType2dXY
        .RowCount = (UBound(Series1) + 1) \ 2
        .ColumnCount = 6 '2 columns per series, 3 series.
        
        'Set up each Series for small circles with no lines.
        For Series = 1 To 3
            With .Plot.SeriesCollection((Series - 1) * 2 + 1)
                .SeriesType = VtChSeriesType2dXY
                .ShowLine = False
                With .SeriesMarker
                    .Show = True
                    .Auto = False
                End With
                With .DataPoints(-1).Marker
                    .Style = VtMarkerStyleFilledCircle
                    .Size = ScaleX(7, vbPixels, vbTwips)
                    With .Pen.VtColor
                        Select Case Series
                            Case 1
                                .Set 192, 64, 64 'Red.
                            Case 2
                                .Set 64, 64, 192 'Blue.
                            Case 3
                                .Set 64, 192, 64 'Green.
                        End Select
                    End With
                End With
            End With
        Next
    
        For I = 0 To UBound(Series1) Step 2
            Row = I \ 2 + 1
            .DataGrid.SetData Row, 1, Series1(I), False
            .DataGrid.SetData Row, 2, Series1(I + 1), False
            
            .DataGrid.SetData Row, 3, Series2(I), False
            .DataGrid.SetData Row, 4, Series2(I + 1), False
            
            .DataGrid.SetData Row, 5, Series3(I), False
            .DataGrid.SetData Row, 6, Series3(I + 1), False
        Next
    End With
End Sub

I hope this helps you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top