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
ファイルを表示 Open project: miloschuman/yii2-highcharts-widget Class Usage Examples

Protected Properties

Property Type Description
$columns column configuration
$data the underlying data source

Public Methods

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

Protected Methods

Method 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 method

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 method

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

jsonSerialize() public method

public jsonSerialize ( )

normalizeColumns() protected method

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

process() public method

Processes the source data and returns the result.
public process ( ) : array
return array the processed data

setColumns() public method

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 method

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