PHP Class miloschuman\highcharts\SeriesDataHelper

It includes a set of built-in formatters to handle common preprocessing tasks (like converting datetime strings to JavaScript timestamps) and provides an extensible column configuration, which allows you to add custom parser/formatter handlers. Basic usage: php use miloschuman\highcharts\Highstock; use miloschuman\highcharts\SeriesDataHelper; Highstock::widget([ 'options' => [ 'series' => [ [ 'type' => 'candlestick', 'name' => 'Stock', 'data' => new SeriesDataHelper($dataProvider, ['date:datetime', 'open', 'high', 'low', 'close']), ], [ 'type' => 'column', 'name' => 'Volume', 'data' => new SeriesDataHelper($dataProvider, ['date:datetime', 'volume:int']), ], ] ] ]);
Inheritance: extends yii\base\Component, implements JsonSerializabl\JsonSerializable
Afficher le fichier Open project: miloschuman/yii2-highcharts-widget Class Usage Examples

Protected Properties

Свойство Type Description
$columns column configuration
$data the underlying data source

Méthodes publiques

Méthode Description
__construct ( BaseDataProvider | array $data, array $columns, array $config = [] ) Constructor
jsonSerialize ( )
process ( ) : array Processes the source data and returns the result.
setColumns ( array $columns ) Sets the column configuration.
setData ( BaseDataProvider | array $data ) Sets the underlying data source.

Méthodes protégées

Méthode Description
getFormatters ( ) : callable[] Built-in formatters, which can be used in the [[$columns]] configuration.
normalizeColumns ( ) Prepares the [[$columns]] for use by SeriesDataHelper::process.

Method Details

__construct() public méthode

Constructor
See also: setColumns()
See also: setData()
public __construct ( BaseDataProvider | array $data, array $columns, array $config = [] )
$data yii\data\BaseDataProvider | array the underlying data source
$columns array column configuration
$config array for future use

getFormatters() protected méthode

Built-in formatters, which can be used in the [[$columns]] configuration.
protected getFormatters ( ) : callable[]
Résultat callable[]

jsonSerialize() public méthode

public jsonSerialize ( )

normalizeColumns() protected méthode

Prepares the [[$columns]] for use by SeriesDataHelper::process.
protected normalizeColumns ( )

process() public méthode

Processes the source data and returns the result.
public process ( ) : array
Résultat array the processed data

setColumns() public méthode

Each element can be either an array ['column', 'format'] or a shortcut string 'column:format'. Column can be a string representing the attribute, field, or key from the source data. It can even be an integer if the source data uses numeric keys. Format can be one of the built-in formatters ('datetime', 'float', 'int', 'raw', 'string', or 'timestamp') or a callable that is used to prepare each data value. If format is omitted, the raw value will be passed to the chart. Example showing different ways to specify a column: php [ ['date_measured', 'datetime'], 'open', 'high:float', ['low', 'float'], ['close', function($value) { return ceil($value); }] ]
public setColumns ( array $columns )
$columns array

setData() public méthode

Sets the underlying data source.
public setData ( BaseDataProvider | array $data )
$data yii\data\BaseDataProvider | array the data source

Property Details

$columns protected_oe property

column configuration
protected $columns

$data protected_oe property

the underlying data source
protected $data