Cookbook

  1. Axes

    1. Exact Ticks
    2. Format Tick Values
    3. Hide Axes
    4. Share Axes Between Contexts
  2. Bars

    1. Chopped Bars
    2. Negative Bars
  3. Legend
    1. Hide Legend

Axes

Exact Ticks

Explanation

By default, Clicker shows 5 tick values on an axes by evenly dividing the range. You can make the ticks match the values in the data base setting the Axis’ tick_values to the data.

In the example below, the domain axis’ tick_values are set to the keys of the series.

Code Show/Hide

Sample Show/Hide

pie

Format Tick Values

Explanation

Without intervention, you are at the mercy of perl’s formatting. Generally this will result in tick values with a large number of decimal points.

You have two options with clicker: printf or a coderef. If you set the format attribute of an Axis to a string then it will be passed to printf. If you set the value of format to a coderef, then that coderef will be executed and passed the value of of the tick. The return value from the coderef will be used as the tick label.

The example here illusrates the coderef method.

Code Show/Hide

Sample Show/Hide

pie

Hide Axes

Explanation

Axes are associated with a context. To make hide an axis, retrieve it from the context and set it’s hidden attribute to true.

Code Show/Hide

Sample Show/Hide

pie

Share Axes Between Contexts

Explanation

When you create a new Context it implicitly creates new axes, so anything you associate with that context will — by definition — be associated with different axes than datasets associated with other context.

To change this, simple set the range or domain axis of your new context to that of the one you want to share with. Clicker will recognize that the axes are the same and Do What You Mean. The example blow sets a new context’s domain axis to be shared with the default context.

Code Show/Hide

Sample Show/Hide

pie

Bars

Negative Bars

Explanation

By default all bar are charted as ‘positive’, meaning they are drawn up the domain axis. By default the baseline is set to the lowest value on the axis. You can control this by changing the baseline of the domain axis.

Code Show/Hide

Sample Show/Hide

pie

Fix Chopped Bars

Explanation

Clicker centers bars over their values. The domain axis’ range is from the lowest to highest value. This results in the bars of a chart sliding just off the chart. You can fix this by setting the Axis’ fudge_amount to a decimal percentage of how much ‘fudging’ clicker should do to widen the axis. A value of 0.1 usually does the trick.

Code Show/Hide

Sample Show/Hide

pie

Legend

Hide Legend

Explanation

The legend is automatically added to every chart when it is prepared. To prevent it from showing up, set it’s visible attribute to false.

Code Show/Hide

Sample Show/Hide

pie