Skip to content

Commit 89c955c

Browse files
authored
Merge pull request #209 from lorefnon/chart-fix
Fix regression causing chart height to not be respected and title not showing up
2 parents 7595795 + 0ea6265 commit 89c955c

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

sqlpage/apexcharts.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ function sqlpage_chart() {
3535
for (const c of document.querySelectorAll("[data-pre-init=chart]")) {
3636
try {
3737
const data = JSON.parse(c.querySelector("data").innerText);
38+
const chartContainer = c.querySelector('.chart');
39+
chartContainer.innerHTML = "";
3840
const is_timeseries = !!data.time;
3941
/** @type { Series } */
4042
const series_map = {};
@@ -71,7 +73,7 @@ function sqlpage_chart() {
7173
type: data.type || 'line',
7274
fontFamily: 'inherit',
7375
parentHeightOffset: 0,
74-
height: c.style.height,
76+
height: chartContainer.style.height,
7577
stacked: !!data.stacked,
7678
toolbar: {
7779
show: !!data.toolbar,
@@ -143,8 +145,7 @@ function sqlpage_chart() {
143145
series,
144146
};
145147
if (labels) options.labels = labels;
146-
c.innerHTML = "";
147-
const chart = new ApexCharts(c, options);
148+
const chart = new ApexCharts(chartContainer, options);
148149
chart.render();
149150
if (window.charts) window.charts.push(chart);
150151
else window.charts = [chart];

sqlpage/templates/chart.handlebars

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
class="card my-2 {{class}}"
44
data-pre-init="chart"
55
data-js="/{{static_path 'apexcharts.js'}}"
6-
style="height: {{default height 250}}px;"
76
>
87
<div class="card-body">
98
<div class="d-flex">
109
<h3 class="card-title">{{title}}</h3>
1110
</div>
12-
<div class="chart">
11+
<div class="chart" style="height: {{default height 250}}px;">
1312
<div class="d-flex justify-content-center h-100 align-items-center">
1413
<div class="spinner-border" role="status" style="width: 3rem; height: 3rem;">
1514
<span class="visually-hidden">Loading...</span>

0 commit comments

Comments
 (0)