Cobnut
Feb 29th 2008, 9:42 am
I'm building a simple graphing function and would like to include some labels within the bars of the graph; like this:
http://www.cobnut.net/examples/chart.jpg
I've got tests for the width of the bars that increases/decreases the font number (or doesn't show text at all) but I need some way to limit the length of the text dependent upon the size of the bar itself. Ideally, I'd like to be able to say 'if the text gets within x pixels of the top of the bar, then substr it down to a point where it's within the bar'. As it happens, for this particular project I can be fairly certain that the bars are always going to be around 75% of the chart but I can't control the label text itself and some could be longer than those shown on the example.
I suppose what I'm after is some direct equation between the standard font number in imagestring and the 'size' per character.
Anyone have any ideas?
Jon
http://www.cobnut.net/examples/chart.jpg
I've got tests for the width of the bars that increases/decreases the font number (or doesn't show text at all) but I need some way to limit the length of the text dependent upon the size of the bar itself. Ideally, I'd like to be able to say 'if the text gets within x pixels of the top of the bar, then substr it down to a point where it's within the bar'. As it happens, for this particular project I can be fairly certain that the bars are always going to be around 75% of the chart but I can't control the label text itself and some could be longer than those shown on the example.
I suppose what I'm after is some direct equation between the standard font number in imagestring and the 'size' per character.
Anyone have any ideas?
Jon