PHP Класс 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']), ], ] ] ]);
Наследование: extends yii\base\Component, implements JsonSerializabl\JsonSerializable
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$columns column configuration
$data the underlying data source

Открытые методы

Метод Описание
__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.

Защищенные методы

Метод Описание
getFormatters ( ) : callable[] Built-in formatters, which can be used in the [[$columns]] configuration.
normalizeColumns ( ) Prepares the [[$columns]] for use by SeriesDataHelper::process.

Описание методов

__construct() публичный Метод

Constructor
См. также: setColumns()
См. также: 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() защищенный Метод

Built-in formatters, which can be used in the [[$columns]] configuration.
protected getFormatters ( ) : callable[]
Результат callable[]

jsonSerialize() публичный Метод

public jsonSerialize ( )

normalizeColumns() защищенный Метод

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

process() публичный Метод

Processes the source data and returns the result.
public process ( ) : array
Результат array the processed data

setColumns() публичный Метод

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() публичный Метод

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

Описание свойств

$columns защищенное свойство

column configuration
protected $columns

$data защищенное свойство

the underlying data source
protected $data