RGraph: HTML5 canvas graph library - Bi-polar chart documentation
The Bi-polar chart is good for comparing two things side by side. For example sales trends for two separate years, that you
want to compare.
The example file is here.
<script>
window.onload = function ()
{
var left = [5,6,8,9,12,13,4,9];
var right = [5,8,4,11,15,26,13,16];
var bipolar = new RGraph.Bipolar('myBipolar', left, right);
bipolar.Set('chart.colors', ['#fff', '#eef', '#ddf', '#ccf', '#bbf', '#bbf', '#aaf', '#99f']);
bipolar.Set('chart.margin', 3);
bipolar.Set('chart.labels', ['Barry', 'John', 'Fred', 'George', 'Rich', 'Larry', 'John', 'Mike']);
bipolar.Set('chart.title.left', '2007');
bipolar.Set('chart.title.right', '2008');
bipolar.Set('chart.gutter', 35);
bipolar.Draw();
}
</script>
Available properties
You can use these properties to control how the chart apears. You can set them by using the Set() method. Eg:
myBipolar.Set('name', 'value');
Margins
chart.gutter
The space given over to the labels.
Default: 25
chart.margin
The space above and below each bar.
Default: 2
Titles
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
chart.title.color
The color of the title.
Default: black
chart.title
The main title of the chart.
Default: (An empty string)
chart.title.left
The left title.
Default: An empty string
chart.title.right
The right title.
Default: An empty string
Colors
chart.colors
An array of colors. These too can be gradients that you make if you wish.
Default: ['#fcf', '#00f', '#f00', '#0f0', '#ff0', '#0ff', '#f0f', '#ff6101', '#b401ff', '#e4ff01', '#fb8195', '#ccc']
Labels, text and axes
chart.xtickinterval
The X tick mark interval.
Default: null
chart.axis.color
The color of the axes.
Default: black
chart.xmax
This allows you to set the maximum X value that the chart uses, instead of it being auto-generated.
Default: null
chart.scale.decimals
This allows you to set the precision of the X labels.
Default: null
chart.scale.point
The character used as the decimal point.
Default: .
chart.scale.thousand
The character used as the thousand separator
Default: ,
chart.labels
An array of the graphs labels (they go in the middle).
Default: null
chart.text.size
The size of the text used (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
Scale
chart.units.pre
The units that are applied to the X axis labels (these are pre-pended to the number).
Default: none
chart.units.post
The units that are applied to the X axis labels (these are appended to the number).
Default: none
Interactive features
chart.tooltips
A numerically indexed array of tooltips that are shown when a bar is clicked. These can contain HTML.
Default: An empty array
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 graph 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. Cannot be used in conjunction with tooltips.
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 graph 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
Shadow
chart.shadow
Turns the shadow on or off.
Default: false
chart.shadow.color
The color of the shadow.
Default: #666
chart.shadow.offsetx
The horizontal offset of the shadow.
Default: 3
chart.shadow.offsety
The vertical offset of the shadow.
Default: 3
chart.shadow.blur
How severe the blurring effect is for the shadow.
Default: 3
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 graph 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