?
Solved

MSChart-Plotting 1000 points

Posted on 2003-02-20
2
Medium Priority
?
853 Views
Last Modified: 2012-05-04
I've been pondering on this problem for some time now, maybe you can easily solve it for me. That would be terrific.
I'm plotting a graph with 2 curves on it that contain 1000 points. The problem is that I only want 4 rows displayed on the graph, not 1000. How do I do this? This is my code:

    For lRow = 0 To UBound(FirstDerivate) - 1 '0 -999
        For lCol = 0 To 2
            Select Case lCol
                Case 0  ' Get the concentration
                    vArray(lRow, lCol) = _
              Str(CalCurveData(lRow + 2)) 'x -axis values
                Case 1  ' Get the respons values
                    vArray(lRow, lCol) = _
              CalculatedResp(lRow + 2)
                Case 2  ' Get the derivatives
                    vArray(lRow, lCol) = _
                FirstDerivate(lRow)
            End Select
        Next lCol
    Next lRow
    ' Create the chart
    With GraphForm.MSChart1
        .chartType = VtChChartType2dLine
        '.RowCount = 4   (does not do any difference)
        '.ColumnCount = 2
        .ChartData = vArray
    End With

    ' Configure the chart.
    With GraphForm.MSChart1
        .TitleText = "Calibration curve"
        .Title.VtFont.Name = "Arial"
        .Title.VtFont.Style = VtFontStyleBold
        .Title.VtFont.size = 12
        'set chart labels
        .Plot.Axis(VtChAxisIdX).Labels(1).Auto = False
        .Plot.Axis(VtChAxisIdX).Labels(1).TextLayout.Orientation = VtOrientationHorizontal
        .Plot.Axis(VtChAxisIdX).Labels(1).TextLayout.VertAlignment = VtVerticalAlignmentCenter
        .Plot.Axis(VtChAxisIdX).Labels(1).TextLayout.WordWrap = True
        .Plot.Axis(VtChAxisIdX).AxisTitle.Text = "Conc"
        .Plot.Axis(VtChAxisIdX).AxisTitle.VtFont.Name = "Arial"
        .Plot.Axis(VtChAxisIdX).AxisTitle.VtFont.VtColor.Set 0, 120, 0
        .Plot.Axis(VtChAxisIdY).AxisTitle.Text = "Res/Der"
        .Plot.Axis(VtChAxisIdY).AxisTitle.VtFont.Name = "Arial"
        .Plot.Axis(VtChAxisIdY).AxisTitle.VtFont.VtColor.Set 0, 120, 0
        'Y-axis is linnear, x-axis logarithmic
        .Plot.Axis(VtChAxisIdY).AxisScale.Type =VtChScaleTypeLinear
        .Plot.Axis(VtChAxisIdX).AxisScale.Type =VtChScaleTypeLogarithmic
        'Set color of response line to blue
        With .Plot.SeriesCollection(1).Pen.VtColor
            .Blue = 200
            .Green = 0
            .Red = 0
        End With
        'Set color of derivative line to red
        With .Plot.SeriesCollection(2).Pen.VtColor
            .Blue = 0
            .Green = 0
            .Red = 200
        End With
        'setup legend
        .ShowLegend = True
        .Plot.SeriesCollection(1).LegendText= "Response"
        .Plot.SeriesCollection(2).LegendText= "Derivative"
    End With

Thanks/Ingela
0
Comment
Question by:Ingela
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 18

Accepted Solution

by:
Sethi earned 225 total points
ID: 7986808
Why iterate 999 times if you want only 4 values to be plotted. Change this statement :  For lRow = 0 To UBound(FirstDerivate) - 1 '0 -999 to the following:
 For lRow = 0 To 3
0
 

Author Comment

by:Ingela
ID: 7987300
True, I could do that. Just found an even better solution.
Thanks anyway. Better:


MSChart1.ChartType = VtChChartType2dLine
With MSChart1.Plot.Axis(VtChAxisIdX)
      .ValueScale.MajorDivision = 10
      .ValueScale.MinorDivision = 5
      .CategoryScale.Auto = False          ' Sets manual scaling.
      .CategoryScale.DivisionsPerLabel = 2 ' Label appears every two
                                           ' divisions.
      .CategoryScale.DivisionsPerTick = 2  ' Ticks appear every two
                                           ' divisions.
      .CategoryScale.LabelTick = True   ' Labels displayed on top of
                                       ' Tick marks.
End With
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question