add reset line chart option
This commit is contained in:
@@ -82,12 +82,10 @@
|
|||||||
|
|
||||||
this.data.chart.events = {
|
this.data.chart.events = {
|
||||||
mounted: function (chartContext, config) {
|
mounted: function (chartContext, config) {
|
||||||
console.log('moount', chartContext)
|
renderLegend(chartContext);
|
||||||
renderCustomLegend(chartContext);
|
|
||||||
},
|
},
|
||||||
updated: function (chartContext, config) {
|
updated: function (chartContext, config) {
|
||||||
console.log('update')
|
renderLegend(chartContext);
|
||||||
renderCustomLegend(chartContext);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,7 +93,15 @@
|
|||||||
|
|
||||||
chart.render();
|
chart.render();
|
||||||
|
|
||||||
function renderCustomLegend(chartContext) {
|
// reset custom zoom button
|
||||||
|
var resetZoomButton = document.querySelector('#chart-reset-zoom-{{ $name }}');
|
||||||
|
resetZoomButton.addEventListener('click', function () {
|
||||||
|
chart.resetSeries()
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
// generate custom legend view
|
||||||
|
function renderLegend(chartContext) {
|
||||||
var legendContainer = document.querySelector('#chart-legend-{{ $name }}');
|
var legendContainer = document.querySelector('#chart-legend-{{ $name }}');
|
||||||
|
|
||||||
if (!legendContainer) return;
|
if (!legendContainer) return;
|
||||||
|
|||||||
@@ -89,7 +89,10 @@ new class extends Component {
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<x-dropdown label="{{ $scope }}" class="btn-ghost btn-sm">
|
<div class="flex items-center">
|
||||||
|
<x-button title="{{ __('Reset chart') }}" icon="o-arrow-path" class="btn-ghost btn-sm btn-circle mr-2" id="chart-reset-zoom-{{ $name }}" />
|
||||||
|
|
||||||
|
<x-dropdown title="{{ __('Choose time period') }}" label="{{ $scope }}" class="btn-ghost btn-sm">
|
||||||
|
|
||||||
<x-menu>
|
<x-menu>
|
||||||
@foreach($options as $option)
|
@foreach($options as $option)
|
||||||
@@ -102,7 +105,7 @@ new class extends Component {
|
|||||||
@endforeach
|
@endforeach
|
||||||
</x-menu>
|
</x-menu>
|
||||||
</x-dropdown>
|
</x-dropdown>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
|
|||||||
Reference in New Issue
Block a user