Bar Charts

new BookmarkLockedFalling
metro
Full Member
***

metro Avatar

Posts: 207

Intel Core2 QUAD CPU @2.54 x 4 Mint Linux 19.3 Mate
merkat
New Member
*

merkat Avatar

Posts: 2

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

Last Edit: Mar 26, 2017 10:11:48 GMT -5 by merkat
metro
Full Member
***

metro Avatar

Posts: 207

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!

Intel Core2 QUAD CPU @2.54 x 4 Mint Linux 19.3 Mate
neal
Full Member
***

neal Avatar

Posts: 104

metro
Full Member
***

metro Avatar

Posts: 207

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

'JAVASCRIPT call JS function wiper()
html "<script>wiper();</script>"
this may eventually sink in ::)
Last Edit: Mar 26, 2017 20:45:51 GMT -5 by metro
Intel Core2 QUAD CPU @2.54 x 4 Mint Linux 19.3 Mate