Skip to content

Commit

Permalink
implement chartjs support, part 3
Browse files Browse the repository at this point in the history
  • Loading branch information
mutantsan committed Jun 6, 2024
1 parent 77e3177 commit c5ccdca
Show file tree
Hide file tree
Showing 17 changed files with 628 additions and 19 deletions.
15 changes: 15 additions & 0 deletions ckanext/charts/assets/css/vendor/tom-select.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 11 additions & 8 deletions ckanext/charts/assets/js/charts-global.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,23 @@ ckan.module("charts-global", function ($, _) {
"use strict";

return {
options: {
config: null
},

initialize: function () {
$.proxyAll(this, /_/);

// this hack is to dispatch a change event when a select2 element is selected
// so the HTMX could update the chart
this.el.find('select').on('change', function (e) {
htmx.trigger($(this).closest('.tab-content').get(0), "change")
});
// this.el.find('select').on('change', function (e) {
// htmx.trigger($(this).closest('.tab-content').get(0), "change")
// });

new TomSelect(".tom-select", { plugins: ['remove_button'], });
// initialize CKAN modules for HTMX loaded pages
htmx.on("htmx:afterSettle", function (event) {
var elements = event.target.querySelectorAll("[data-module]");

for (let node of elements) {
ckan.module.initializeElement(node);
}
});
}
};
});
12 changes: 12 additions & 0 deletions ckanext/charts/assets/js/charts-select.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ckan.module("charts-select", function ($, _) {
"use strict";

return {
initialize: function () {
$.proxyAll(this, /_/);

console.log('charts-select');
new TomSelect(this.el.find("select")[0], { plugins: ['remove_button'], });
}
};
});
1 change: 0 additions & 1 deletion ckanext/charts/assets/js/vendor/chartjs.min.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions ckanext/charts/assets/js/vendor/htmx.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit c5ccdca

Please sign in to comment.