API

MxStandardChartModel class provides the default implementation of MxChartModel class and adds a number of API functions that can be used to load, persist and dynamically update models.

The following functions can be used to dynamically update chart's model:

public void insertRow(java.lang.String rowLabel, double[] seq, int rowIndex)
Insets a new row with specified label at the specified location. When -1 is specified as rowIndex, the new row is appended to the list of the rows. If seq is null or its length is less than the current number of columns, then the rest of the row is filled with Double.NaN values.
public void insertCol(java.lang.String colLabel, double[] seq, int colIndex)
Insets a new column with specified label at the specified location. When -1 is specified as colIndex, the new column is appended to the list of the columns. If seq is null or its length is less than the current number of rows, then the rest of the column is filled with Double.NaN values.
public void replaceRow(double [] seq, int index)
Replaces row at specified location with a new one. If seq is null or its length is less than the current number of columns, then the rest of the row is filled with Double.NaN values.
public void replaceCol(double [] seq, int index)
Replaces column at specified location. If seq is null or its length is less than the current number of rows, then the rest of the column is filled with Double.NaN values.
public void deleteRow(int rowIndex)
Deletes row at specified location.
public void deleteCol(int colIndex)
Deletes column at specified location.
public void setRowLabelAt(int rowIndex, java.lang.String rowLabel)
Changes row's label to provided rowLabel.
public void setColLabelAt(int colIndex, java.lang.String colLabel)
Changes columns's label to provided colLabel.
public void setValueAt(int rowIndex, int colIndex, double value)
Updates specified cell with the provided value.

NOTE. MxStandardChartModel does not fire any change events and the chart will not be updated until it is repainted.

WebCharts3D can read data from XML sources, separated files and databases. In all cases, the data can be either in row-by-row or crosstab (three values per row specifying row, column and value) formats. (See also XML Model Formats) In some cases, database queries or files will contain data in the transposed format, when you would want to plot returned rows as columns and columns as rows. To achieve it, it is often easier to set isTransposed attribute on the chart style than to change your data source. The following functions can be used with MxChartModel class to retrieve and persist chart's model.

public static MxStandardChartModel load( 
 java.sql.Connection conn, String sql, boolean isCrosstab, boolean hasRowLabels)
Creates a new chart's model from data returned by a database query.
conn - Opened database connection
sql - SQL command
isCrosstab - true when the query returns data in crosstab format, false otherwise
hasRowLabels - true when the query returns rowLabels in the first column
public static MxStandardChartModel load( 
 java.io.Reader rdr, char sep, char quote, boolean isCrosstab, boolean hasColLabels, boolean hasRowLabels)
Creates a new chart's model from data located in a delimited file. This function can import data from any delimited (comma, tab, semicolon, etc.) file that might have quoted values. For example, to parse file that contains rows like "Year 2001","5","10" you should specify ',' as a separator and '"' as a quote. To parse file that contains rows like Year 2001;5;10 you should specify ';' as a separator and '\0' as a quote character.
rdr - Reader
sep - Delimiter character
quote - Quote character or '\0' for the unquoted files
isCrosstab - true when the query returns data in crosstab format, false otherwise
hasColLabels - true when the first row contains column labels, false otherwise
hasRowLabels - true when the first column contains row labels, false otherwise

public String toXML(boolean isCrossTab, String encoding)
Returns XML represetation of the chart's model in default or crosstab format with XML encoding set to specified encoding.

public String toXML()
Returns XML represetation of the chart's model in default format.

public static MxStandardChartModel fromXML(String xml, String parser)
Creates new chart model from the xml representation using a specified parser or built-in parser if the parser is not specified.