Line Graph Drawing
Hi i have developed a class for the information manipulation of a Line graph
I would Like some help in actually drawing the graph so i can pass values
manipulated here to the drawing of the graph any help is greatly appreciated thank you
package ICUv2;
import java.awt.Point;
import java.util.Random;
public class ecgSensor extends Paitent {
private int x;
private int y;
private int xpos;
private int ypos;
private int min;
private int max;
private Point rate;
public ecgSensor(int x, int y, int min, int max, int xpos, int ypos ){
setX(x);
setY(y);
setMin(min);
setMax(max);
setRate(getXpos() , getYpos());
public ecgSensor(int x, int y, int min, int max ){
this(x,y,min,max,0,0);
setX(x);
setY(y);
setMin(min);
setMax(max);
public ecgSensor(){
this(5, 5, 50, 100);
@Override
public String toString(){
return String.format("%s :%s", getX(), getY());
public static void main (String[] args){
ecgSensor a = new ecgSensor() ;
System.out.print(a.toString());
//System.out.print(a.getX());
//System.out.print(" ");
//System.out.print(a.getY());
public Point getRate(){
return rate;
public void setRate(int x, int y){
this.rate = new Point (x, y);
public int getX(){
return x;
public int getY(){
return y;
public void setX(int x){
this.x = x;
public void setY(int y){
this.y = y;
public int getMin(){
return min ;
public int getMax(){
return max;
public void setMin(int min){
this.min = min;
public void setMax(int max){
this.max = max;
public int getXpos(){
return xpos;
public int getYpos(){
return ypos;
public void setXpos(int xpos){
this.xpos = xpos;
public void setYpos(int ypos){
this.ypos = ypos;
public int incYpos(){
return this.ypos;
public void setincYpos(int inc){
setYpos(getYpos()-inc);
public int decYpos(){
return this.ypos;
public void setdecYpos(int dec){
setYpos(getYpos()+ dec);
public class ecgReadings implements Runnable {
Random ecgr = new Random();
int Change = ecgr.nextInt(20);
public void run(){
this.toString();
while (true) {
if (x%2==0){
setXpos(getXpos()+ 10);
setdecYpos(Change);
}else{
setXpos(getXpos()+ 10);
setincYpos(Change);
try{
Thread.sleep(1000);
}catch(InterruptedException e){}
}// end of while
}// end of run method
}// end of ReviseBloodrate class
}
xiaolixx wrote:
Hi i have developed a class for the information manipulation of a Line graph
I would Like some help in actually drawing the graph so i can pass values
manipulated here to the drawing of the graph ..Right. Did you have a question, or did you think your plaintiff cry for help would get someone to do it all for you?
..any help is greatly appreciated thank you
package ICUv2;
By convention, package names are alllowercase (It's funny you should rediscover your shift key, just for some package name where it is inappropriate!). Class names should be EachWordUpperCase, while attributes and methods should be firstWordLowerCaseAllTheRestUpper.
By using the common conventions for code, you help to communicate the problem to others who are used to seeing that nomenclature.
And as I said before.. "For better help sooner, post an SSCCE".
Similar Messages
-
How to draw cumulative line graph over the stacked bar chart?(SSRS)
Hello,
I need your help to draw a cumulative line graph over this bar chart.
I need your help to draw a cumulative line graph over this bar chart in SSRS.
The dimension (Category Group) is "Hour" in this case. and expression is sum of two distinct values like 'Y' and 'N' in Activity column(Series Groups). The sum(Activity=Y) in green color and sum(Activity='N') in Red color.
I require to draw a cumulative line graph in this same chart, that should give the result of cumulative Sum(Activity) for each hour?? I mean sum of (Y+N) for each hour and that should be cumulative over the hour.
I mean sum of (Y+N) for each hour and that should be cumulative over the hour.
SSRS Version details:
Microsoft SQL Server Reporting Services Designers
Version 10.50.1600.1
--SivaHi Siva,
It seems that you need to verify your email address to post images, etc
Besides, Microsoft® SQL Server™ 2008 Reporting Services: Step by Step is a good choice to you. With STEP BY STEP, you work at your own pace through hands-on, learn-by-doing exercises. A companion CD includes data sets and sample code. You can download
it from this link http://my.safaribooksonline.com/9780735626041 Click the Extras, you can get the samples and database from Supplemental Content.
And there are vast of valuable articles and SQL Server Reporting Services Books Online in MSDN ,you can click these link to begin your learning journey, SQL Server Reporting Services 2008 Books Online:
http://msdn.microsoft.com/en-us/library/ms159106(v=SQL.100).aspx
Besides these, there are still many valuable videos in Microsoft Webcast, click this link
https://msevents.microsoft.com/cui/SearchDisplay.aspx?culture=en-US#culture=en-US;eventType=0;sortKey=;sortOrder=;pageEvent=false;hdnInitialCount=;searchcontrol=yes;kwdAny=Reporting%20service to register with a windows live ID, then download the ones you
want.
Hope this helps.
Regards,
Charlie Liao
TechNet Community Support -
How to Draw a line Graph using x,y Cordinates in Java ?
Hi,
what r the easiest way to draw a line Graph using Java Code either applet.
can u give me code sample. or any package where we can pass some parameter so that accoring to the paramter as i know jfreeChart.function() like some method is there from toold jChart.
Is it possible.
Regards,
PrabhatThere's a number of sample applications in one of the packages of freechart, one of which should do the trick.
If you're doing applets I suggest you look at genjar from the sourceforge site. What that does is bundle classes from a set of library jars into one jar, selecting only classes that are referenced. That should simplify the transfer problem.
To draw graphs, typically, you create a DefaultXYDataset object, add data points and then use the appropriate ChartFactory.createXXX methods to build a chart object. Then you wrap that in a ChartPanel to display. -
I want to have a line graph where the user inputs variables
in a text box and then the graph is generated by the click of a
button. Does anyone know how to do this or know where I could find
a tutorial on this?Check out the MovieClip class for the drawing API –
moveTo(), lineTo(), etc.
The rest will just be interface design and some maths.
For some reason I think that kglad has posted some code in
the forums for at least parts of such a thing. -
Could you please give me the method to draw Line Graph in detail?
Could you please give me the method to draw Line Graph in detail?
Hi,
First update your username instead of using that number.
and also provide full information like
Apex version
Database version
I am giving you one link related to charts,
http://dgielis.blogspot.in/2011/02/apex-4-bug-series-type-bar-line-marker.html
Hope this will helps you
Thanks and Regards
Jitendra -
Can I draw a k-line graph with jfreechart for a Mac app on 10.8?
Hi,
I want to draw a k-line graph on mac, and I haven't find a lib better than jfreechart on doing that work until now, so how can I use it in xcode?
RegardsI believe this version works in 10.6.8.
http://support.apple.com/kb/DL1507 -
Help needed in plotting line graph!
Hi i need help in plotting a line graph complete with both axes shown,plus the legend on the side shown.
Pls help!!!!
rgdsHere's a simple line graph applet I did some time backimport java.awt.*;
public class LineGraff extends java.applet.Applet{
double []toGraff = {6.0, -14.0, -164.0, -210.0, 108.0, 770.0,
1354.0, 896.0, -572.0, -1348.0, -780.0, -108.0};
double []numsFromFile = {6.0, -14.0, -164.0, -210.0, 108.0, 770.0,
1354.0, 896.0, -572.0, -1348.0, -780.0, -108.0};
int max, min, size, Hscale;
double Vscale;
public void init(){
size = numsFromFile.length-1;
java.util.Arrays.sort(numsFromFile);
max = (int) numsFromFile[size];
min = (int) numsFromFile[0];
Vscale = max-min;
Vscale = 200/Vscale;
Hscale = Math.round(300/size);
public void paint(Graphics g) {
g.setFont(new Font("Arial",0,14));
g.drawString("Example app: drawing a graph from a double array",25,18);
g.setFont(new Font("Arial",0,10));
g.setColor(Color.blue);
g.fillRect(10,20,365,230);
g.setColor(Color.cyan);
g.drawLine(25,25,25,225);
g.drawLine(25,140,330,140);
g.setColor(Color.white);
int intA = 30, intB = 0, intC = 0;
int intD = (int) (Math.round(140 - (Vscale * toGraff[0])));
for(int i=1; i <= size; i++) {
intC = intA + Hscale;
intB = intD;
intD = (int) (Math.round(140 - (Vscale * toGraff[ i ])));
g.drawLine(intA, intB, intC, intD);
if(toGraff[ i ] > 0)
g.drawString(Double.toString(toGraff[ i-1 ]), intA+6, intB-3);
else
g.drawString(Double.toString(toGraff[ i-1 ]), intA+6, intB+8);
intA += Hscale;
g.drawString(Double.toString(toGraff[size]), intA+6, intD-3);
} -
Hi,
I am using JDev 11.1.2.2.0
I made a standard line graph which I populate with data through a backing bean.
I read a post on how to put points to the graph:
ArrayList <Object[]> data;
Object[0] -> x axis data, here I have dates
Object[1] -> name of the serie, a new serie is created for each different name
Object[2] -> y axis data, here I have values
Then I put the list to the graph and it works fine, only for one serie.
When I display 2 or more series, the graph shows the different series in different colors as it is suposed to do.
But, the values (Y axis) are not displayed at the correct place. I mean for instance the point with value 4K is displayed below the 3K Y axis marker...
And sometimes the point is displayed above as its real value...
So my graph is false, but my values are correct (I tested it)
Then what can I do? The graph can draw several lines as I managed to put more than one serie. The only problem is that they are not displayed properly...
(if you need the code I can show it)
Edited by: Jikai on 20 sept. 2012 16:51Ok, I found what was wrong.
In the graph properties the subType field was set to LINE_VERT_STACK, then I changed it to default (LINE_VERT_ABS) and it worked.
<dvt:lineGraph id="lineGraph" subType="*LINE_VERT_ABS*"
binding="#{backingBeanScope.backing_ReportingPopUp.lineGraph}" shortDesc="Graph that shows metrics"
inlineStyle="height:100%; width:100%;" imageFormat="FLASH">
<dvt:background>
<dvt:specialEffects/>
</dvt:background>
<dvt:graphPlotArea/>
<dvt:seriesSet>
<dvt:series/>
</dvt:seriesSet>
<dvt:o1Axis/>
<dvt:y1Axis/>
<dvt:legendArea automaticPlacement="AP_NEVER"/>
<dvt:graphTitle text="Metrics for Hosts by Date" horizontalAlignment="CENTER"/>
</dvt:lineGraph> -
First off, thanks to kglad for the line graph function I
started with, it has been a huge help. Now the step I'm trying to
take is 2 fold.
First, I'd like to graph more than one line segment on the
graph. Right now I am graphing functions f1 and f2, but f2
currently overwrites f1. I want them to coincide so f1 goes from
x=1 to x=15, f2 goes from x=15 to x=25, f3 goes from x=25 to x=10
at a different y (these are all curves), and finally f4 goes from
x=10 to x=1 creating a closed shape. Also, I want the x values and
the y values to be variable based on the temperature. I'm using
PV=nRT and n, R, and T are all known. so I have something like
P=nRT/V where P is y, V is X and the nRT can be calculated for two
steps of the 4. The other two steps are adiabatic, so Q=0, I don't
know yet how to fit the lines but i do know that y = a / (x^(5/3))
is a formula that works, I just need to find the proper a values
for steps 2 and 4.
Part two of this issue is that currently the graph is drawing
as the whole canvas, which is fine for testing until i get the
multiple line part worked out; however I only want this to be 1/4
of the viewing area as I have other movie clips and such to put on
this. A conceptual drawing of what I plan on making can be found
at:
http://www.students.bucknell.edu/gbement/Steps.html
I'm a novice to Actionscript and movie clips, I previously
did everything with motion tweens and nothing was dynamic. I plan
on creating the piston and molecule simulation in another movie
clip, then I can vary the play speed relative to the hot and cold
temperatures by looping the movieclip and having it play faster for
a high T and slower for a low T.
Any help on any of my many issues would be greatly
appreciated and the user will be recognized for their assistance in
my research presentation :)Hi Arun, thanks again for the help but upon closer inspection
(along with only a basic knowledge of java and actionscript), I
think your script would need editing to work for me (editing i'm
unsure of how to do). What I'm looking for is a graph that will
create a line based on a function. Much like y=(a*b*c)/x or
y=(a*b*c)/(x^1.66) The a*b*c would be complicated also, but here's
what i've thought up on paper that I have to move to script, I hope
this is useful:
Step 1: Calculate the a*b*c
The original function is PV=nRT , nRT being the a*b*c ,
however the Thot and Tcold terms are input boxes that the user
types in before hitting the "go" button.
So I have to do this much:
tcold = Number(tcold_num.text);
thot = Number(thot_num.text);
var n:Number = 1;
var R:Number = 0.0825;
var a:Number;
var b:Number;
var c:Number;
var d:Number;
a = n*R*thot // Step 1 constant
b = // Step 2 constant (formula to be finished :-/) Looks to
be a formula using ((b) / (Math.pow(x, 1.666)))
c = n*R*tcold // Step 3 constant
d = // Step 4 constant (formula to be finished :-/)
Then I need to find a way to initialize axis to line the
graph, I can label the P and V axis using static text boxes later I
suppose.
The problem I have with yours that I don't understand is that
I could add the function into the y part of the addLine() function,
however it's noted as inity= y1 (requires a number), and the
function definition has y1:Number.
Now the issue i'm tackling below is just a newbie's lack of
understanding (i hope), but the script kglad wrote (snipped below)
will graph one line, and i can't figure out for the life of me how
to write this up to graph more than one instance without
overwritting the previous line. Again, Thanks for the help so far,
it has helped me find the points where I lacked direction and solid
ideas before. -
Multiple symbols for line graph in illustrator
I can't figure out how to change the default square data points in a line graph. When I try to got to Object>Graph>Marker it is greyed out. When I click on a circle symbol and then try to go to Object>Graph>Design, it is greyed out. I am so frustrated trying to do the simplest things in this program. The online tutorials on how to make graphs do not seem to explain the simplest of tasks, only the difficult. Thanks for any help!
Skeptic,
Yes, it's cumbesome, but it's described in Online Help (at least in CS3 and prior):
Draw whatever you want to use for the marker. (It can be a Symbol; doesn't matter.)
Draw a rectangle and send it behind the marker artwork. For a marker on a line chart, the size of the rectangle relative to the marker art defines the scale.So the rectangle can be smaller than the artwork to make the artwork larger, as shown above. The rectangle can be unstroked, unfilled so it doesn't show.
Select both the artwork and the rectangle. Group. Leave it selected.
Object>Graph>Design. In the dialog, click New Design. Click OK.
Black pointer: Select the graph. Object>Graph>Marker. In the dialog, select the Design you just created. Or...
White pointer: AltClick a single marker in the Graph. AltClick it again to "select up" (Illustrator's upside-down selection scheme) to the parent group. AltClick again to include the legend marker. Object>Graph>Marker. In the dialog, select the Design. This way, you can assign different markers to the various lines in the line graph if you want.
JET -
Exporting from a 2D line graph with .jpeg extension
Is there any way to export from an ordinary 2D line graph with .jpeg extension so that with using this image i will improve my result of exporting excel.
e.g. i have found and example and added a button as you will see when you run this code.I will click this button and it will export this line graph with extension .jpeg so that i will see it as an ordinary image at my home directory.
Thanks for any helpful comment
Regars,
Serhat
* To change this template, choose Tools | Templates
* and open the template in the editor.
* @author led1433
import java.awt.*;
import java.awt.font.*;
import java.awt.geom.*;
import javax.swing.*;
public class LineGraph
public static void main(String[] args)
int x1 = 1000,y1 = 0;
JFrame f = new JFrame();
JButton exportToJPegButton = new JButton("EXPORT WITH JPEG");
exportToJPegButton.setToolTipText("Exports Graph with extension *jpeg");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
exportToJPegButton.setSize(200,25);
f.add(exportToJPegButton).setLocation(x1, y1);
f.getContentPane().add(new GraphPanel());
f.setSize(400,400);
f.setLocation(200,200);
f.setVisible(true);
class GraphPanel extends JPanel
final int
HPAD = 60,
VPAD = 40;
int[] data;
Font font;
public GraphPanel()
data = new int[] {
120, 190, 211, 75, 30, 290, 182, 65, 85, 120, 100, 101
font = new Font("lucida sans regular", Font.PLAIN, 16);
setBackground(Color.white);
protected void paintComponent(Graphics g)
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2.setFont(font);
FontRenderContext frc = g2.getFontRenderContext();
int w = getWidth();
int h = getHeight();
// scales
float xInc = (w - HPAD - VPAD) / 11f;
float yInc = (h - 2*VPAD) / 10f;
int[] dataVals = getDataVals();
float yScale = dataVals[2] / 10f;
// ordinate
g2.draw(new Line2D.Double(HPAD, VPAD, HPAD, h - VPAD));
// tic marks
float x1 = HPAD, y1 = VPAD, x2 = HPAD - 3, y2;
for(int j = 0; j < 10; j++)
g2.draw(new Line2D.Double(x1, y1, x2, y1));
y1 += yInc;
// labels
String text; LineMetrics lm;
float xs, ys, textWidth, height;
for(int j = 0; j <= 10; j++)
text = String.valueOf(dataVals[1] - (int)(j * yScale));
textWidth = (float)font.getStringBounds(text, frc).getWidth();
lm = font.getLineMetrics(text, frc);
height = lm.getAscent();
xs = HPAD - textWidth - 7;
ys = VPAD + (j * yInc) + height/2;
g2.drawString(text, xs, ys);
// abcissa
g2.draw(new Line2D.Double(HPAD, h - VPAD, w - VPAD, h - VPAD));
// tic marks
x1 = HPAD; y1 = h - VPAD; y2 = y1 + 3;
for(int j = 0; j < 12; j++)
g2.draw(new Line2D.Double(x1, y1, x1, y2));
x1 += xInc;
// labels
ys = h - VPAD;
for(int j = 0; j < 12; j++)
text = String.valueOf(j + 1);
textWidth = (float)font.getStringBounds(text, frc).getWidth();
lm = font.getLineMetrics(text, frc);
height = lm.getHeight();
xs = HPAD + j * xInc - textWidth/2;
g2.drawString(text, xs, ys + height);
// plot data
x1 = HPAD;
yScale = (float)(h - 2*VPAD) / dataVals[2];
for(int j = 0; j < data.length; j++)
y1 = VPAD + (h - 2*VPAD) - (data[j] - dataVals[0]) * yScale;
if(j > 0)
g2.draw(new Line2D.Double(x1, y1, x2, y2));
x2 = x1;
y2 = y1;
x1 += xInc;
private int[] getDataVals()
int max = Integer.MIN_VALUE;
int min = Integer.MAX_VALUE;
for(int j = 0; j < data.length; j++)
if(data[j] < min)
min = data[j];
if(data[j] > max)
max = data[j];
int span = max - min;
return new int[] { min, max, span };
}GraphPanel stays the same.
public class JpegExport {
public static void main(String[] args) {
final GraphPanel graphPanel = new GraphPanel();
JButton exportToJPegButton = new JButton("EXPORT WITH JPEG");
exportToJPegButton.setToolTipText("Exports Graph with extension *jpeg");
exportToJPegButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
exportToJpeg(graphPanel);
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(exportToJPegButton, BorderLayout.NORTH);
f.getContentPane().add(graphPanel, BorderLayout.CENTER);
f.setSize(400, 400);
f.setLocationRelativeTo(null);
f.setVisible(true);
private static void exportToJpeg(GraphPanel graphPanel) {
try {
int w = graphPanel.getWidth();
int h = graphPanel.getHeight();
BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = image.createGraphics();
graphPanel.paint(g2);
g2.dispose();
ImageIO.write(image, "jpeg", new File("export.jpg"));
} catch (IOException e) {
e.printStackTrace();
} -
Hi ,
I am developing dvt line graph for two object AX and BY .Graph is designed in such a way that at particular point of time it will intersect .
Whenever it will intersect i want to identify point of intersection and draw a vertical dotted line .
Can anyone help me how can i approach for this design .
Thanks ,
Arun.Hi Frank ,
As per your opinion i cant get vertical dotted line for point of intersection ?
Thanks ,
Arun. -
I have a series of data
01-JAN-2008 10
01-FEB-2008 20
01-MAR-2008 30
01-DEC-08 30
and some data for 2009
01-JAN-2009 5
01-FEB-2009 10
01-MAR-2009 20
01-APR-2009 30
I am trying to produce a rolling 12 month Graph with the Month as the label and Year as the colour. So if my current data was for May 2009 I'd see the following Axis for Month:
Jun Jul Aug Sept Oct Nov Dec Jan Feb Mar Apr May
I'd expect to see:
. line from Jun ending in December for 2008 series.
. line starting in Jan ending in May for 2009 series.
My problem is the line graph default behaviour seems to be to assume a value of 0 where there are no Axis points, drawing the line to 0, not simply ending the line.
Has anyone attempted to do anthing like this?
Thanks for your help.I'm surprised that you're not able to find this functionality yourself, because it is just under one of the chart option icons.
To be specific: click on the axis scaling icon, then click on Edit Scale Markers, click add. You can choose for a line or range.
Regards,
Stijn -
Hi,
Could anyone plz provide me with an application to draw line graph using draw2d?or maybe useful links if such a code is freely available..thnx in advanceHere is a rough example
http://forum.java.sun.com/thread.jsp?forum=20&thread=543227
Bamkin -
Line Graph will be broken on the different lines issue
Hi, While I create a line graph which Horizontal Axis is date, if just has one line then the line is a continuous line from start date to end date,
but if have more than 2 lines and if these lines do not have values on one same date then these lines will be broken
my question is does this correct ? Our requirement is that these lines should be continuous, can the line graph do that ?Your post is unclear, but I think you want to do the following:
Acquire 2D intensity data from a CCD array and plot it on an intensity graph
Draw two lines to delineate an area of interest
Integrate the values of the CCD between these two lines
This is relatively straightforward, but you will need a more complex architecture than the one you currently have. You will need to use the event structure and probably should have a task handling loop, as well. This architecture is known by several things, but "event-driven state machine" is probably the most common. Search these forums for that phrase and you will get lots of information.
For your particular problem:
In your event structure, you will need events to handle drawing the line (could be mouse or button/parameter driven, or both), events to calculate the integral, and the usual start/stop/data acquisition things. Note that all these events should only generate commands for your command processor/state machine to handle. These will be send via queue.
In your queue-driven state machine / task handler, you will need a shift register to hold such variables as the line data (both of them), local copy of the intensity graph data, etc.
The different frames of the case statement (or dynamically dispatched VIs if you go the object oriented route) do the actual work.
You should learn about the event structure and queue driven state machines before starting this. Start with the LabVIEW help, then search these forums for additional info. For example, I believe altenbach posted a demo awhile back of the event structure in which he drew a polygonal line.
Good luck. Let us know if you need more info.
This account is no longer active. Contact ShadesOfGray for current posts and information.
Maybe you are looking for
-
Problem with gui_download
Hi, in my gui_download function I'm passing the 'ASC' value to the parameter filetype but, once I go to the txt file downladed and I try to save it as a csv file I realise that it's of type UTF-8 and not an ASCII type. Can anybody tell me why the fil
-
I got a new nano l am unable to connect it on my computer, l have windows 8. I have deleted itunes and downloaded back on my computer, l still am unable to connect my nano to my computer. When l put my nano on the computer itunes saids "Accessing Itu
-
Need help in customising OOTB Report
Hi, In OIM-->reports-->Operational reports-->OIM password expiration report, the input values are user id, firstname, lastname and date range. Can we customize this report so that it takes only date range as input? I want to remove other input values
-
How to have button in down state as page opens
On opening a new "blank" subsidiary page using "getURL", there are 2 buttons on the new page. Each button plays a moveclip. (The first movieclip is already playing as the new page opens). I'd like to have the corresponding button already in the down
-
FInder crash when viewing Preferences folder
I am getting a repeatable Finder crash when scrolling through my User/Library/Preferences folder. This happens when in Column view. Finder does not crash when in Icon or List view. I did get one crash when in CoverFlow view, but it took a lot of scro