Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

MSChart Data Aware

Posted on 2001-09-17
13
Medium Priority
?
440 Views
Last Modified: 2007-12-19
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
Comment
Question by:philcrouch
[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
  • 8
  • 5
13 Comments
 
LVL 3

Accepted Solution

by:
adg earned 1200 total points
ID: 6489253
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
 
LVL 3

Expert Comment

by:adg
ID: 6489256
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
 

Author Comment

by:philcrouch
ID: 6498282
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:philcrouch
ID: 6498286
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
 

Author Comment

by:philcrouch
ID: 6498342
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
 

Author Comment

by:philcrouch
ID: 6498362
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
 

Author Comment

by:philcrouch
ID: 6498375
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
 
LVL 3

Expert Comment

by:adg
ID: 6498818
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
 

Author Comment

by:philcrouch
ID: 6498825
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
 
LVL 3

Expert Comment

by:adg
ID: 6499161
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
 

Author Comment

by:philcrouch
ID: 6504548
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
 
LVL 3

Expert Comment

by:adg
ID: 6510488
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
 

Author Comment

by:philcrouch
ID: 6510875
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

609 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