PHP code example of nouman3070 / my-chart-widget
1. Go to this page and download the library: Download nouman3070/my-chart-widget library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nouman3070 / my-chart-widget example snippets
use nouman3070\ChartWidget\ChartWidget;
<?= ChartWidget::widget([
'elementId' => 'lineChart',
'type' => 'line',
'labels' => ['Jan', 'Feb', 'Mar', 'Apr'],
'datasets' => [
['label' => 'Sales', 'data' => [100, 200, 150, 300], 'fill' => false],
['label' => 'Purchase', 'data' => [80, 120, 90, 240], 'fill' => false],
],
])
<?= ChartWidget::widget([
'elementId' => 'barChart',
'type' => 'bar',
'labels' => ['Jan', 'Feb', 'Mar', 'Apr'],
'datasets' => [
['label' => 'Income', 'data' => [1000, 1500, 1300, 2000]],
],
])
<?= ChartWidget::widget([
'elementId' => 'hBarChart',
'type' => 'horizontalBar',
'labels' => ['Product A', 'Product B', 'Product C'],
'datasets' => [
['label' => 'Units Sold', 'data' => [300, 500, 200]],
],
])
<?= ChartWidget::widget([
'elementId' => 'pieChart',
'type' => 'pie',
'labels' => ['Chrome', 'Firefox', 'Safari'],
'datasets' => [
['label' => 'Browser Share', 'data' => [60, 25, 15]],
],
])
<?= ChartWidget::widget([
'elementId' => 'doughnutChart',
'type' => 'doughnut',
'labels' => ['USA', 'India', 'UK'],
'datasets' => [
['label' => 'Users', 'data' => [300, 400, 100]],
],
])
<?= ChartWidget::widget([
'elementId' => 'radarChart',
'type' => 'radar',
'labels' => ['Speed', 'Strength', 'Agility', 'Stamina', 'Skill'],
'datasets' => [
['label' => 'Player A', 'data' => [65, 75, 70, 80, 90]],
['label' => 'Player B', 'data' => [50, 85, 60, 70, 80]],
],
])
<?= ChartWidget::widget([
'elementId' => 'polarChart',
'type' => 'polarArea',
'labels' => ['A', 'B', 'C', 'D'],
'datasets' => [
['label' => 'Scores', 'data' => [11, 16, 7, 3]],
],
])
<?= ChartWidget::widget([
'elementId' => 'scatterChart',
'type' => 'scatter',
'labels' => [],
'datasets' => [
[
'label' => 'Observations',
'data' => [
['x' => -10, 'y' => 0],
['x' => 0, 'y' => 10],
['x' => 10, 'y' => 5],
],
'backgroundColor' => 'rgba(255, 99, 132, 0.6)',
],
],
])