Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Components
| Search | Today's Posts | Mark Forums Read
VB Components Issues specific to components in VB.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Components section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old February 22nd, 2005, 03:33 AM
Registered User
 
Join Date: Feb 2005
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default MSChart : A chart that needs incomplete data point

We are using MSChart(a Microsoft control for drawing charts) control in Visual Basic for
charting purpose in our project. Our requirement is like this:

It will be a 2D line graph.
On a single chart on the X-axis I will have to show some values for the current year as well as
for the previous year. It may happen that the current data points contains values for 4months
values(i.e. values for Jan, Feb, Mar and Apr) but the previous data points always contains all
the 12 values (for 12 months).

So we will have to draw the chart like : the current
data line will show 4data points and then it will stop there and the previous data line will
show all the 12data points. We are facing a problem like: we can't stop the current link after
showing the line for 4data points rather it draws the chart for all the 12 data points (although
it has only 4defined data points to draw the chart, it just gets the rest 8data points and draws
the chart). So the current chart is wrong, we do not have any problem with the previous chart. But
we will have to stop the current chart after displaying the 4data points.


Can u pls suggest any feasible solution for the above stated problem. Thanks in advance.

Just to restrict the current chart from showing the rest 8 data points I have forcefully made
the rest 8 data points array values as 0. But it does not solve our problem as u can guess.

Pls have a look at the attached VB code.. We get the data points from a Oracle stored procedure and
we get exactly 4 data points for current and 12 data points for previous. Pls have a look at the subroutine
'CreateChartImage' that draws the chart for us. Check on line 526 we are forcefully making the rest 8 data
values for current to 0.

Public Sub CreateChartImage(ByVal ChartNo As Integer, ByVal i_time As String, ByVal rowCount As Long, _
                            ByRef a_apsub() As Single, ByVal countCurrentDPLth As Integer, ByRef a_apsubp() As Single, _
                            ByRef a_ovaprt() As Single, ByRef a_ovaprtp() As Single, _
                            ByRef a_bta() As Single, ByRef a_btap() As Single, _
                            ByRef a_chgoff() As Single, ByRef a_chgoffp() As Single, _
                            ByRef a_lr() As Single, ByRef a_lrp() As Single, _
                            ByRef a_inp() As Single, ByRef a_inpp() As Single, _
                            ByRef a_inlr() As Single, ByRef a_inlrp() As Single, _
                            ByRef a_roma() As Single, ByRef a_romap() As Single, _
                            ByRef a_FMS() As Single, ByRef a_FMSp() As Single)
    Dim i As Integer
    Dim ArrayLength As Integer
    Dim objPen As Object
    i = 0

    'Add a title and legend.
    With frm_Chart.MsChart
        If ChartNo = 1 Then
            .Title.Text = "Applications Submitted"
        ElseIf ChartNo = 2 Then
            .Title.Text = "Overall Approval Rate "
        ElseIf ChartNo = 3 Then
            .Title.Text = "Booked to Approval"
        ElseIf ChartNo = 4 Then
            .Title.Text = "Charge Off Amount"
        ElseIf ChartNo = 5 Then
            .Title.Text = "Loss Rate"
        ElseIf ChartNo = 6 Then
            .Title.Text = "Insurance Penetration"
        ElseIf ChartNo = 7 Then
            .Title.Text = "Insurance In Force Loss Ratio"
        ElseIf ChartNo = 8 Then
            .Title.Text = "ROMA"
        ElseIf ChartNo = 9 Then
            .Title.Text = "Finance Market Share"
        End If
        .Legend.Location.LocationType = MSChart20Lib.VtChLocationType.VtChLocationTypeRigh t
        .Legend.Location.Visible = True
    End With

    If Mid(i_time, 1, 4) <> "CQTD" And Mid(i_time, 1, 4) <> "FQTD" Then
        frm_Chart.MsChart.Plot.Axis(VtChAxisIdX, 1).AxisTitle = "Months"
    Else
        frm_Chart.MsChart.Plot.Axis(VtChAxisIdX, 1).AxisTitle = "Quarters"
    End If

