From 770ba5201f5c60b2bb36602ff9d359f641e33125 Mon Sep 17 00:00:00 2001 From: Yves Fischer Date: Sun, 23 Oct 2011 21:14:40 +0200 Subject: Charting with flask, rgraph and custom "timeseries database" --- schall/static/RGraph/docs/pie.html | 567 +++++++++++++++++++++++++++++++++++++ 1 file changed, 567 insertions(+) create mode 100644 schall/static/RGraph/docs/pie.html (limited to 'schall/static/RGraph/docs/pie.html') diff --git a/schall/static/RGraph/docs/pie.html b/schall/static/RGraph/docs/pie.html new file mode 100644 index 0000000..bd1ffc9 --- /dev/null +++ b/schall/static/RGraph/docs/pie.html @@ -0,0 +1,567 @@ + + + + + + RGraph: HTML5 Javascript charts library - Pie charts documentation + + + + + + + + + + + + + + + + + + + + +
+ + Mention RGraph on Twitter + +
+ + + +
+ + +
+ + + + +

RGraph: HTML5 Javascript charts library - Pie charts documentation

+ + + +

+ The pie chart can be used, for example, to represent something that is akin to percentages. ie A set of data that + should be taken as part of a whole. +

+ +

+ The example file is here. +

+ +
+<script>
+    window.onload = function ()
+    {
+        var data = [564,155,499,611,322];
+    
+        var pie = new RGraph.Pie('myPie', data);
+        pie.Set('chart.labels', ['Abc', 'Def', 'Ghi', 'Jkl', 'Mno']);
+        pie.Set('chart.linewidth', 5);
+        pie.Set('chart.stroke', '#fff');
+        pie.Draw();
+    }
+</script>
+
+ + + + +

Properties

+ +

+ You can use these properties to control how the pie chart looks. You can set them by using the Set() method. Eg: +

+ +

+ myPie.Set('name', 'value'); +

+ + + + + +

Margins

+ + + + + chart.gutter.left
+ The left gutter of the chart, (the gutter is where the labels and title are)).
+ Default: 25

+ + + chart.gutter.right
+ The right gutter of the chart, (the gutter is where the labels and title are).
+ Default: 25

+ + + chart.gutter.top
+ The top gutter of the chart, (the gutter is where the labels and title are).
+ Default: 25

+ + + chart.gutter.bottom
+ The bottom gutter of the chart, (the gutter is where the labels and title are).
+ Default: 25

+ + +

Colors

+chart.colors
+ Colors to be used for the pie segments.
Default: ['rgb(255,0,0)', '#ddd', 'rgb(0,255,0)', 'rgb(0,0,255)', 'rgb(255,255,0)', 'rgb(0,255,255)', 'red', 'pink', 'black', 'white']

+ +chart.strokestyle
+ The color of the seperating lines. By setting this to your background color, and setting the linewidth to approx. 5, it will make the pie chart look "exploded".
Default: #999

+ +

Labels and text

+chart.text.size
+ The size of the text (in points).
Default: 10

+ +chart.text.font
+ The font used to render the text.
Default: Verdana

+ +chart.text.color
+ The color of the labels.
Default: black

+ +chart.labels
+ An array of labels to be used for the chart.
Default: [] (an empty array)

+ + + chart.labels.sticks
+ Stipulates that sticks for the labels are shown.
+ Default: false

+ + + chart.labels.sticks.color
+ Sets the color of the label sticks.
+ Default: #aaa

+ + + chart.labels.sticks.length
+ Sets the length of the label sticks.
+ Default: 7

+ + +

Titles

+ + +chart.title
+ The title of the pie chart.
Default: none

+ + + + +chart.title.font
+The font that the title is rendered in. If not specified the chart.text.font setting is used (usually Verdana)
+Default: null

+ + +chart.title.size
+The size of the title. If not specified the size is usually 2pt bigger than the chart.text.size setting.
+Default: null

+ + +chart.title.bold
+Whather the title is bold or not.
+Default: true

+ + +chart.title.background
+The background color (if any) for the title.
+Default: null

+ + +chart.title.color
+ The color of the title.
Default: black

+ +chart.title.hpos
+ This allows you to completely override the horizontal positioning of the title. It should be a number between 0 and 1, and is multiplied with the whole width of the canvas and then used as the horizontal position.
Default: null

