|
|
|
| |
|
Generating Real Time Graphs with Webimpetus
|
|
Introduction
|
 |
|
By Balinder S Walia, Systems Developer (Tenthmatrix Information Systems Ltd) Technical Notes for January 2006 Document revision : 1.2 Webimpetus has in-built graphing and charting scripting language which generates real time graphs from the given set of commands and data. Various kinds of graphs can be created with in-built graph generator and literally any part of the graph can be defined and controlled by this sophiticated set of commands: Commands available which should be defined as attributes of the main tag are as follows: - Graph_Height - Define graph image height in format "Integer"
- Graph_Width - Define graph image width in format "Integer"
- Graph_Categories - "Define the data displayed across x axis of the graph in the format equals to category1;category2;category3;....categoryN"
- Graph_Values1 - "Value of first series in the format equals to value1;value2;value3;....valueN"
- Graph_Values2 - "Value of the second series in the format equals to value1;value2;value3;....valueN"
- Graph_Series - "Series1Name;Series2Name"
- Graph_Series.setScaleAuto - Define a boolean value TRUE or FALSE (FALSE in case user will define scale units themselves or TRUE to define automatically depending on minimum and maximum values in the series data
- Graph_Series.minValue - Minimum value of the scale (Starts the scale from this value)
- Graph_Series.maxValue - Maximum value to be shown on the scale
- Graph_Series.maxIncrement - Maximum difference between the units of scale
- Graph_Series.minIncrement - Minimum difference between the units of scale
- Graph_Legend.setAuto - Yes to set Legend automatically, No to define legend yourself
- If Graph_Legend.setAuto is set to No follwing commands can further allow you to display a legend, set it position and it's order of display
- Graph_Legend.display - Yes or No
- Graph_Legend.orientation - Horizontal or Vertical
- Graph_Legend.reverseOrder - Yes or No, It specifies whether the order of the series in the legend is reversed or not
- Graph_Legend.reverseKey - Yes or No, It specifies whether the series label and the key that explains the unique pattern and color of the series are reversed. The default is to show the key to the left of the label.
- Graph_Legend.location - Location of the legend, Possible value can be one these: UseOffsets;TopLeft;BottomLeft;TopRight;BottomRight;Left;Right;Top;Bottom
- If above is set to UseOffsets then following offset values can be passed:
- Graph_Legend.location.horizOffset
- Graph_Legend.location.vertOffse
- Graph_Legend.location.horizOffset and Graph_Legend.location.vertOffset are used when location is set to 0. Graph_Legend.location.horizOffset is expressed in points from the left side of the graph to the left side of the legend. Graph_Legend.location.vertOffset is expressed in points from the top of the graph to the top of the legend.
Any of the commands available above can be passed as an attributes inside the following tag <!--WebImpetusGraph--> as shown below in order to tell Webimpetus to process these commands from a free text object as a graph gif image. Various types of graphs are available in the WebImpetus. After creating the code save the document and you will notice a gif image file is created and attached to the object in which you have written the code. Graph is created dynamically on the fly every type code is written. These commands are very easy to use as in order to create a graph all we have to write code with the above commands and their attribute values, in the format as shown below: <!--WebImpetusGraph ....various attributes to control graph type, color, x, y and series data can be defined here --> Let's write some code to generate a simple graph of type "Area" of size 470 x 280. This graph will display data categorised into months, say we start from month 11/04 and go upto 10/05. Basically it will display series data in monthly intervals for a year. Add values for each series for each month using attribute 'Graph_Values1' and 'Graph_Values2'. So in order to create a graph add the following code in the object box in the caliban editor area and save the document: <!--WebImpetusGraph Graph_Type="Area" Graph_Type_Options="Area;Column;Picture;Line;Scatter;Pie;Polar;2D_XY;3D_Column;3D_Line;3D_Area;3D_Surface;3D_Triangle;3D_Spike;Random" -- | Lets add graph image width and height using attributes 'Graph_Width' and 'Graph_Height' |-- Graph_Width="470" Graph_Height="280" --| Lets add some categories in which we want to display graph data 'Graph_Categories' Graph_Categories="11/04;12/04;01/05;02/05;03/05;04/05;05/05;06/05;07/05;08/05;09/05;10/05" Graph_Values1="4;5;6;5;5;6;7;5.5;5;6;5;5" Graph_Values2="6;7;4;6;5.5;5;4.5;6;6;5;5;4" Graph_Series="Response time;Average" Graph_Series.colors="orange;blue" Graph_Series.setScaleAuto="false" Graph_Series.minValue="0" Graph_Series.maxValue="12" Graph_Series.maxIncrement="1" Graph_Series.minIncrement="0.1" //set graph legend options Graph_Legend.setAuto="false" Graph_Legend.display="yes" yes/no Graph_Legend.orientation="Horizontal" Horizontal/Vertical Graph_Legend.reverseOrder="no" yes/no Graph_Legend.reverseKey="no" yes/no Graph_Legend.location="Top" Graph_Legend.locationoptions=UseOffsets;TopLeft;BottomLeft;TopRight;BottomRight;Left;Right;Top;Bottom Graph_Legend.location.horizOffset="" Graph_Legend.location.vertOffset=" --> Conclusion: Creating and maintaining different types of graphs is easy with Webimpetus. A non technical person with no graphic design skills can create graphs and charts. See the example code and how it renders below: <!--WebImpetusGraph Graph_Type="Area" Graph_Type_Options="Area;Column;Picture;Line;Scatter;Pie;Polar;2D_XY;3D_Column;3D_Line;3D_Area;3D_Surface;3D_Triangle;3D_Spike;Random" Graph_Width="470" Graph_Height="280" Graph_Categories="11/04;12/04;01/05;02/05;03/05;04/05;05/05;06/05;07/05;08/05;09/05;10/05" Graph_Values1="4;5;6;5;5;6;7;5.5;5;6;5;5" Graph_Values2="6;7;4;6;5.5;5;4.5;6;6;5;5;4" Graph_Series="Response time;Average" Graph_Series.colors="orange;blue" Graph_Series.setScaleAuto="false" Graph_Series.minValue="0" Graph_Series.maxValue="12" Graph_Series.maxIncrement="1" Graph_Series.minIncrement="0.1" //set graph legend option Graph_Legend.setAuto="false" Graph_Legend.display="yes" yes/no Graph_Legend.orientation="Horizontal" Horizontal/Vertical Graph_Legend.reverseOrder="no" yes/no Graph_Legend.reverseKey="no" yes/no Graph_Legend.location="Top" Graph_Legend.locationoptions=UseOffsets;TopLeft;BottomLeft;TopRight;BottomRight;Left;Right;Top;Bottom Graph_Legend.location.horizOffset="" Graph_Legend.location.vertOffset="" -->
|
|
|
|
|
How it renders
|
|
|
|
|
Another example of graph type: 3D_Column
|
|
|
|
|
Creating different types of graphs randomly
|
|
|
|
|
Creating a Pie graph
|
|
|
|
| |
|
|
|
|
|