' If ChartNo = 1 Then
' frm_Chart.MsChart.Plot.Axis(VtChAxisIdY, 1).AxisTitle = "Applications Submitted"
' ElseIf ChartNo = 2 Then
' frm_Chart.MsChart.Plot.Axis(VtChAxisIdY, 1).AxisTitle = "Overall Approval Rate "
' ElseIf ChartNo = 3 Then
' frm_Chart.MsChart.Plot.Axis(VtChAxisIdY, 1).AxisTitle = "Booked to Approval"
' ElseIf ChartNo = 4 Then
' frm_Chart.MsChart.Plot.Axis(VtChAxisIdY, 1).AxisTitle = "Charge Off Amount"
' ElseIf ChartNo = 5 Then
' frm_Chart.MsChart.Plot.Axis(VtChAxisIdY, 1).AxisTitle = "Loss Rate"
' ElseIf ChartNo = 6 Then
' frm_Chart.MsChart.Plot.Axis(VtChAxisIdY, 1).AxisTitle = "Insurance Penetration"
' ElseIf ChartNo = 7 Then
' frm_Chart.MsChart.Plot.Axis(VtChAxisIdY, 1).AxisTitle = "Insurance In Force Loss Ratio"
' ElseIf ChartNo = 8 Then
' frm_Chart.MsChart.Plot.Axis(VtChAxisIdY, 1).AxisTitle = "ROMA"
' ElseIf ChartNo = 9 Then
' frm_Chart.MsChart.Plot.Axis(VtChAxisIdY, 1).AxisTitle = "Finance Market Share"
' End If

    With frm_Chart.MsChart
        .chartType = VtChChartType2dLine
        .rowCount = rowCount
        .ColumnCount = 2

        'restrict to only 4 values for CQTD and FQTD
        If Mid(i_time, 1, 4) <> "CQTD" And Mid(i_time, 1, 4) <> "FQTD" Then
            ArrayLength = 11
        Else
            ArrayLength = 3
        End If

        For i = 0 To ArrayLength
            .Row = i + 1
            .RowLabel = aMonths(i)
        ' MsgBox aMonths(i)
        Next
        If ChartNo = 1 Then
            'Applications Submitted - Current & Previous
            For i = 0 To countCurrentDPLth - 1
                .Row = i + 1
                .Column = 1
                .Data = a_apsub(i)
            ' MsgBox a_apsub(i)
            Next
            If countCurrentDPLth <= ArrayLength Then
' For i = countCurrentDPLth To ArrayLength
' .rowCount = rowCount
' .Row = i + 1
' .Column = 1
' .Plot.SeriesCollection(1).Pen.Width = 0
' .Plot.SeriesCollection(1).DataPoints(6).Pen.VtColo r.Set 255, 255, 0
' .Data = vbNull
' Next

                For i = countCurrentDPLth To ArrayLength
                    .Row = i + 1
                    .Column = 1
                    .Data = 0
                    If Mid(i_time, 1, 4) = "CYTD" Or Mid(i_time, 1, 4) <> "FYTD" Or Mid(i_time, 1, 4) = "CQTD" Or Mid(i_time, 1, 4) <> "FQTD" Then
                        .Plot.SeriesCollection(1).Pen.Width = 0
                    End If
' Set objPen = .Plot.SeriesCollection(1).Pen
' ' Set Pen attributes.
' With objPen
' .VtColor.Set 255, 255, 0
' .Width = 100
' .Style = VtPenStyleDashDot
' .Join = VtPenJoinRound
' .Cap = VtPenCapRound
' End With
                Next
            End If
            For i = 0 To ArrayLength
                .Row = i + 1
                .Column = 2
                .Data = a_apsubp(i)
            ' MsgBox a_apsubp(i)
            Next
        End If
    End With

    With frm_Chart.MsChart.Plot
       .SeriesCollection(1).LegendText = "Current"
       .SeriesCollection(2).LegendText = "Previous"
    End With

    frm_Chart.Picture1.Visible = False
    Dim strDateTime As String
    strDateTime = Now()
    strDateTime = Replace(strDateTime, "/", "")
    strDateTime = Replace(strDateTime, ":", "")
    strDateTime = Replace(strDateTime, " ", "")
    If ChartNo = 1 Then
        g_filename = "Demochart1" & strDateTime & ".jpg"
        Call Save_to_JPEG_From_Chart(pFilePath)
    End If

End Sub

Thanks,
sanjib



Similar Threads
Thread Thread Starter Forum Replies Last Post
Formatting point labels on stacked column chart jwbus2004 Reporting Services 0 March 3rd, 2008 12:53 AM
Incomplete Data Showing rameshjha ADO.NET 0 June 20th, 2006 06:46 AM
Chart in power point Using VBA Bhavna Agrawal Excel VBA 1 July 11th, 2003 07:39 AM
MSChart - Populating Data kasie Beginning VB 6 1 June 11th, 2003 06:00 AM
MSChart - Populating the chart kasie VB Components 0 June 10th, 2003 03:22 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.