Set series Y values from data encoded in a separator-delimited string (for XY-Scatter and XY-Curves).

object->SetSeriesYValuesFromString( int index, string values )

Arguments

object
Required. A Chart object.
index
Required. An integer value that specifies the zero-based index of the series in the chart object.
values
Required. A string that specifies the Y data (see SetSeparators).

Remarks

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 Y 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 Y 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.

PHP Sample Code

The following PHP code shows how to store the XY values of the table below using the SetSeriesYValuesFromString method. This table has two series named "Year 2006" and "Year 2007". Each of these two series contains independant X values and Y values.

Year 2006 Year 2007
X
Y
X
Y
1
12
1.5
14
2
7.5
1.8
9.9
3
11.3
3.7
13.1
4
9.2
3.9
11.5
5
5.3
5.8
4.9
  

// 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 );

See Also

GetSeriesCount Method | SetSeriesYValuesFromArray Method | SetSeriesCaption Method | GetSeriesYValue Method

Applies To: Chart Object