Chart

Posted: 2017-01-17 in Chart
Q:
in a web app how do I create a chart with dynamic data from a vt_table?
A:

You can use {…} macros in many places where you would normally specify a comma separated list of values. This {…} macro can contain a custom procedure that is called to substitute the value returned from it. Typically in the case of charts it should return a comma separated list.

e.g.

{getSomeData(args,...)}
These {…} macros can be also specified as part of page headers, section headers, section footers etc.

Macros are not commands. They are used to substitute expressions into an attribute.

For example.

Let’s say you have a section header caption like this.

Customer is {customers.name}

Then as the section header is updated as you navigate between records the caption will display the current customer name.

These {…} macros can be used in the attributes for UI elements so that the value is dynamic and context sensitive to the current data you are viewing.

.rsp page that generates the Gantt chart probably needs to have the following in the
<meta charset=”UTF8“>
If you rtrim() the names and they will be right justified next to the gantt chart.

Q:

I’m doing some tests with charts.

If you recall a graph with the command:

Code:
       m_data = "1,2,3,3,4,5|1,2,3"
        m_keylabels = "a,b"
        m_labels = "1,2,3,4,5"
        
        m_url = "lib:/graph_line.rsp?data=" + m_data + "&keylabels=" + m_keylabels + "&labels=" + m_labels + "&title=" + m_title            
        
        lianja.get("Scout.SectionChart").url = m_url
I get this:
2016-02-11 16_08_52-Lianja App Builder v2.1Beta8 [scout] - UTF-8 - scout - Licensed to Soft up S.png
It is not possible to do so that the second line, the green one, occupies only the first 3 points of the graph, without stretching up to 5?
A:
No, the line chart you refer to gas a max and min value and the graph is rendered based on that.
Maybe you should be using a bar chart or a Gantt chart.
A2:

I try with a bar chart.

I noticed that if I send a “null” value, the graph is correct …

but you can not decide on the vertical scale is always 100 …
2016-02-12 08_50_35-Lianja App Builder v2.1Beta8 [scout] - UTF-8 - scout - Licensed to Soft up S.png

Q:
I’m having problems to show the progression of the tasks as I’m unable to build an array that passes the correct type of information to the chart, as I need to pass it in the following format: [int,int,int,str]. So, I’m able to build an array that passes this as an string but it doesn’t work. Any idea? This is the code I’m using for the function. I’ve build also an script (yeardays) that convert a date to a number of days, so the user inserts a date but the script passes an int to the array. etd is the initial date, eta is the due date, accomplishment is the percentage of accomplishment and name is the name of the task
select id from tareas where project=p_project into array numtareas
 select etd from tareas where project=p_project into array etds
 select eta from tareas where project=p_project into array etas

 select accomplishment where project=p_project from tareas into array accomplishments
 select name from tareas where project=p_project into array names
 declare tab[alen(numtareas,1),4]
 declare gantt[alen(numtareas,1)]
 for o=1 to alen(tab,1)
 tab[o,1]=yeardays(etds[o])
 tab[o,2]=yeardays(etas[o])-yeardays(etds[o])
 tab[o,3]=accomplishments[o]
 tab[o,4]=names[o]
 gantt[o]=concat("[",str(tab[o,1]),str(tab[o,2]),str(tab[o,3]),"'",tab[o,4],"'","]")
 endforreturn implode(',',gantt)
A:
If you need format [int,int,int,str], then I do not see that you put sign “,” in your concat. Try in console this CONCAT expression first

Code:
gantt[o]=concat("[",str(tab[o,1]),str(tab[o,2]),str(tab[o,3]),"'",tab[o,4],"'","]")

When I simulate with this code:

Code:
declare tabx[1,4]
declare gantt[1,1]
tabx[1,1]=11
tabx[1,2]=12
tabx[1,3]=13
tabx[1,4]='MyName'
gantt[1,1]=concat("[",str(tabx[1,1],2,0),str(tabx[1,2],2,0),str(tabx[1,3],2,0),"'",tabx[1,4],"'","]")
?gantt[1,1]

… I get this;

Code:
[111213'MyName']

Correct CONCAT:

Code:
gantt[1,1]=concat("[",str(tabx[1,1],2,0),",",str(tabx[1,2],2,0),",",str(tabx[1,3],2,0),",'",tabx[1,4],"'","]")

and result is:

Code:
[11,12,13,'MyName']

Q:
The problem now are the Gantt labels.
A:
Gantt is another problem with accents.
I applied Berry’s soulution (I edited graph_gantt.rsp in your app)…:
_SP32-20151110-134536.jpg
…and it works, showing your accent letters:
 _sp32-20151110-134941
A:
tab[o,4]=padr(names[o],30,’ ‘)
If you rtrim() the names and they will be right justified next to the gantt chart.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s