Email conversation
From | Rob Wagner |
To | Me |
Subject | multigraph script |
Date | 12 November 2003 20:41 |
wow, that's a heck of a script!
i have two questions.
1) can i separate the columns more. as it is, each colum runs right up to
the next. with multiple data sets the bar charts can become confusing.
2) i was wondering if it would be possible to define background images
rather than background colors for the bars in the chart. i was thinking
about creating images which when tiled as a background would create a
shaded image for the bars. have you tried this?
once again, i really like that script. and the error handling is pretty
darned good too! thanks a lot. -rob
From | Me |
To | Rob Wagner |
Subject | Re: multigraph script |
Date | 13 November 2003 15:53 |
Rob,
Glad you like it.
I have not provided a way to put gaps between bars in the same data
range, but if you replace the first occurance of
this.rotate?scaleSize:offWidth,this.rotate?offWidth:scaleSize
with
this.rotate?scaleSize:offWidth-1,this.rotate?offWidth-1:scaleSize
in the script source, then an extra pixel gap will appear down the edge of
each bar, making them separate from each other. It may have a few minor
rendering bugs in extreme circumstances - 1px wide bars will disappear
etc. - (which is why I do not offer it as an option), but for most graphs,
it will look perfect.
I had hoped that the configurable colours would be enough to make the bars
distinguishable from each other.
As for images, I have not provided any way to do this, mainly because the
width of the bars may change, so the tiling effect would only work if you
managed to make everything pixel perfect (note that some bars are one
pixel wider than others to fill up the available space). Also, one of the
important things about the way I wrote the script is that it does not use
any images at all, making it very lightweight - but that's just a matter
of my pride ;)
If you want to enable images, you will need to do some more editing:
replace the last occurance of:
background-color
with
background
and replace
bgcolor="'+oC+'"
with
background="'+oC+'"
and replace
bgcolor="'+this.colours[x]+'"
with
background="'+this.colours[x]+'"
and replace
if( typeof( oCol ) != 'string' || oCol.length != 7 || oCol.charAt(0) != '#' ) {
with
if( typeof( oCol ) != 'string' ) {
You will then ONLY be able to use images, not colours for the
bars/columns.
Tarquin - author of http://www.howtocreate.co.uk/
From | Rob Wagner |
To | Me |
Subject | RE: multigraph script |
Date | 13 November 2003 16:02 |
thanks for the edits. i'll give them a try.
if i end up using this script, it will be in a pretty well controlled
environment, so i'm not really worried about rendering irregularities.
thanks again for your time. I really appreciate it.
-rob
From | Rob Wagner |
To | Me |
Subject | Need help on using multiple slider controls |
Date | 18 January 2004 23:16 |
hi there.
i love this slider control of yours. i can see a lot of uses for it. i can
see that it is possible to use multiple sliders on one page. i have three
in my test page now:
var temper = new slider {...}
var density = new slider {...}
var salinity = new slider {...}
with the following stop function:
function stopFunction(sliderPosition) {
alert("Slider is showing "+sliderPosition);
}
which, of course, results in "Slider is showing 0.459354967" when i move a
slider.
now this works fine on each of my three sliders. but what i would like to
know is which slider is in use so i know what set of data to calculate with.
for instance, then i could have an alert like this:
Slider #1 is showing 0.111111111.
Slider #2 is showing 0.222222222.
Slider #3 is showing 0.333333333.
it seems that the slider must know which one it is, otherwise how would it
know which position to return? so how can i access that information? my
mediocre javascript talents are exhausted.
any help would be great. i'm sorry i a url, but i'm only working locally
for the time being.
thanks a lot.
-rob
From | Me |
To | Rob Wagner |
Subject | Re: Need help on using multiple slider controls |
Date | 19 January 2004 08:48 |
Hi again Rob,
This is easily possible. The sliders have no concept of which slider they
are, all they know is 'I am me', but they do not hold an individual
reference to themselves. This is why the sliders do not pass that
information to the function. However, you can use any function name(s) you
like, you are not restricted to using 'stopFunction'. This means that each
slider can run its own function, instead of running the same function as
the other sliders. Each function can then do something different, or could
simply pass values to another function, along with the number or name of
the slider (as I have shown below).
eg
var temper = new slider(
...
'moveFunction',
'stopFunction',
...
);
var density = new slider(
...
'myMoveFunction',
'myStopFunction',
...
);
var salinity = new slider(
...
'yourMoveHandler',
'yourStopHandler',
...
);
function yourMoveHandler(oPos) {
//this function will be called by slider3 (and only slider3) as it is moving
}
... etc ...
if you then want all sliders to run the same function, but to tell it which
slider they are, try this:
function moveFunction(oPos) { globalMove(oPos,'temper'); }
function myMoveFunction(oPos) { globalMove(oPos,'density'); }
function yourMoveHandler(oPos) { globalMove(oPos,'salinity'); }
function stopFunction(oPos) { globalStop(oPos,'temper'); }
function myStopFunction(oPos) { globalStop(oPos,'density'); }
function yourStopHandler(oPos) { globalStop(oPos,'salinity'); }
function globalMove(oPos,oSlider) {
window.status = 'Slider '+oSlider+' at position '+oPos;
}
function globalStop(oPos,oSlider) {
alert('Slider '+oSlider+' at position '+oPos);
}
You could even pass the reference to the slider object if you wanted to
(note the lack of quotes, I am just passing the variables you created):
function stopFunction(oPos) { globalStop(oPos,temper); }
function myStopFunction(oPos) { globalStop(oPos,density); }
function yourStopHandler(oPos) { globalStop(oPos,salinity); }
function globalStop(oPos,oSlider) {
oSlider.setPosition(0.5);
alert('Ha! Ha! I moved it back.')
}
Does all of that make sense?
Tarquin
From | Rob Wagner |
To | Me |
Subject | Re: Need help on using multiple slider controls |
Date | 19 January 2004 14:05 |
mark,
of course! yes, that makes perfect sense. and now that you've explained
it i can't imagine how i missed it myself. i'll give that a try, and i
have no doubt it will solve my problem.
thanks a million,
-rob