How to make a Server Library
Make sure there isn't already a library written.
Get a library for your language that can write JSON.
Take a look at the JSON format that Open FLash Chart reads. Then take a look at the
PHP library (it is very simple) to see how it creates little objects, then
JSONs these. This is what you will need to do.
When you have something working, email it to us, or post it on the forums. No
one cares if it isn't the most perfect code in the world, 95% of the effort is
creating a little code from nothing. Polishing the code, squashing bugs and
extending it is simple in comparison! (That is the other 95% of the effort ;-) haha,
just a little joke. Even if it is true.)
So even five or ten lines of code will be enough to give us something to look at and work with.
If your language supports heredoc
then you can use this to simplify the library. For example if you are only interested
in changing the title of a bar chart, then you could embed the JSON data into your
code.
This is pseudo code:
$title = "Hello World!";
$json = <<<EOT
{
"title": {
"text": "$title",
"style": "{font-size: 20px; color:#0000ff; font-family: Verdana; text-align: center;}"
},
"elements": [
{
"type": "bar",
"alpha": 0.5,
"colour": "#9933CC",
"text": "Page views",
"font-size": 10,
"values": [9,8,7,6,5,4,3,2,1]
}
],
"x_axis": {
"stroke": 1,
"tick_height": 10,
"colour": "#d000d0",
"grid_colour": "#00ff00",
"labels": ["January","February","March","April","May","June","July","August","Spetember"]
}
}
EOT;
echo $json;
See how we set $title up, then we insert it into the JSON string. Then finally we
echo the entire JSON string out. If that is all the functionality you need, then
this way of making the data file is simple.
|
|