+ +chart.title.vpos
+ This allows you to completely override the vertical positioning of the title. It should be a number between 0 and 1, and is multiplied with the gutter and then used as the vertical position. It can be useful if you need to have a large gutter.
Default: null

+ +

Shadows

+chart.shadow
+ Whether a simple shadow effect is applied.
Default: false

+ +chart.shadow.color
+ The color of the shadow.
Default: rgba(0,0,0,0.5)

+ +chart.shadow.blur
+ The severity of the shadow blurring effect.
Default: 3

+ +chart.shadow.offsetx
+ The X offset of the shadow.
Default: 3

+ +chart.shadow.offsety
+ The Y offset of the shadow.
Default: 3

+ +

Interactive features

+ + + chart.tooltips
+ An array of tooltips, starting from the middle right (ie east) axis, and going clockwise sequentially.
+ Default: [] (An empty array)

+ + + chart.tooltips.event
+ This can be onclick or onmousemove and determines which event is used for tooltips.
+ Default: onclick

+ + + chart.tooltips.effect
+ The animated effect used for showing tooltips. Can be either fade or expand.
+ Default: fade

+ + + chart.tooltips.css.class
+ This is the name of the CSS class the chart uses.
+ Default: RGraph_tooltip

+ + + chart.tooltips.override
+ If you wish to handle showing tooltips yourself, this should be a function object which does just that. There's more + information on the tooltips documentation page
+ Default: null

+ + + +chart.contextmenu
+ An array of context menu items. More information on context menus is here.
Default: [] (An empty array)

