# Bi-polar charts documentation

- Example
- Properties
- Methods

## Example

    <script>
        window.onload = function ()
        {
            // The Bipolar chart takes two arrays of data - one for the left side and one for the right.
            var left  = [5,6,8,9,12,13,4,9];
            var right = [5,8,4,11,15,26,13,16];

            // Create the Bi-polar object. Give the constructor the ID of the canvas tag along with
            // the left sides data and the right sides data.
            var bipolar = new OfficeExcel.Bipolar('myBipolar', left, right);

            // Configure the Bipolar chart to appear as wished.
            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);

            // Now call the .Draw() method to draw the chart
            bipolar.Draw();
        }
    </script>

The example file is here.

## 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
- Titles
- Colors
- Labels, text and axes
- Scale
- Interactive features
- Shadow
- Zoom
- Events
- Miscellaneous

### 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.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.formatter
To allow thoroughly custom formats of numbers in the scale, you can use this option to specify a function that is used by OfficeExcel 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
The number of decimal places to display for the Y scale.
Default: 0
chart.scale.point
The character used as the decimal point.
Default: .
chart.scale.thousand
The character used as the thousand separator
Default: ,
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: OfficeExcel_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.thumbnail.fixed
When the zoom is in thumbnail mode, you can use this property to fix the zoom in the top left corner instead of it following the cursor around.
Default: false
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

### Events

chart.events.click
If you want to add your own onclick function you can do so by assigning it to this property. See here for details.
Default: null
chart.events.mousemove
If you want to add your own onmousemove function you can do so by assigning it to this property. See here for details.
Default: null

### 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)

## Methods

obj.getBar(event)

This method when used in an event will return the details of the bar that was clicked on moused over (if any). It returns:

- The X coordinate
- The Y coordinate
- The width
- The height
- The index of the bar (starting at 0)

obj.getShape(event)

This method is an alternate name for the above method but has a generic name that is the same acoss the various libraries.