-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/daredloco/lagoon-charts
- Loading branch information
Showing
19 changed files
with
493 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<div> | ||
@once | ||
@push('styles') | ||
<style> | ||
svg > g > g.google-visualization-tooltip { pointer-events: none } | ||
</style> | ||
@endpush | ||
@push('headerScripts') | ||
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> | ||
<script type="text/javascript"> | ||
google.charts.load('current', {'packages':['corechart'], 'language': '{{ config("lagoon.language") }}'}); | ||
</script> | ||
@endpush | ||
@endonce | ||
|
||
<script type="text/javascript"> | ||
google.charts.setOnLoadCallback(drawChart{{ $chartId }}); | ||
function drawChart{{ $chartId }}() { | ||
var data = google.visualization.arrayToDataTable( | ||
@json($chartData) | ||
); | ||
var options = @json($optionsArray); | ||
var chart = new google.visualization.CandlestickChart(document.getElementById('{{ $chartId.$random }}')); | ||
chart.draw(data, options); | ||
@if($printable) | ||
document.getElementById('lagoon-printable-{{ $chartId.$random }}').outerHTML = '<div style="display: flex; justify-content: center;"><a href="' + chart.getImageURI() + '">Print</a></div>'; | ||
@endif | ||
} | ||
</script> | ||
|
||
<div id="{{ $chartId.$random }}" style="height: 100%; width: 100%;"></div> | ||
@if($printable) | ||
<div id="lagoon-printable-{{ $chartId.$random }}"></div> | ||
@endif | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<div> | ||
@once | ||
@push('styles') | ||
<style> | ||
svg > g > g.google-visualization-tooltip { pointer-events: none } | ||
</style> | ||
@endpush | ||
@push('headerScripts') | ||
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> | ||
<script type="text/javascript"> | ||
google.charts.load('current', {'packages':['corechart'], 'language': '{{ config("lagoon.language") }}'}); | ||
</script> | ||
@endpush | ||
@endonce | ||
|
||
<script type="text/javascript"> | ||
google.charts.setOnLoadCallback(drawChart{{ $chartId }}); | ||
function drawChart{{ $chartId }}() { | ||
var data = google.visualization.arrayToDataTable( | ||
@json($chartData) | ||
); | ||
var options = @json($optionsArray); | ||
var chart = new google.visualization.ColumnChart(document.getElementById('{{ $chartId.$random }}')); | ||
chart.draw(data, options); | ||
@if($printable) | ||
document.getElementById('lagoon-printable-{{ $chartId.$random }}').outerHTML = '<div style="display: flex; justify-content: center;"><a href="' + chart.getImageURI() + '">Print</a></div>'; | ||
@endif | ||
} | ||
</script> | ||
|
||
<div id="{{ $chartId.$random }}" style="height: 100%; width: 100%;"></div> | ||
@if($printable) | ||
<div id="lagoon-printable-{{ $chartId.$random }}"></div> | ||
@endif | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<div> | ||
@once | ||
@push('styles') | ||
<style> | ||
svg > g > g.google-visualization-tooltip { pointer-events: none } | ||
</style> | ||
@endpush | ||
@push('headerScripts') | ||
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> | ||
<script type="text/javascript"> | ||
google.charts.load('current', {'packages':['gantt'], 'language': '{{ config("lagoon.language") }}'}); | ||
</script> | ||
@endpush | ||
@endonce | ||
|
||
<script type="text/javascript"> | ||
google.charts.setOnLoadCallback(drawChart{{ $chartId }}); | ||
function drawChart{{ $chartId }}() { | ||
var data = new google.visualization.DataTable( | ||
{ | ||
cols: | ||
[ | ||
{id: 'id', label: 'Task ID', type: 'string'}, | ||
{id: 'name', label: 'Task Name', type: 'string'}, | ||
{id: 'resource', label: 'Resource', type: 'string'}, | ||
{id: 'start', label: 'Start Date', type: 'date'}, | ||
{id: 'end', label: 'End Date', type: 'date'}, | ||
{id: 'duration', label: 'Duration', type: 'number'}, | ||
{id: 'percent', label: 'Percent Complete', type: 'number'}, | ||
{id: 'dependencies', label: 'Dependencies', type: 'string'} | ||
], | ||
rows: {!! $chartData !!} | ||
} | ||
); | ||
var options = @json($optionsArray); | ||
var chart = new google.visualization.Gantt(document.getElementById('{{ $chartId.$random }}')); | ||
chart.draw(data, options); | ||
} | ||
</script> | ||
|
||
<div id="{{ $chartId.$random }}" style="height: 100%; width: 100%;"></div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace Helvetiapps\LagoonCharts\DataTables; | ||
|
||
use Exception; | ||
|
||
class ColumnChartTable{ | ||
|
||
private $data = []; | ||
private $colCount; | ||
|
||
public function __construct(string $xAxisLabel, array $yAxisLabels, array $rows = []) | ||
{ | ||
$this->colCount = count($yAxisLabels) + 1; | ||
$rowCount = 0; | ||
$labels = [$xAxisLabel]; | ||
foreach($yAxisLabels as $label){ | ||
array_push($labels, $label); | ||
} | ||
$this->data = [$labels]; | ||
foreach($rows as $row){ | ||
$rowCount++; | ||
if(count($row) != $this->colCount){ | ||
throw new Exception("Row ".$rowCount." has ".count($row)." columns but needs to have ".$this->colCount."!"); | ||
} | ||
array_push($this->data, $row); | ||
} | ||
} | ||
|
||
public function addRow(array $row){ | ||
if(count($row) != $this->colCount){ | ||
throw new Exception("Row has ".count($row)." columns but needs to have ".$this->colCount."!"); | ||
} | ||
array_push($this->data, $row); | ||
} | ||
|
||
public function __toString() | ||
{ | ||
return json_encode($this->data); | ||
} | ||
|
||
public function toArray():array{ | ||
return $this->data; | ||
} | ||
} |
Oops, something went wrong.