lookout-ahoy 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascript/lookout/controllers/funnel_chart_controller.js +14 -3
- data/app/assets/javascript/lookout/controllers/line_chart_controller.js +1 -1
- data/app/assets/javascript/lookout/controllers/sparkline_controller.js +3 -3
- data/app/components/lookout/sticky_nav_component.html.erb +1 -1
- data/app/controllers/lookout/application_controller.rb +1 -2
- data/app/helpers/lookout/application_helper.rb +1 -6
- data/lib/lookout/version.rb +1 -1
- data/lib/lookout.rb +4 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cc40e394fab7179d1aedeffac0094bc4ff1c6b9ad6adf8c38894b59f470a3094
|
|
4
|
+
data.tar.gz: ec7e747428b3def4e970d51a72791ee72ad8d7c1a042463aa4a4b02fc804925a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a75cb93ccc72e4d2f62aec75e9b66a048f00833d79c822ff1486662ddff70ca32bfba4705b5cd0aa45b5ae9db517c52d9b7fe7293b02ef0f09081d2078dad6d6
|
|
7
|
+
data.tar.gz: ecbcef96bd32e3cf804c43acf1ec6a2f6e08743c5875412ae03a5560b77c858f385e237a7f77a19f601975cd3f9c2f56c22c262a62d257e20e91c712417522c4
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Controller } from '@hotwired/stimulus';
|
|
2
|
-
|
|
2
|
+
// NOTE: chartjs-plugin-datalabels is imported globally in application.js
|
|
3
|
+
// Do NOT import it here - it causes race conditions with Chart.js initialization
|
|
3
4
|
import { getCSS, externalTooltipHandler } from "helpers/chart_utils";
|
|
4
5
|
|
|
5
6
|
const calculatePercentageDifference = function(oldValue, newValue) {
|
|
@@ -18,6 +19,17 @@ export default class extends Controller {
|
|
|
18
19
|
this.funnel = JSON.parse(this.element.dataset.data);
|
|
19
20
|
console.log('Funnel data:', this.funnel);
|
|
20
21
|
|
|
22
|
+
// Check if Chart.js is available
|
|
23
|
+
if (typeof window.Chart === 'undefined') {
|
|
24
|
+
console.error('Chart.js is not loaded yet');
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Register ChartDataLabels plugin globally if available
|
|
29
|
+
if (window.ChartDataLabels && !window.Chart.registry.plugins.get('datalabels')) {
|
|
30
|
+
window.Chart.register(window.ChartDataLabels);
|
|
31
|
+
}
|
|
32
|
+
|
|
21
33
|
const fontFamily = 'ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"';
|
|
22
34
|
const labels = this.funnel.steps.map((step) => step.name);
|
|
23
35
|
const stepData = this.funnel.steps.map((step) => step.total_events);
|
|
@@ -48,7 +60,6 @@ export default class extends Controller {
|
|
|
48
60
|
const config = {
|
|
49
61
|
responsive: true,
|
|
50
62
|
maintainAspectRatio: false,
|
|
51
|
-
plugins: [ChartDataLabels],
|
|
52
63
|
type: 'bar',
|
|
53
64
|
data,
|
|
54
65
|
options: {
|
|
@@ -119,7 +130,7 @@ export default class extends Controller {
|
|
|
119
130
|
|
|
120
131
|
const visitorsData = [];
|
|
121
132
|
|
|
122
|
-
this.chart = new Chart(
|
|
133
|
+
this.chart = new window.Chart(
|
|
123
134
|
this.element,
|
|
124
135
|
config,
|
|
125
136
|
);
|
|
@@ -8,7 +8,7 @@ export default class extends Controller {
|
|
|
8
8
|
|
|
9
9
|
connect() {
|
|
10
10
|
// Wait for Chart.js to be available
|
|
11
|
-
if (typeof Chart === 'undefined') {
|
|
11
|
+
if (typeof window.Chart === 'undefined') {
|
|
12
12
|
console.error('Chart.js not loaded for sparkline:', this.labelValue);
|
|
13
13
|
// Try again after a short delay
|
|
14
14
|
setTimeout(() => this.renderChart(), 100);
|
|
@@ -19,7 +19,7 @@ export default class extends Controller {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
renderChart() {
|
|
22
|
-
if (typeof Chart === 'undefined') {
|
|
22
|
+
if (typeof window.Chart === 'undefined') {
|
|
23
23
|
console.error('Chart.js still not available for:', this.labelValue);
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
@@ -28,7 +28,7 @@ export default class extends Controller {
|
|
|
28
28
|
// Generate sample trend data (in production, pass real data via data-sparkline-data-value)
|
|
29
29
|
const data = this.hasDataValue ? this.dataValue : Array.from({length: 7}, () => Math.random() * 100);
|
|
30
30
|
|
|
31
|
-
new Chart(this.element.getContext('2d'), {
|
|
31
|
+
new window.Chart(this.element.getContext('2d'), {
|
|
32
32
|
type: 'line',
|
|
33
33
|
data: {
|
|
34
34
|
labels: data.map((_, i) => i),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<div class=" sticky top-0 min-h-sm z-[99999] py-6 bg-base-100">
|
|
2
|
-
<div class="max-w-6xl mx-auto
|
|
2
|
+
<div class="max-w-6xl mx-auto flex justify-between px-4 sm:px-6 lg:px-8">
|
|
3
3
|
<div class="flex items-center">
|
|
4
4
|
<a href="<%= Lookout.config.return_path %>" class="text-lg font-medium hover:text-primary transition-colors py-2">
|
|
5
5
|
<%= Lookout.config.return_copy %>
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
module Lookout
|
|
2
2
|
class ApplicationController < ActionController::Base
|
|
3
|
-
|
|
4
|
-
include defined?(Pagy::Method) ? Pagy::Method : Pagy::Backend
|
|
3
|
+
include Pagy::Method
|
|
5
4
|
include CompareMode
|
|
6
5
|
include RangeOptions
|
|
7
6
|
include Rangeable
|
|
@@ -113,12 +113,7 @@ module Lookout
|
|
|
113
113
|
|
|
114
114
|
def render_pagination
|
|
115
115
|
if @pagination
|
|
116
|
-
|
|
117
|
-
if @pagination.respond_to?(:series_nav)
|
|
118
|
-
@pagination.series_nav.html_safe
|
|
119
|
-
else
|
|
120
|
-
pagy_nav(@pagination).html_safe
|
|
121
|
-
end
|
|
116
|
+
@pagination.series_nav.html_safe
|
|
122
117
|
else
|
|
123
118
|
""
|
|
124
119
|
end
|
data/lib/lookout/version.rb
CHANGED
data/lib/lookout.rb
CHANGED
|
@@ -34,6 +34,8 @@ module Lookout
|
|
|
34
34
|
builder.pin "@hotwired/stimulus", to: "stimulus.min.js", preload: true
|
|
35
35
|
builder.pin "@hotwired/stimulus-loading", to: "stimulus-loading.js", preload: true
|
|
36
36
|
builder.pin "application", to: "lookout/application.js", preload: true
|
|
37
|
+
# Chart.js must be pinned BEFORE its plugins
|
|
38
|
+
builder.pin "chart.js", to: "https://cdn.jsdelivr.net/npm/chart.js@4.4.7/dist/chart.umd.min.js", preload: true
|
|
37
39
|
builder.pin "chartjs-plugin-datalabels", to: "https://cdn.jsdelivr.net/npm/chartjs-plugin-datalabels@2", preload: true
|
|
38
40
|
builder.pin "classnames", to: "https://cdnjs.cloudflare.com/ajax/libs/classnames/2.3.2/index.min.js", preload: true
|
|
39
41
|
builder.pin "chartjs-chart-geo", to: "https://cdn.jsdelivr.net/npm/chartjs-chart-geo@4.3.6/build/index.umd.min.js", preload: true
|
|
@@ -47,6 +49,8 @@ module Lookout
|
|
|
47
49
|
pin "@hotwired/stimulus", to: "stimulus.min.js", preload: true
|
|
48
50
|
pin "@hotwired/stimulus-loading", to: "stimulus-loading.js", preload: true
|
|
49
51
|
pin "application", to: "lookout/application.js", preload: true
|
|
52
|
+
# Chart.js must be pinned BEFORE its plugins
|
|
53
|
+
pin "chart.js", to: "https://cdn.jsdelivr.net/npm/chart.js@4.4.7/dist/chart.umd.min.js", preload: true
|
|
50
54
|
pin "chartjs-plugin-datalabels", to: "https://cdn.jsdelivr.net/npm/chartjs-plugin-datalabels@2", preload: true
|
|
51
55
|
pin "classnames", to: "https://cdnjs.cloudflare.com/ajax/libs/classnames/2.3.2/index.min.js", preload: true
|
|
52
56
|
pin "chartjs-chart-geo", to: "https://cdn.jsdelivr.net/npm/chartjs-chart-geo@4.3.6/build/index.umd.min.js", preload: true
|