|
Chart FX for Java 6.5 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object SoftwareFX.ChartFX.DataSourceSettings
public final class DataSourceSettings
Provides access to the DataSourceSettings object.
One of the greatest features in Chart FX is the ability to read or pass data from many sources, including text files, arrays, collections, XML files, etc. The DataSourceSettings Class members provide the mechanism for configuring your data source and control how Chart FX plots the fields in the resultsets.
Constructor Summary | |
---|---|
DataSourceSettings()
|
Method Summary | |
---|---|
IDataProvider |
getDataSource()
Gets the DataSource. |
int |
getDataStyle()
Gets the DataStyle. |
DataTypeCollection |
getDataType()
An array property that specifies how Chart FX should treat the different fields available in the result set. |
int |
getDataType(int n)
Deprecated. You should use getDataType() instead. |
java.lang.String |
getLabelSeparator()
Gets the LabelSeparator. |
void |
setDataSource(IDataProvider value)
Gets or sets the source containing the values used to populate the chart. |
void |
setDataStyle(int value)
Controls how Chart FX plots the fields in the resultset. |
void |
setDataType(int n,
int value)
Deprecated. You should use getDataType() instead. |
void |
setLabelSeparator(java.lang.String value)
Used to define the label separator character used when concatenating labels. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DataSourceSettings()
Method Detail |
---|
public IDataProvider getDataSource()
Gets the DataSource. For more detail see setDataSource(SoftwareFX.ChartFX.IDataProvider)
.
public int getDataStyle()
Gets the DataStyle. For more detail see setDataStyle(int)
.
public int getDataType(int n)
getDataType()
instead.
public DataTypeCollection getDataType()
An array property that specifies how Chart FX should treat the different fields available in the result set.
This property is used in conjunction with the setDataStyle(int)
property to control how Chart FX takes the information from a Data Control.
When using this property, you must make sure each and every field has a DataType set. For example if you have 4 field in your result set, you must make sure 4 assignments are made using this property.
Make sure you set the DataType for all fields before reading the data.
The Value enumeration should be used when there is a categorical axis (1,2,3,4,5..) in your chart. To change the Legends (labels X axis) you should use the ChartCore.getLegend(int)
Property.
The Series ChartCore.setSerLegBox(boolean)
will show the label of the Y axis since it is an independent variable (X variable depends on Y variable). To modify the Series legend use the ChartCore.getSerLeg(int)
property.
This property is very useful when you have a resultset that you would like to use to chart data, where you have some fields that are not necessary for the chart. If you would like to ignore a field in the result set, the DataType can be set to NotUsed.
chart1.getDataSourceSettings().setDataType(0, DataType.NOT_USED);
It is also useful to change the default rules Chart FX applies to retrieve data from a data control. The following are the rules:
1) Series Legends will be taken from the numerical field names.
2) All numerical columns will be plotted as different series and all string and/or date columns will be plotted as point legends (joined by the '-' character).
3) All string and numerical fields specified in the SELECT statement will be plot.
setDataStyle(int)
,
setDataSource(SoftwareFX.ChartFX.IDataProvider)
,
ChartCore.getSerLeg(int)
,
ChartCore.setSerLegBox(boolean)
,
ChartCore.openData(int, int, int)
,
ChartCore.closeData(int)
,
Chart
public java.lang.String getLabelSeparator()
Gets the LabelSeparator. For more detail see setLabelSeparator(java.lang.String)
.
public void setDataSource(IDataProvider value)
Gets or sets the source containing the values used to populate the chart.
This property is used in conjunction with the setDataStyle(int)
and getDataType(int)
properties to bind Chart FX to a Data Control.
Once the DataSource has been configured using this property, the chart is automatically bound to the data.
When reading data from arrays, you will need to create the ListProvider object and use that as the DataSource:
chart1.getDataSourceSettings().setDataSource(new ListProvider(myArrayVariable));
setDataStyle(int)
,
getDataType(int)
,
setLabelSeparator(java.lang.String)
,
ChartCore.openData(int, int, int)
,
ChartCore.closeData(int)
,
ListProvider
,
TextProvider
,
Chart
public void setDataStyle(int value)
Controls how Chart FX plots the fields in the resultset.
In other words, this property specifies what field types should be considered when data is passed to the chart.
DataStyle :
Define the data column styles.Value | Description |
---|---|
DataStyle.DEFAULT | Use Chart FX default field assignments. |
DataStyle.NO_MIN_MAX | Do not assign a Min and Max based on data field values. |
DataStyle.TRANSPOSE | See Remarks. |
DataStyle.USE_BLOB_TEXT | Use as text from a "binary large object". |
DataStyle.KEEP_SER_LEG | Keep preset series legends. |
DataStyle.KEEP_LEGEND | Keep preset legends. |
DataStyle.ALLOC_HIDDEN | Instructs Chart FX to plot missing values in data fields as hidden points. |
DataStyle.READ_XVALUES | Instructs Chart FX that the data read will include both values and x values. |
DataStyle.READ_INI_VALUES | Instructs Chart FX that the data read will include both values and initial values. |
DataStyle.DATES_AS_LABELS | Instructs Chart FX to use date values as labels. |
This property is used in conjunction with the getDataType(int)
property to control how Chart FX takes the information from a Data Control.
Please note that instead of the value associated with the point, you can assign a hidden constant which will cause the point to be hidden in the chart. Although a hidden point is physically in the data array, when you use this constant the marker will not appear in the chart, and if you have charts like a line or area chart, the line will break at that particular point.
chart1.setValue(2,3, Chart.HIDDEN);
Chart FX for Java includes two data style flags that will instruct the component to expect values and X Values or to expect both values and initial values in the data array.
For example, lets say that your data looks like this and you want to plot an XY chart:
1 200 3 400
2 100 6 300
When you set the datastyle to ReadXValues, the data will be passed to the chart like:
chart1.setXValue(0,0,1);
chart1.setValue(0,0,200);
chart1.setXValue(1,0,3);
chart1.setValue(1,0,400);
chart1.setXValue(0,1,2);
chart1.setValue(0,1,100);
chart1.setXValue(1,1,6);
chart1.setValue(1,1,300);
The ReadIniValues will do the same except will set initial values using the IniValue property.
Transposing Data
ChartFX Internet Edition uses any numerical columns in your SQL statement as data series and each record in your SQL statement as values, e.g.
SELECT CharField,NumField1,NumField2 FROM Table
Will create a chart with two series and CharField will be used as the X axis labels, if this SQL statement returns 5 records, the chart will contain 2 lines (assuming it is a line chart) and each line will have 5 point markers. If you want to create a chart with 5 lines (each with two point markers) you would use the Transpose before the DataSource Call:
chart1.setDataStyle(chart1.getDataStyle() | DataStyle.TRANSPOSE);
chart1.setDataSource(DataTable);
Chart FX will take all string and date fields to construct a long string that will be used as a legend for each point in the chart. If you want to avoid this behavior just turn OFF the appropriate constants in this property or control the fields Chart FX will use from the Data Control with the DataType property.
With this property you can overwrite the default rules Chart FX use to take information from the Data Control. These default rules are intelligent enough to pick the information from the database and assign the legends. So if you send a SELECT statement, Chart FX will create the chart series and point legends automatically. These rules are:
1) Series Legends will be taken from the numerical field names.
2) All numerical columns will be plotted as different series and all string and/or date columns will be plotted as point legends (joined by the '-' character).
3) All string and numerical fields specified in the SELECT statement will be plot.
Because it is a mask property, you must make sure you use these operators to turn on/off bits and avoid losing previous settings to the property.
For example, if you want to turn on NoMinMax
The right way of setting this property is:
chart1.setDataStyle(chart1.getDataStyle() | DataStyle.NO_MIN_MAX);
If you type the following code:
chart1.setDataStyle(DataStyle.NO_MIN_MAX);
(WRONG!)
you will erase all other settings in the property causing an erratic behavior of the library and an incorrect setting of the individual properties which also control these flags.
setDataSource(SoftwareFX.ChartFX.IDataProvider)
,
getDataType(int)
,
ChartCore.openData(int, int, int)
,
ChartCore.closeData(int)
,
Chart
public void setDataType(int n, int value)
getDataType()
instead.
public void setLabelSeparator(java.lang.String value)
Used to define the label separator character used when concatenating labels.
Only string data types may be concatenated using the label separator.
If there is a space in the string to be used as a label, the configured label separator will not be appended in the label. Only when two strings are added together will the separator be used.
setDataSource(SoftwareFX.ChartFX.IDataProvider)
,
setDataStyle(int)
,
getDataType(int)
,
Chart
|
http://www.softwarefx.com | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |