Mention RGraph on Twitter

RGraph: HTML5 Javascript charts library - Bi-polar charts documentation

Bi-polar charts are good for comparing two sets of data 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.bottom', 45);
        bipolar.Draw();
    }
</script>

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.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

chart.gutter.center
The center area of the chart that the labels sit in. If your labels are large then you may need to increase this.
Default: 60

chart.margin
The space above and below each bar.
Default: 2

Titles

chart.title
The main title of the chart.
Default: (An empty string)

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

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.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.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']

chart.strokestyle
This is the color used as the stroke style. If you didn't want it, you could set this to rgba(0,0,0,0)
Default: #333

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.formatter
To allow thoroughly custom formats of numbers in the scale, you can use this option to specify a function that is used by RGraph to format numbers. This function should handle ALL of the formatting. Eg:

function myFormatter(obj, num)
{
    return num + 'F'; // An example of formatting
}
myGraph.Set('chart.scale.formatter', myFormatter);

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 charts 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.scale.round
Whether to round the maximum scale value up or not. This will produce slightly better scales in some instances.
Default: null

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 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. 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 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

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 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.highlight.stroke
If you use tooltips, this controls the colour of the highlight stroke.
Default: black

chart.highlight.fill
If you use tooltips, this controls the colour of the highlight fill.
Default: rgba(255,255,255,0.5)