Set series X values from data encoded in a separator-delimited string (for XY-Scatter and XY-Curves).
object->SetSeriesXValuesFromString( int index, string values )
Note: This method is available when manipulating XY data series required for displaying XY-Curves and XY-Scatter. Note that the Chart type (ie: bar, column, line, etc.) is defined in the Swiff Chart style file (.scs) which must be loaded via the LoadStyle method.
You can set the X values of a specified series in a chart with data encoded in a string (i.e. the values argument). The string must be formatted as a list of numerical values, two consecutive values must be separated by a separator character that can be specified with the SetSeparators method.
Here is an example of series X values encoded in a string with the character ";" as separator.
$myEncodedString= "12;7.5;11.3;9.2;5.3"
The string argument values is parsed by the chart object according to the separator characters specified to the chart object (see the SetSeparators method for specifying separator characters and rules).
The ";" character is the default separator character.
If the index argument refers to a series that does not exist in the chart object, the series is created.
The following PHP code shows how to store the XY values of the table below using the SetSeriesXValuesFromString method. This table has two series named "Year 2006" and "Year 2007". Each of these two series contains independant X values and Y values.
|
// Let's build the series and categories string with ";" as separator $sep= ";"; $ignoremultseparators= true; // Before setting the series and categories, we must specify the separators $chart->SetSeparators( $sep, $ignoremultseparators ); // Add the first series "Year 2006" $str_x= "1" . $sep . "2" . $sep . "3" . $sep . "4" . $sep . "5"; $str_y= "12" . $sep . "7.5" . $sep . "11.3" . $sep . "9.2" . $sep . "5.3"; // Fill the first series with the XY values stored in the str_x and str_y variables $chart->SetSeriesCaption( 0, "Year 2006" ); $chart->SetSeriesXValuesFromString( 0, $str_x ); $chart->SetSeriesYValuesFromString( 0, $str_y ); // Add the second series "Year 2007" $str_x= "1.5" . $sep . "1.8" . $sep . "3.7" . $sep . "3.9" . $sep . "5.8"; $str_y= "14" . $sep . "9.9" . $sep . "13.1" . $sep . "11.5" . $sep . "4.9"; // Fill the second series with the XY values stored in the str_x and str_y variables $chart->SetSeriesCaption( 1, "Year 2007" ); $chart->SetSeriesXValuesFromString( 1, $str_x ); $chart->SetSeriesYValuesFromString( 1, $str_y );
GetSeriesCount Method | SetSeriesXValuesFromArray Method | SetSeriesCaption Method | GetSeriesXValue Method
Applies To: Chart Object