+ +chart.annotatable
+ Whether annotations are enabled for the chart (ie you can draw on the chart interactively.
Default: false

+ +chart.annotate.color
+ If you do not allow the use of the palette, then this will be the only colour allowed for annotations.
Default: black

+ + + + + chart.resizable
+ Defaulting to false, this determines whether your chart will be resizable. Because of the numerous event handlers this has to install code on, This feature is unlikely to work with other dynamic features (the context menu is fine however).
+ Default: false

+ + + + chart.resize.handle.background
+ With this you can specify the background color for the resize handle. If you're adjusting the position of the + handle then you may need this to make the handle stand out more.
+ Default: null

+ + + + + + +

Key

+ + + chart.key
+ An array of key information.
+ Default: [] (An empty array)

+ + + chart.key.background
+ The color of the key background. Typically white, you could set this to something like rgba(255,255,255,0.7) to allow people to see things behind it.
+ Default: white

+ + + chart.key.halign
+ Instead of specifying the exact x/y coordinates, you can use this property to simply specify whether the key hould be + aligned left or right.
+ Default: right

+ + + chart.key.position
+ Determines the position of the key.Either graph (default), or gutter.
+ Default: graph

+ + chart.key.position.x
+ This allows you to specify a specific X coordinate for the key.
+ Default: null

+ + chart.key.position.y
+ This allows you to specify a specific Y coordinate for the key.
+ Default: null

+ + chart.key.position.gutter.boxed
+ If you have the key in gutter mode (ie horizontal), this allows you to give a background color.
+ Default: true

+ + + chart.key.shadow
+ Whether a small drop shadow is applied to the key.
+ Default: false

+ + + chart.key.shadow.color
+ The color of the shadow.
+ Default: #666

+ + + chart.key.shadow.blur
+ The extent of the blurring effect used on the shadow.
+ Default: 3

+ + + chart.key.shadow.offsetx
+ The X offset of the shadow.
+ Default: 2

+ + + chart.key.shadow.offsety
+ The Y offset of the shadow.
+ Default: 2

+ + + chart.key.rounded
+ This controls whether the corners of the key (in graph mode) are curved. If the key is gutter mode, this has no effect.
+ Default: false

+ + + chart.key.color.shape
+ This can be square, circle or line and controls how the color indicators in the key appear.
+ Default: square

+ + + chart.key.linewidth
+ The line width of the surrounding border on the key.
+ Default: 1

+ + + chart.key.interactive
+ This option enables the facility to click on the pie chart to highlight (explode only) the relevant segment.
+ Default: false

+ + + + +

Zoom

+chart.zoom.mode
+ Can be used to control whether the zoom is in thumbnail or canvas mode. Possible values are: thumbnail and canvas.
Default: canvas

+ +chart.zoom.factor
+ This is the factor that the chart will be zoomed by (bigger values means more zoom)
Default: 1.5

+ +chart.zoom.fade.in
+ Whether the zoomed canvas fades in or not. This also can be used to control the fade in for the zoom in thumbnail mode.
Default: true

+ +chart.zoom.fade.out
+ Whether the zoomed canvas fades out or not. This also can be used to control the fade in for the zoom in thumbnail mode.
Default: true

+ +chart.zoom.hdir
+ The horizontal direction of the zoom. Possible values are: left, center, right
Default: right

+ +chart.zoom.vdir
+ The vertical direction of the zoom. Possible values are: up, center, down
Default: down

+ +chart.zoom.delay
+ The delay (in milliseconds) between frames.
Default: 50

+ +chart.zoom.frames
+ The number of frames in the zoom animation.
Default: 10

+ +chart.zoom.shadow
+ Whether or not the zoomed canvas has a shadow or not.
Default: true

+ +chart.zoom.thumbnail.width
+ When the zoom is in thumbnail mode, this is the width (in pixels) of the thumbnail.
Default: 75

+ +chart.zoom.thumbnail.height
+ When the zoom is in thumbnail mode, this is the height (in pixels) of the thumbnail.
Default: 75

+ +chart.zoom.background
+ Defaulting to true, this determines whether the zoom has a dark, semi-opaque background that covers the entire web page.
Default: true

+ + + + + +

Miscellaneous

+chart.align
+ Whether to left, center or right align the pie chart.
Default: center

+ +chart.linewidth
+ By setting this to roughly 5, and setting the strokestyle to the same colour as your background colour,you will get a segment separation effect.
Default: 1

+ + + chart.variant
+ This can be either pie (the default) or donut. Setting this to donut is how you get a + donut chart.
+ Default: pie

+ + + chart.variant.donut.color
+ This is the color of the center of the Donut chart.
+ Default: white

+ + + chart.highlight.style
+ Can be either explode, 2d or 3d and determines which style of segment highlighting is used in + conjunction with tooltips.
+ Default: 2d

+ + + chart.highlight.style.2d.fill
+ When 2D highlighting for tooltips is used, this controls the color of the highlighting. The former name for this property was + chart.highlight.style.2d.color.
+ Default: rgba(255,255,255,0.5)

+ + + chart.highlight.style.2d.stroke
+ When 2D highlighting for tooltips is used, this controls the stroke color of the highlighting.
+ Default: rgba(255,255,255,0)

+ + + chart.explode
+ This can either be an array with the same number of elements as segments, or a single number, in which case every + segment will be exploded that amount. If it's an array then only those segments will be exploded - eg [0,5,0,0]
+ Default: [] (an empty array)

+ + + +
 
+

Methods

+ + obj.getSegment()

+ + obj.getSegment() makes it easy to determine which segment of the Pie chart was clicked on. It provides: + + + +
+<script>
+    RGraph.Register(myGraph);
+    
+    myGraph.canvas.onclick = function (e)
+    {
+        RGraph.FixEventObject(e);
+        RGraph.Redraw();
+
+        var canvas  = e.target;
+        var context = canvas.getContext('2d');
+        var obj     = canvas.__object__;
+        var segment = obj.getSegment(e);
+        
+        if (segment) {
+            context.fillStyle = 'rgba(255,255,255,0.5)';
+            context.beginPath();
+                
+                // Angles are provided in degrees, so convert them to radians
+                segment[3] /= 57.29;
+                segment[4] /= 57.29;
+            
+                context.moveTo(segment[0], segment[1]);
+                context.arc(segment[0], segment[1], segment[2], segment[3], segment[4], 0);
+            context.stroke();
+            context.fill();
+            
+            e.stopPropagation();
+        }
+    }
+    
+    window.onclick = function (e)
+    {
+        RGraph.Redraw();
+    }
+</script>
+
+ + obj.Explode()

+

+ The Explode() method allows you to programmatically trigger the exploding (ie the highlighting of) a particular segment. + The Explode() method is used like so: +

+ +
+<script>
+    myObj = new RGraph.Pie('cvs', [8,9,4,6]);
+    myObj.Draw();
+
+    myObj.Explode(index, size);
+</script>
+
+ +

+ The index argument is the zero-index segment to operate on (counting from the north axis). An the size is measured in pixels. +

+ + Important Note + +

+ This method was formerly a common object method, called RGraph.getSegment(e), but has now (6th March 2011) been + moved to be part of the Pie chart object. +

+ + + \ No newline at end of file -- cgit v1.2.1