com.googlecode.charts4j
Class BarChart

java.lang.Object
  extended by com.googlecode.charts4j.AbstractGraphChart
      extended by com.googlecode.charts4j.AbstractAxisChart
          extended by com.googlecode.charts4j.BarChart
All Implemented Interfaces:
GChart, GraphChart, GridChart, TitledChart

public class BarChart
extends AbstractAxisChart

Bar chart constructed with the GCharts static factory class. Bar chart class that supports vertical and horizontal bar charts. Bars from different data series can either be stacked or side-by-side.

Author:
Julien Chastang (julien.c.chastang at gmail dot com)
See Also:
BarChartPlot, GCharts

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.googlecode.charts4j.TitledChart
TitledChart.ChartTitle
 
Method Summary
 void setBackgroundFill(Fill fill)
          Specify background fill.
 void setBarWidth(int barWidth)
          Set the bar chart width.
 void setDataEncoding(DataEncoding dataEncoding)
          Set the data encoding scheme.
 void setDataStacked(boolean dataStacked)
          Are the bar charts stacked, or side-by-side.
 void setHorizontal(boolean horizontal)
          Is the bar chart bars horizontal or vertical.
 void setSize(int width, int height)
          Set the chart size.
 void setSpaceBetweenGroupsOfBars(int spaceBetweenGroupsOfBars)
          Set the space between groups of bars.
 void setSpaceWithinGroupsOfBars(int spaceWithinGroupsOfBars)
          Set the space within groups of bars.
 void setTransparency(int opacity)
          Specify the chart transparency.
 String toURLForHTML()
          Create a URL with the ampersand character entity reference (&) in place of an ampersand.
 String toURLString()
          Create a URL string given the information supplied to this chart.
 
Methods inherited from class com.googlecode.charts4j.AbstractAxisChart
addRightAxisLabels, addTopAxisLabels, addXAxisLabels, addYAxisLabels, setGrid
 
Methods inherited from class com.googlecode.charts4j.AbstractGraphChart
setAreaFill, setLegendPosition, setTitle, setTitle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setDataStacked

public final void setDataStacked(boolean dataStacked)
Are the bar charts stacked, or side-by-side.

Parameters:
dataStacked - If true, data from different bar chart plot will be stacked instead of side-by-side.

setHorizontal

public final void setHorizontal(boolean horizontal)
Is the bar chart bars horizontal or vertical.

Parameters:
horizontal - If true, the bar chart will be horizontal instead of vertical.

setBarWidth

public final void setBarWidth(int barWidth)
Set the bar chart width.

Parameters:
barWidth - Bar width in pixels. If not set defaults to 23. Must be > 0.

setSpaceBetweenGroupsOfBars

public final void setSpaceBetweenGroupsOfBars(int spaceBetweenGroupsOfBars)
Set the space between groups of bars.

Parameters:
spaceBetweenGroupsOfBars - The space between groups of bars. Bars within a group have half the specified spacing. If not set default to 8. Must be >= 0.

setSpaceWithinGroupsOfBars

public final void setSpaceWithinGroupsOfBars(int spaceWithinGroupsOfBars)
Set the space within groups of bars.

Parameters:
spaceWithinGroupsOfBars - The space within groups of bars. Bars within a group have half the specified spacing. If not set default to 4. Must be >= 0.

setSize

public void setSize(int width,
                    int height)
Set the chart size. If no size is specified, the chart will default to 200x125.

Specified by:
setSize in interface GChart
Parameters:
width - chart width. Must be > 0 and <= 1000.
height - chart height. Must be > 0 and <= 1000.
See Also:
Chart Size

toURLString

public final String toURLString()
Create a URL string given the information supplied to this chart. You can copy and paste this string into your web browser, and see if you get the results you anticipated. Better yet, incorporate this method call or GChart.toURLForHTML() into your Internet application to dynamically generate charts. URLs beyond 2000 characters are not recommended. You can sometimes get away with the simple encoding scheme if URL length is a problem. See GChart.setDataEncoding(DataEncoding dataEncoding)

Specified by:
toURLString in interface GChart
Returns:
URL String
See Also:
DataEncoding, WWW FAQs: What is the maximum length of a URL?

toURLForHTML

public final String toURLForHTML()
Create a URL with the ampersand character entity reference (&amp;) in place of an ampersand. Useful for embedding your link in a web page.

Specified by:
toURLForHTML in interface GChart
Returns:
URL string

setBackgroundFill

public void setBackgroundFill(Fill fill)
Specify background fill.

Specified by:
setBackgroundFill in interface GChart
Parameters:
fill - Background fill. Cannot be null.
See Also:
Fill

setTransparency

public void setTransparency(int opacity)
Specify the chart transparency. Use cautiously as this feature may obscure background fills. Also there appears to be a bug in the Google Chart API where setting a transparency makes the label color disappear.

Specified by:
setTransparency in interface GChart
Parameters:
opacity - Supply a number between 0 and 100. 0 is completely transparent, and 100 is completely opaque.

setDataEncoding

public final void setDataEncoding(DataEncoding dataEncoding)
Set the data encoding scheme. The only advantage to the simple encoding scheme is it will ultimately result in shorter URLs, but at the cost of lower resolution. charts4j defaults to the extended encoding, but if you have lots of data and if you are willing to sacrifice resolution, the simple encoding may be right for you.

Specified by:
setDataEncoding in interface GChart
Parameters:
dataEncoding - Supply the data encoding, either simple or extended. Cannot be null.