Chart FX 7 for Java Server

com.softwarefx.chartfx.server
Class DataSourceSettings

java.lang.Object
  extended by com.softwarefx.chartfx.server.DataSourceSettings

public class DataSourceSettings
extends Object

Provides customization on how the Data is databind to the chart.

One of the greatest features in Chart FX for Java is the ability to read or pass data from many sources, including text files, arrays, collections, XML files, etc. The DataSourceSettings Class provides the mechanism for configuring your data source and control how Chart FX stores and plots the data.


Constructor Summary
DataSourceSettings()
           
 
Method Summary
 IDataSource getDataSource()
          Gets the DataSource.
 FieldMapCollection getFields()
           Returns a collection of FieldMap objects.
 String getLabelSeparator()
          Gets the LabelSeparator.
 EnumSet<DataSourceStyles> getStyle()
          Gets the Style.
 void reloadData()
          Reloads the chart data from the current configured datasource.
 void setDataSource(IDataSource value)
          Sets the source containing the values used to populate the chart.
 void setLabelSeparator(String value)
          Sets a value defining the label separator character used when concatenating labels.
 void setStyle(EnumSet<DataSourceStyles> value)
          Controls how Chart FX plots the fields in the resultset.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataSourceSettings

public DataSourceSettings()
Method Detail

getDataSource

public IDataSource getDataSource()

Gets the DataSource. For more detail see setDataSource(com.softwarefx.chartfx.server.dataproviders.IDataSource).


getFields

public FieldMapCollection getFields()

Returns a collection of FieldMap objects. Those objects allows you to configure how ChartFX will store the data provided by the DataProvider.

Remarks:
  • This property is used in conjunction with the setStyle(java.util.EnumSet) property to control how Chart FX takes the information from a DataProvider.

  • Make sure you set the FieldMap.setUsage(com.softwarefx.chartfx.server.FieldUsage)for all FieldMapbefore reading the data. For example if you have 4 field in your result set, you must make sure 4 assignments are made using this 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.

    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.

  • The Value enumeration should be used when there is a categorical axis (1,2,3,4,5..) in your chart.

  • See Also:
    setStyle(java.util.EnumSet), FieldMap

    getLabelSeparator

    public String getLabelSeparator()

    Gets the LabelSeparator. For more detail see setLabelSeparator(java.lang.String).


    getStyle

    public EnumSet<DataSourceStyles> getStyle()

    Gets the Style. For more detail see setStyle(java.util.EnumSet).


    reloadData

    public void reloadData()

    Reloads the chart data from the current configured datasource.

    Remarks:
  • Depending on the Binding Context for a chart and the configured datasource, the chart may automatically be refreshed. For example, if a design-time datasource configuration is configured, the Chart will be aware of changes in the datasource and automatically reload to display the new values. In cases where the Binding Context is created at runtime, the reloadData() method my be called to refresh the chart data without rebinding the chart to its configured datasource.

  • See Also:
    setDataSource(com.softwarefx.chartfx.server.dataproviders.IDataSource)

    setDataSource

    public void setDataSource(IDataSource value)

    Sets the source containing the values used to populate the chart.

    Remarks:
  • Once the DataSource has been configured using this property, the chart is automatically bound to the data.

  • This property has a shortcut called Chart.setDataSource(com.softwarefx.chartfx.server.dataproviders.IDataSource)property and defined in the Chart Class .Chart.getDataSourceSettings()

  • Important Note: When developing web apps and using any design time control to pass data to Chart FX, you must bind the data to the chart by calling the DataBind method after setting the DataSource (Web Apps Only):

    chart1.DataSourceSettings.DataSource = DataSet1.Table1;
    chart1.DataBind();

  • See Also:
    setStyle(java.util.EnumSet), setLabelSeparator(java.lang.String), Chart.setDataSource(com.softwarefx.chartfx.server.dataproviders.IDataSource)

    setLabelSeparator

    public void setLabelSeparator(String value)

    Sets a value defining the label separator character used when concatenating labels.

    Remarks:
  • 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.

  • See Also:
    setDataSource(com.softwarefx.chartfx.server.dataproviders.IDataSource), Chart

    setStyle

    public void setStyle(EnumSet<DataSourceStyles> value)

    Controls how Chart FX plots the fields in the resultset.

    Remarks:
  • This property is used in conjunction with the getFields() property to control how Chart FX takes the information from a DataProvider.

  • 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.Data.Y[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 Style to ReadXValues, the data will be passed to the chart like:

    chart1.Data.X[0,0] = 1;

    chart1.Data.Y[0,0] = 200;

    chart1.Data.X[1,0] = 3;

    chart1.Data.Y[1,0] = 400;

    chart.Data.XValue[0,1] = 2;

    chart1.Data.Y[0,1] = 100;

    chart1.Data.X[1,1] = 6;

    chart1.Data.Y[1,1] = 300;

    The ReadYFromValues will do the same except it will set initial values using the DataValues.getYFrom()DataValues.getYFrom()property.

  • Transposing Data

    Chart FX for Java 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.DataSourceSettings.Style |= DataSourceStyles.Transpose;

    chart1.DataSourceSettings.DataSource = ds.Table1;

  • Chart FX for Java willl 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 that Chart FX for Java will use from the Data Control with the DataType property.

  • 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.DataSourceSettings.Style |= DataSourceStyles.NoMinMax;

    If you type the following code:

    chart1.DataSourceSettings.Style = DataSourceStyles.NoMinMax;

    (WRONG!), you will erase all other settings in the property causing an erratic behavior of the library and an incorrect setting of the individual methods which also control these flags.

  • See Also:
    getFields()

    http://www.softwarefx.com

    2008 Software FX, Inc. All Rights Reserved. Chart FX is a registered trademark of Software FX, Inc
    All other names are trademarks or registered trademarks of their respective owners.