Class dosamigos\chartjs\ChartJs

Inheritancedosamigos\chartjs\ChartJs » yii\base\Widget

Chart renders a canvas ChartJs plugin widget.

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$clientOptions array The options for the underlying ChartJs JS plugin. dosamigos\chartjs\ChartJs
$data array The datasets configuration options and data to display on the chart. dosamigos\chartjs\ChartJs
$options array The HTML attributes for the widget container tag. dosamigos\chartjs\ChartJs
$type string The type of chart to display. dosamigos\chartjs\ChartJs

Public Methods

Hide inherited methods

MethodDescriptionDefined By
init() Initializes the widget. dosamigos\chartjs\ChartJs
run() Renders the widget. dosamigos\chartjs\ChartJs

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
registerClientScript() Registers the required js files and script to initialize ChartJS plugin dosamigos\chartjs\ChartJs

Property Details

$clientOptions public property

The options for the underlying ChartJs JS plugin. Please refer to the corresponding ChartJs type plugin Web page for possible options. For example, this page shows how to use the "Line chart" plugin.

public array $clientOptions = []
$data public property

The datasets configuration options and data to display on the chart. See its documentation for the different options.

public array $data = []
$options public property

The HTML attributes for the widget container tag.

public array $options = []
$type public property

The type of chart to display. The possible options are:

  • "Line" : A line chart is a way of plotting data points on a line. Often, it is used to show trend data, and the comparison of two data sets.
  • "Bar" : A bar chart is a way of showing data as bars. It is sometimes used to show trend data, and the comparison of multiple data sets side by side.
  • "Radar" : A radar chart is a way of showing multiple data points and the variation between them. They are often useful for comparing the points of two or more different data sets
  • "PolarArea" : Polar area charts are similar to pie charts, but each segment has the same angle - the radius of the segment differs depending on the value. This type of chart is often useful when we want to show a comparison data similar to a pie chart, but also show a scale of values for context.
  • "Pie" : Pie charts are probably the most commonly used chart there are. They are divided into segments, the arc of each segment shows a the proportional value of each piece of data.
  • "Doughnut" : Doughnut charts are similar to pie charts, however they have the centre cut out, and are therefore shaped more like a doughnut than a pie!
public string $type null

Method Details

init() public method

Initializes the widget.

This method will register the bootstrap asset bundle. If you override this method, make sure you call the parent implementation first.

public void init ( )
registerClientScript() protected method

Registers the required js files and script to initialize ChartJS plugin

protected void registerClientScript ( )
run() public method

Renders the widget.

public void run ( )