ATTENTION

This FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices.


flexsim.com

Go Back   FlexSim Community Forum > FlexSim Software > Flexsim Student Forum
Downloads

Flexsim Student Forum Forum for discussion for Flexsim Students using the Flexsim Textbook.

  #1  
Old 12-18-2013
mearjun mearjun is offline
Flexsim User
 
Join Date: Feb 2012
Posts: 123
Downloads: 5
Uploads: 0
Thanks: 27
Thanked 19 Times in 11 Posts
Rep Power: 119
mearjun will become famous soon enough
Default Trouble making a custom line graph

I am trying to build a custom line graph in a custom GUI.
What I thought of doing was to use the drawline command to draw the line graph in increments. the problem is everytime it draws the next increment of the line the previous one disappears and instead of a line I see a worm moving!! . here is the code that I used in the ondraw attribute of the graph:

treenode view = c;
treenode waiting_area = node(">viewfocus+",view);

double yvalue = getlabelnum(waiting_area,"Avg_WTBS");
double xvalue = getlabelnum(waiting_area,"PatientNumber")*.1;
int lastx = getlabelnum(centerobject(waiting_area,1),"lastx");
int lasty = getlabelnum(centerobject(waiting_area,1),"lasty");

drawline(view,lastx,lasty,0,xvalue+1,yvalue,0,1,0, 1);

setlabelnum(centerobject(waiting_area,1),"lastx",x value + 1);
setlabelnum(centerobject(waiting_area,1),"lasty",y value);

Last edited by mearjun; 12-19-2013 at 12:50 AM.
  #2  
Old 12-19-2013
Esther Bennett Esther Bennett is offline
Flexsim User
 
Join Date: Mar 2008
Posts: 115
Downloads: 27
Uploads: 0
Thanks: 103
Thanked 116 Times in 50 Posts
Rep Power: 271
Esther Bennett is a name known to allEsther Bennett is a name known to allEsther Bennett is a name known to allEsther Bennett is a name known to allEsther Bennett is a name known to allEsther Bennett is a name known to all
Default

Hello mearjun,

You are drawing one (moving) point every time. Every time the OnDraw code is refreshed it starts with a blank sheet. If you want to draw 10 line segments, you will have to call the drawline command 10 times (you can use a for loop). For every segment you have to determine the start and end point.

It could look something like:

treenode view = c;
treenode waiting_area = node(">viewfocus+",view);

double yvalue = getlabelnum(waiting_area,"Avg_WTBS");
double xvalue = getlabelnum(waiting_area,"PatientNumber")*.1;
int lastx = getlabelnum(centerobject(waiting_area,1),"lastx");
int lasty = getlabelnum(centerobject(waiting_area,1),"lasty");

int nrOfLines = 10;

for( int x = 1; x <= nrOfLines; x++ )
{
drawline(view,lastx,lasty,0,xvalue+1,yvalue,0,1,0, 1);
lastx++; // adds 1 to the lastx value
}

Esther
The Following User Says Thank You to Esther Bennett For This Useful Post:
Jörg Vogel (12-19-2013)
  #3  
Old 12-20-2013
mearjun mearjun is offline
Flexsim User
 
Join Date: Feb 2012
Posts: 123
Downloads: 5
Uploads: 0
Thanks: 27
Thanked 19 Times in 11 Posts
Rep Power: 119
mearjun will become famous soon enough
Default

Thanks for answering but I am not clear yet..Here is what I am trying to do. I want that whenever the value of a particular label changes a new point in the graph should be found such that new y is the label value and x increments by 1. When you say that I should use a for loop, how would I have all the possible values of y (label values) at one time ?
Maybe what I need to do is that the line I draw should be a permanent line and the ondraw trigger should not refresh the entire canvas the next time so that a curve is generated with the help of 1000s of small lines.
  #4  
Old 12-20-2013
Jörg Vogel's Avatar
Jörg Vogel Jörg Vogel is offline
Flexsim User
 
Join Date: Sep 2007
Location: Hannover, Germany
Posts: 643
Downloads: 35
Uploads: 0
Thanks: 802
Thanked 665 Times in 410 Posts
Rep Power: 642
Jörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond repute
Default

Hello,

you have to store all the values you want to print in the graph. You can use different methods to store values (table, tracked variables, bundles).

Jörg
The Following 3 Users Say Thank You to Jörg Vogel For This Useful Post:
Steven Hamoen (12-20-2013)


Thread Thread Starter Forum Replies Last Post
Add Graph to custom GUI mearjun Flexsim Student Forum 0 12-17-2013 04:41 AM
Custom GUI: Graph OnDraw Phil BoBo Tips and Tricks 2 05-16-2013 03:48 AM
trouble overriding begintask() for a custom module Vadim Fooks Q&A 2 04-08-2013 12:23 AM
Show global variable as line graph in Recorder Congshi Wang Q&A 1 12-08-2010 01:22 AM
Need Example Graph in a UI ( With the Graph Control) Gleny Rodriguez Q&A 2 06-09-2010 08:31 AM


All times are GMT -6.
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.