MSChart Data Aware

Hey all

Ok i am not sure this weather the mschart is the rght tool for the job but it is a starting point.

I have a problem

I have some data stored in my database that run behind my VB front end.  For simplicity sake i will give explain only fields required.

RA# - agreement Number
StartDate - start date agreememnt
EndDate - end date of agreement

So i have a list of RA# and when they are happening

I want to display this visually in a month.

so i forsee there being a bar chart/graph with 1-31 accross the bottom of the chart and then bars in the horizontal position relating to the days the RA's are on

does this sound reasonable

also the month displayed would alos have to be chosen by the user.

400 points up for offer for a answer that gets me working fully

any sujestions?
Who is Participating?
adgConnect With a Mentor Commented:
It is difficult to do a horizontal bar chart using the mschart control. But you might get a good effect using an X-Y chart.  Here is an example of what I mean:

Option Explicit
'   garray(Datapoints,series)
Dim garray(1 To 2, 1 To 30)

Private Sub Form_Load()
    Dim i As Integer
    Dim serx As Series
    Randomize Timer
    With MSChart1
        .chartType = VtChChartType2dXY
        .AllowSelections = False
        .Plot.Axis(VtChAxisIdX).ValueScale.Minimum = 1
        .Plot.Axis(VtChAxisIdX).ValueScale.Maximum = 31
    End With
    For i = 1 To 15
        garray(1, i * 2 - 1) = Int(Rnd * 31)
        garray(1, i * 2) = i
        garray(2, i * 2 - 1) = Int(Rnd * 31)
        garray(2, i * 2) = i
    Next i
    MSChart1 = garray
    For Each serx In MSChart1.Plot.SeriesCollection
        serx.Pen.VtColor.Set 255, 0, 0
    Next serx
End Sub

Private Sub Form_Resize()
    MSChart1.Move Me.ScaleLeft, Me.ScaleTop, Me.ScaleWidth, Me.ScaleHeight
End Sub
Also, I forgot to mention that you can adjust the width of the lines to make them look more like bars.  Example:   serx.Pen.Width = 100
philcrouchAuthor Commented:
Ok i will test that out


I am not sure if a chart is the entirely right way to go about it as the data does not all start from 0

below is example data

ra# 1
Start 1/1/01
End   7/1/01

ra# 2
Start 5/1/01
End  15/1/01

rs# 3
Start 11/1/01
End   17/1/01

so if i was to plot or display these it would look like this

 3                                            *****************  

RA#?s  2                       ***********************

 1         ***********


               Days of Month

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

philcrouchAuthor Commented:
that did not work out right......

       3                         *****************  

RA#?s  2           **************************

       1   *************


               Days of Month
philcrouchAuthor Commented:

i just tested your comments and i like what i am seeing

could you now tell me how i related the data series to my data from my database?

philcrouchAuthor Commented:

i just tested your comments and i like what i am seeing

could you now tell me how i related the data series to my data from my database?

philcrouchAuthor Commented:

i just tested your comments and i like what i am seeing

could you now tell me how i related the data series to my data from my database?

I was hoping that was what you were looking for! I can see why you ask about the dataseries - it's not very intuitive.  As you can see each "Bar" is using up two series, like this:

 1,series is the X1 value (starting day between 1 and 31)
 2,series is the Y1 value (1 = 1st RA#, 2 = 2nd RA#, etc.)

 1,series+1 is the X2 value (ending day between 1 and 31)
 2,series+1 is the Y2 value (same as Y1)

So the first RA# uses series 1 and 2, the second RA# uses series 3 and 4, etc. So for the 5th RA number I calculate the series as 5*2-1 = 9 and 5*2 = 10 and use the 9th and 10th series to chart the 5th RA#.  Hope that clarifies it but if not just let me know.  

Did you get to use the "serx.Pen.Width = 100"? It really improves the appearance of the chart.  
philcrouchAuthor Commented:

that is excellent.
I had actually just finished working that bit out :)
Sorry to be a bother

I am not just tryiing to get the information from the database through a recordset and put it into the dataseries.

I am going to give you the points, cause it was what i was after, i am just gong to leave it open for a while so i can ask any more questions if that is ok.......

thanks again

i did set the pen and it does look better, thanks
No problem.  I don't know much about databases but I can manipulate ADO recordsets to some degree so if that is giving you any trouble feel free to ask.  
philcrouchAuthor Commented:
Ok i am going fine with the record set but now i have a question about the chart

is there a way i can have the y axis not being in scale

the reason i ask is that my vales up the y axis are the RA numbers

these can atucally be values as follows


and if i plot those one the chart it is tiny.

so can i just have them liked spaced evenly and maybe a lable beside saying the ra # ?

thanks again

I tried for hours last night to change the Y-axis labels on an XY mschart and so far have been unable to do so.  I also tried using datapoint labels (with the series name) which sort of worked but didn't look very good.  Anyway, I haven't given up but if I'm able to figure it out I'll post the info to 
philcrouchAuthor Commented:

thanks very much

This is what i have asked for so i have given you the points.  Thanks heaps for your help in this

I have left it at 300 but opened another question at 200 points for the additional part of the question.

It would be great if you can help me out with that.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.