473,387 Members | 1,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Bar Graph

6
I am using VML to create a bar graph report, however i have run into trouble trying to come up with a formula to display and draw the grid lines by....

So if i have 3 users... 1 person does 10 time-outs, another does 20 time-outs and another does 24 time-outs....

The max result being 24 should be close to the top of the bar chart... so i would prob want to round to the next 5... i.e. the top of the chart being 25... first and foremost how do i round to the next 5, i will be only dealing w/ positive numbers...
Jan 7 '08 #1
4 1362
jhardman
3,406 Expert 2GB
I am using VML to create a bar graph report, however i have run into trouble trying to come up with a formula to display and draw the grid lines by....

So if i have 3 users... 1 person does 10 time-outs, another does 20 time-outs and another does 24 time-outs....

The max result being 24 should be close to the top of the bar chart... so i would prob want to round to the next 5... i.e. the top of the chart being 25... first and foremost how do i round to the next 5, i will be only dealing w/ positive numbers...
say maxResult is your variable which now reads 24. You will always need to add one, right? (because if you started at 25 you would want the top of the graph to start at 30, not 25, right?) so add one, then start a loop that increments the number and exits when the number is a whole number multiple of five:
Expand|Select|Wrap|Line Numbers
  1. maxResult = maxResult + 1
  2. do until maxResult/5 = int(maxResult/5)
  3.    maxResult = maxResult + 1
  4. loop
after your loop maxResult will be greater than the highest number you started with, and it will be the first multiple of five above your starting point. Let me kow if this helps.

Jared
Jan 8 '08 #2
A better method to do it will be like this:

Suppose x is the variable in which your value is stored then:

Expand|Select|Wrap|Line Numbers
  1.  
  2. if x Mod 5 <> 0 Then
  3.        x = x + 5 - (x Mod 5)
  4. End If
  5.  
That's it. No loops required.
Jan 9 '08 #3
jhardman
3,406 Expert 2GB
A better method to do it will be like this:

Suppose x is the variable in which your value is stored then:

Expand|Select|Wrap|Line Numbers
  1.  
  2. if x Mod 5 <> 0 Then
  3.        x = x + 5 - (x Mod 5)
  4. End If
  5.  
That's it. No loops required.
That's a good solution. I never thought of subtracting xMod 5, but that should work, and very fast. Good job.

Jared
Jan 9 '08 #4
That's a good solution. I never thought of subtracting xMod 5, but that should work, and very fast. Good job.

Jared
My pleasure, keep programming.
Jan 10 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Lilith | last post by:
Is there a python module somewhere (been searching today, no luck) which has efficiently coded various graph-handling routines, such as finding the shortest path through a graph, or the set of all...
25
by: Magnus Lie Hetland | last post by:
Is there any interest in a (hypothetical) standard graph API (with 'graph' meaning a network, consisting of nodes and edges)? Yes, we have the standard ways of implementing graphs through (e.g.)...
1
by: entropy123 | last post by:
Hey all, In an effort to solve a sticky - for me - problem I've picked up Sedgewick's 'Algorithm's in C'. I've tried working through the first few problems but am a little stumped when he refers...
2
by: MLH | last post by:
A97 Am having difficulty displaying graph in Form View that I see fine in graph control on form opened in design view. I know I'm doing something wrong. If I open the form in design view - I...
0
by: mylog | last post by:
I have downloaded a GLEE(Graph Layout Execution Engine) and written the following code to display a windows form from a web page but i am encountering with a small problem on displaying the graph...
2
by: sriniwas | last post by:
Hi Frnd's, m using prefuse visulation,it's have one display class and this class have one saveImage(outPutStream, String jpg,double size);. now graph is converting ia jpg image properly.now my...
4
by: Man4ish | last post by:
namespace ve/////////////////ve.h { struct VertexProperties { std::size_t index; boost::default_color_type color; }; }...
2
by: Man4ish | last post by:
I have created Graph object without vertex and edge property.It is working fine. #include <boost/config.hpp> #include <iostream> #include <vector> #include <string> #include...
1
by: Man4ish | last post by:
I am creating a graph using boost library, I am making the network using create_Network function() i am adding the vertices to this graph by creating the object g of class Graph. I am trying to...
0
by: eureka2050 | last post by:
Hi all, I am creating a radar chart containing 2 plots using jpgraph. My code is as follows:- include ("./jpgraph/src/jpgraph.php"); include ("./jpgraph/src/jpgraph_radar.php"); //...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.