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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a4adca74fe854b333e1cee9586ad01b0b2a94d8b85b8fd04b9ae17e3113b18f4
4
- data.tar.gz: 73c8ebb11604d6e40feb2c7f0a3cdda1af38fb1efa0bc347d317058abe7dccea
3
+ metadata.gz: cc40e394fab7179d1aedeffac0094bc4ff1c6b9ad6adf8c38894b59f470a3094
4
+ data.tar.gz: ec7e747428b3def4e970d51a72791ee72ad8d7c1a042463aa4a4b02fc804925a
5
5
  SHA512:
6
- metadata.gz: f3f84d89ddba73a7625f7d21b55ba70afe2f2907a0fa041e675d817d45bc413f9ee22421b139a37b3dc383aedbff17a82562156adf5443a7a46cdb087eede247
7
- data.tar.gz: 8e9cfce9194d9067a78883565c2e2c2d6b968ae571d52f3183a46d119cc4ceecd35b6a4e2eb0de11c05f261e788d0d5e9719bd886f8d15a435e034d334608a0e
6
+ metadata.gz: a75cb93ccc72e4d2f62aec75e9b66a048f00833d79c822ff1486662ddff70ca32bfba4705b5cd0aa45b5ae9db517c52d9b7fe7293b02ef0f09081d2078dad6d6
7
+ data.tar.gz: ecbcef96bd32e3cf804c43acf1ec6a2f6e08743c5875412ae03a5560b77c858f385e237a7f77a19f601975cd3f9c2f56c22c262a62d257e20e91c712417522c4
@@ -1,5 +1,6 @@
1
1
  import { Controller } from '@hotwired/stimulus';
2
- import 'chartjs-plugin-datalabels';
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
  );
@@ -140,7 +140,7 @@ export default class extends Controller {
140
140
  }
141
141
  }
142
142
  }
143
- this.chart = new Chart(this.element, options);
143
+ this.chart = new window.Chart(this.element, options);
144
144
 
145
145
 
146
146
  var canvas = this.element;
@@ -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 max-w-6xl flex justify-between ">
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
- # Support both Pagy v9 (Backend) and v43+ (Method)
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
- # Support both Pagy v9 (pagy_nav helper) and v43+ (series_nav method)
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
@@ -1,3 +1,3 @@
1
1
  module Lookout
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.0"
3
3
  end
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lookout-ahoy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - nativestranger