metro
Full Member
Posts: 180
|
Post by metro on Mar 26, 2017 3:46:14 GMT -5
Any chance some one can advise on how to create a Bar chart, Ive looked at www.rgraph.net/demos/effects-bar-wave.htmlbut have no idea how to implement it with RB. There may be other options any advice appreciated metro
|
|
|
Post by merkat on Mar 26, 2017 9:19:16 GMT -5
Hello Down Under..
I thought you disappeared..
Try something like this and see if it works for you.
barWidth = 600
mth$ = "JanFebMarAprMayJunJulAugSepOctNovDec"
dim clr$(5)
clr$(1) = "green"
clr$(2) = "blue"
clr$(3) = "yellow"
clr$(4) = "orange"
clr$(5) = "red"
html "<TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0>"
html "<TR BGCOLOR=silver><TD>Month</TD><TD WIDTH=";barWidth;" align=center>Sales</TD></TR>"
for i = 1 to 12
salesPcnt = rnd(1) * 100
c = salesPcnt / 20 + 1
html "<TR><TD>";mid$(mth$,i*3-2,3);"</TD><TD><TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=";salesPcnt;"% BGCOLOR=";clr$(c);"><TR><TD> </TD></TR></TABLE></TD></TR>"
next i
html "</TABLE>"
For vertical bars
barHeight = 400
mth$ = "JanFebMarAprMayJunJulAugSepOctNovDec"
dim clr$(5)
clr$(1) = "green"
clr$(2) = "blue"
clr$(3) = "yellow"
clr$(4) = "orange"
clr$(5) = "red"
html "<TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0><TR>"
for i = 1 to 34 step 3
html "<TD>";mid$(mth$,i,3);"</TD>"
next i
html "</TR><TR valign=bottom HEIGHT=";barHeight;">"
for i = 1 to 12
salesPcnt = rnd(1)
salesPix = salesPcnt * barHeight
c = salesPcnt * 5
html "<TD><TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100% HEIGHT=";salesPix;" BGCOLOR=";clr$(c);"><TR><TD align=center>";int(salesPcnt*100);"</TD></TR></TABLE>"
next i
html "</TR></TABLE>"
HTH Have a g'day.. Dan
|
|
metro
Full Member
Posts: 180
|
Post by metro on Mar 26, 2017 19:08:11 GMT -5
G'day Dan
Nope, haven't disappeared, its just that I get the urge to code something every few months however having the attention span of a goldfish means nothing gets finished as I spend too much time re-leaning. Mind you not a lot happening here which is a shame.
Thanks for the code above, that will do very nicely.
I would like to be able to use Javascript too at some stage, are you or others aware of any articles that explain how to use it with Runbasic?
thanks for four help yet again..
Laurie
PS ... home brew on tap now, I'll have one for you tonight... hope you like Coopers larger!
|
|
neal
Full Member
Posts: 104
|
Post by neal on Mar 26, 2017 20:02:44 GMT -5
If you want to use javascript - I've been using Highcharts (http://www.highcharts.com/). It's free for non-commercial use and pretty easy to use.
|
|
metro
Full Member
Posts: 180
|
Post by metro on Mar 26, 2017 20:18:53 GMT -5
Thanks Neal, I'll take a look... Ok after some looking around am I right that javascript functions are placed in the head element like the example below head "<script> // JavaScript Wiper Function
function wiper() { var myProgram=document.getElementById('program'); myProgram.innerHTML=""""; }
// Note that nothing goes in the quotations. This sets the innerHTML to nothing, and blank.
</script>"
and then called within the RB program when required this may eventually sink in
|
|