+//# sourceURL=customization.js
+const KEY_PROPERTY = "GEO_ID", // change to your geometry ID
+// wait for the pointmap layer, store reference to it and apply customizations
+waitFor("pointmap", function(widget) {
+ let geochart = widget.chart;
+ GLOBALS.geochart = geochart;
+ // do other changes with the choropleth
+ overwriteClickBehavior(geochart);
+// wait for the table and apply customizations
+waitFor("table", function(widget) {
+ let table = widget.chart;
+// waits until the widget of particular type is on stage
+// this is simplified and it should be used just once for particular chartType
+// @param {String} chartType - "choropleth", "pointmap", "table", "row", "bar", "pie", etc.
+// @param {Function} callback callback function
+// @param {Object} callback.widget first widget of particular type
+function waitFor(chartType, callback) {
+ gsp.bi.stage.findWidgets({
+ if (!widgets || !widgets[0]) {
+ TIMEOUTS[chartType] = setTimeout(function() {
+ waitFor(chartType, callback);
+ clearTimeout(TIMEOUTS[chartType]);
+// zoom to bounding box with (transforming coordinates)
+function zoomToBBox(bbox, callback, errback) {
+ var bottomLeftCorner = {
+ // transform the points to current CRS
+ points: [bottomLeftCorner, topRightCorner],
+ sourceCrsId: "EPSG:4326",
+ targetCrsId: gsp.crs.getCurrent()
+ }, function(transformationResult) {
+ // get BBOX in form minx, miny, maxx, maxy
+ var points = transformationResult.points,
+ bbox = [points[0].x, points[0].y, points[1].x, points[1].y];
+// zoom to feature from GLOBALS.geochart.geoJson() with particular ID
+function zoomToFeature(featureId) {
+ if (!GLOBALS.geochart) return;
+ let feature = GLOBALS.geochart.geoJson().features.find(function(f) {
+ return f.properties[KEY_PROPERTY] === featureId;
+ gsp.ui.info("This row has no associated geometry");
+ gsp.bi.stage.requireLibraries(function(gvc) {
+ let geom = feature.geometry.type === "Point" ? gvc.turf.buffer(feature.geometry, BUFFER_SIZE) : feature.geometry;
+ let bbox = gvc.turf.bbox(geom);
+ zoomToBBox(bbox, function() {
+ gsp.ui.info(`Successfully centered on [${bbox.join(",")}]`);
+ gsp.ui.info("Could not zoom on this feature");
+// add "zoom to feature" tool
+function reformatTable(chart) {
+ let columns = chart.columns();
+ chart.columns(columns.concat([{
+ let featureId = d[KEY_PROPERTY];
+ if (!window.zoomToFeature) {
+ window.zoomToFeature = zoomToFeature;
+ return `<a href="#" onClick=window.zoomToFeature("${featureId}")>ZOOM</a>`;
+ // redraw the chart so that the changes may be applied
+// disable filter on click
+function overwriteClickBehavior(geochart) {
+ geochart.willDoMouseEvent(function(feature, event) {
+ if (event.type == "click") {
+ console.log("feature was clicked");