org.progeeks.jfreechart
Class CategoryDatasetProducer
java.lang.Object
org.progeeks.jfreechart.MetaDatasetProducer
org.progeeks.jfreechart.CategoryDatasetProducer
- All Implemented Interfaces:
- de.laures.cewolf.DatasetProducer, java.io.Serializable
public class CategoryDatasetProducer
- extends MetaDatasetProducer
DatasetProducer which can be used to generate a DefaultCategoryDataset
for use in
vertical or horizontal bar charts. The properties of each object in the passed in dataList
correspond to categories to be charted. The seriesNameProperty
is used as the name
of the collective series. The categories names and the methods that have values for them are
passed in by the categoryPropertyMap
. The map's keys are the property names and
the values are the label strings the property.
Example: Take a list of car objects. Each object has 4 properties: model name, head room,
leg room, and hip room. You would normally use the model name as the seriesNameProperty and the
rest for the categories. Given a list of 5 different cars (Outback, Prius, Accord, etc), this
would yield a chart where all the head room stats are grouped together, followed by leg room and
hip room. Each car model would be represented by a single color in the whole chart (the Outback's
data would be a red bar in all clusters, the Prius blue, etc).
You may also set the inverse
property to show the fields mapped in the opposite
way. In the above example, this would show all the Outback's stats together, followed by the
Prius, etc. Each stat would be a different color across all the car groups (head room always red,
leg room blue, etc.) This is good when it is more useful to compare the various properties of a
single series together vs. the same property from different series.
You may also use value of properties in the categoryPropertyMap
to represent
categories themelves rather than be the value of the given named category. If the type of a
category property is anything other than a Number
(or equivalent primitive), the
different data values for that property will each be shown as a category, and the chart will show
the number of items with that value for the category.
Example: Like the example above, take a list of car objects, but this time they have 3
properties: model, year (as a String or Date), and color. Set the seriesNameProperty to model
again, and include year and color in the categoryPropertyMap
. Now you will see a
chart showing you how many cars of each make you have in each year and how many of each make for
each color. You cannot (yet) sub-divide further and show something like how many of each model
and color in each year.
If you set the countItems
property to true, an additional category with the total
count of items in each series will be generated.
Last, make sure to read the notes in MetaDatasetProducer
that explain how to use
the property of a property in a field.
- Version:
- $Revision: 1.7 $
- Author:
- esword
- See Also:
- Serialized Form
Fields inherited from class org.progeeks.jfreechart.MetaDatasetProducer |
addValues, dataClassIsMetaClass, dataMetaClass, dataObjectClass, defaultSeriesName, filteredSeries, PARAM_DATA, PARAM_EXISTING_DATASET, producerId, seriesNameProperty, storeOriginalData |
Fields inherited from interface de.laures.cewolf.DatasetProducer |
PRODUCER_ATTRIBUTE_NAME |
Methods inherited from class org.progeeks.jfreechart.MetaDatasetProducer |
createMetaObject, findOrCreateMetaClass, getDataObjectClass, getDefaultSeriesName, getFilteredSeries, getMetaObject, getOriginalData, getProducerId, getPropertyValue, getSeriesNameProperty, getStoreOriginalData, hasExpired, isAddValues, produceDataset, produceDataset, setAddValues, setDataObjectClass, setDefaultSeriesName, setFilteredSeries, setProducerId, setSeriesNameProperty, setStoreOriginalData |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
log
protected static final Log log
COUNT_ITEM_CAT_NAME
protected static final java.lang.String COUNT_ITEM_CAT_NAME
- See Also:
- Constant Field Values
categoryPropertyMap
protected java.util.Map categoryPropertyMap
inverse
protected boolean inverse
countItems
protected boolean countItems
CategoryDatasetProducer
public CategoryDatasetProducer()
init
protected void init()
throws java.lang.Exception
- Validates input settings
- Overrides:
init
in class MetaDatasetProducer
- Throws:
java.lang.Exception
produceDataset
public java.lang.Object produceDataset(java.util.Map params)
throws de.laures.cewolf.DatasetProduceException
- Specified by:
produceDataset
in interface de.laures.cewolf.DatasetProducer
- Specified by:
produceDataset
in class MetaDatasetProducer
- Throws:
de.laures.cewolf.DatasetProduceException
- See Also:
DatasetProducer.produceDataset(java.util.Map)
getCategoryPropertyMap
public java.util.Map getCategoryPropertyMap()
- Returns:
- Returns the categoryPropertyMap.
setCategoryPropertyMap
public void setCategoryPropertyMap(java.util.Map categoryPropertyMap)
- Parameters:
categoryPropertyMap
- The categoryPropertyMap to set.
isCountItems
public boolean isCountItems()
- If true, the producer will generate a special category with the total count of items in
each series. Default is false.
- Returns:
- Returns the countItems.
setCountItems
public void setCountItems(boolean countItems)
- Parameters:
countItems
- The countItems to set.
isInverse
public boolean isInverse()
- Returns:
- Returns the inverse.
setInverse
public void setInverse(boolean inverse)
- Parameters:
inverse
- The inverse to set.
Copyright © 2002-2003 Paul Speed. All Rights Reserved.