[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 442
  • Last Modified:

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?
0
philcrouch
Asked:
philcrouch
  • 8
  • 5
1 Solution
 
adgCommented:
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
0
 
adgCommented:
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
0
 
philcrouchAuthor Commented:
Ok i will test that out

thanks

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         ***********

1-2-3-4-5-6-7-8-9-10-11-12-13-14-15-16-17-18-19-20???

               Days of Month
                    Jan





0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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





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


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


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

           1-2-3-4-5-6-7-8-9-10-11-12-13-14-15-16-17-18-19-

               Days of Month
                    Jan
0
 
philcrouchAuthor Commented:
adg

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?

0
 
philcrouchAuthor Commented:
adg

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?

0
 
philcrouchAuthor Commented:
adg

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?

0
 
adgCommented:
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.  
 
0
 
philcrouchAuthor Commented:
adq

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

ps
i did set the pen and it does look better, thanks
0
 
adgCommented:
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.  
0
 
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


4
765
234
34
123


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



0
 
adgCommented:
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 http://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20187325 
0
 
philcrouchAuthor Commented:
adq

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.

http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=visualbasic&qid=20187325
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 8
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now