Hexagon Geospatial
MENU

Smart M.App

Looking for answers in regards to M.Apps, M.App Exchange or M.App Studio? Smart M.App Tech Discussion board is where you can search, ask your questions and assist others by sharing your knowledge. Join the conversation, connect, contribute and share.
Showing results for 
Search instead for 
Do you mean 
Reply
Contributor
Posts: 77
Registered: ‎01-20-2016

Link BI Widget with raster files

Hi!

We have a GeoJSON with 10 polygons of the same area in a stack and use it for creating a chart. Instead of showing the polygons in the BI Map View, we would like to display the corresponding raster data set. The connection of BI Widget and raster data is e.g. the attribute 'date' in GeoJSON and 'date' in raster file name.

 

Any help appreciated!

Ruth

Technical Evangelist
Posts: 1,032
Registered: ‎09-11-2015

Re: Link BI Widget with raster files

Hi Ruth,

 

Is this topic still actual? I know we talked about it in separate discussion but that's some time already.

 

If so.. perhaps the first question would be, how is the raster data brought to Map? Is that WMS or WMTS? How would you expect to hide just a portion of an WMS image? Maybe it would be enough to change the "selected" CSS style for the GeoJSON layer which is displayed upon this image.

 

Jan

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Contributor
Posts: 77
Registered: ‎01-20-2016

Re: Link BI Widget with raster files

Hi Jan,

 

this topic is still relevant.

We have 10 different raster data sets published in a map composition in a kind of stack. Every raster file belongs to a different date. If I click in my chart which was derived from a GeoJSON layer based on date, I would like to have the corresponding raster file displayed. The relation is the date.

It would be fine to have a solution here.

Thank you,

Ruth

Technical Evangelist
Posts: 1,032
Registered: ‎09-11-2015

Re: Link BI Widget with raster files

Hi Ruth,

Ok, so I guess you only need to hook up to mouse click event handler on a widget. This event handler would check the clicked value (string or date) and based on that it will show/hide proper legend entries.

 

There's no public API for those event handler but I will check with development if we can somehow modify them.

 

Jan

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Highlighted
Technical Evangelist
Posts: 1,032
Registered: ‎09-11-2015

Re: Link BI Widget with raster files

[ Edited ]

Ok, probably got it.

 

You can attach an event handler to each chart widget, here's a list of possible events: https://github.com/dc-js/dc.js/blob/master/web/docs/api-latest.md#basemixinonevent-listener--basemix...

 

In our case it is probalby best to utilize "filtered" event. This event will return the new filter value that is used to filter other related chart and/or the map. In other words it will be the dimension value. If this value is somehow related to some portion of legend entry name in your case then you can simply toggle displaying of the particular legend entries.

 

You only have to find the proper chart id (or attach this event to all charts):

//Find widgets:
$GP.ready("v1.0", function ($GP) {
   $GP.bi.stage.findStage(null, function (stage) {
      console.log(stage.widgets());
      // extract the proper widget ID
      // ...

      // attach event handler
      $GP.bi.stage.findWidget({
         descriptor : "chart_7j30"
      }, function (ret1) {
            ret1.chart
               .on("filtered", function (chart, filter) {
                  if (filter) {
                     alert(filter);
                  }
               });
      });
   });
});

 

Jan

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Frequent Contributor
Posts: 83
Registered: ‎07-18-2017

Re: Link BI Widget with raster files

Hi Jan,

 

does your code still work?When I run it like this

 

$GP.ready("v1.0", function ($GP) {
   $GP.bi.stage.findStage(null, function (stage) {
      console.log(stage.widgets());
   });
});

the console logs undefined.

Also when I pass an existing stageID as string.

 

Regards,

Marisa

Frequent Contributor
Posts: 83
Registered: ‎07-18-2017

Re: Link BI Widget with raster files

[ Edited ]

I found out that

 

$GP.ready("v1.0", function ($GP) {...})

seems to be called too early so I added 

 

$GP.bi.stage.findStage(null, function (stage) {
      console.log(stage.widgets());
   });

to a button callback.

Now I can log the widgets also for a custom stage id like "stage_froq". the widgets logged look like this:

loggedWidget_stageID_stage_123.JPG

First thing I don't understand: why is the stageId of the chart "chart_09ie"  the default id "zbyszek" and not my custom one "stage_froq"  where I retrieved the log from?

 

Second: When I add the code to find the widget   "chart_09ie"  ret1 is undefined and the following code doesn't run as ret1.chart doesn't exist...

 

$GP.bi.stage.findStage('stage_froq', function (stage) {
console.log(stage.widgets());
$GP.bi.stage.findWidget({descriptor:'chart_09ie'
}, function (ret1) {
console.log(ret1);
ret1.chart
.on("filtered", function (chart, filter) {
if (filter) {
alert(filter);
}
});
});

 What did I miss?

 

 

Technical Evangelist
Posts: 1,032
Registered: ‎09-11-2015

Re: Link BI Widget with raster files

Hi Marisa,

 

I think that you're confusing stage ID and stage name which you can define in the GUI. The gsp.stage.findStage() looks for a stage by the ID. For some reason the "zbyszek" is always used as an ID for the default stage.

 

Regards,

Jan

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Frequent Contributor
Posts: 83
Registered: ‎07-18-2017

Re: Link BI Widget with raster files

Hi Jan,

 

thanks for your fast reply, but 'stage_froq' was not the name I defined in the GUI. This id was set by the platform itself

(I logged the whole map object and __layers shows all the registered stages with their ids)

 

 mainContext.switchingMapViewerAdapter.getMapAdapter().then(function(adapter){
   map=adapter.__map;
   console.log(map);

 

I have more than one stage defined in the gui so they can't have all the same stage id  "zbyszek". And as I said, the first part of your code worked fine after placing it in the button callback. So my stageId "stage_froq" is valid as I got all the three chart widgets logged in the console which I created for this stage with the stageId "stage_froq". But this part doesn't work:

$GP.bi.stage.findWidget({descriptor:'chart_09ie'
      }, function (ret1) {
          console.log(ret1);
            ret1.chart
               .on("filtered", function (chart, filter) {
                  if (filter) {
                     alert(filter);
                  }
               });
      });

 

Did you test it in your environment and ret1 wasn't undefined ?

 

Regards,

Marisa

 

Technical Evangelist
Posts: 1,032
Registered: ‎09-11-2015

Re: Link BI Widget with raster files

I've now tested this code (please use gsp instead of obsolete $GP) and it worked fine:

gsp.bi.stage.findWidget(
   {
      descriptor : 'chart_jptz' // my chart Id found in the stage
   }, 
   function (ret1) {
      console.log(ret1); // returns the actual chart object
      ret1.chart
         .on("filtered", function (chart, filter) {
            if (filter) {
               // this event got registered and triggers once filter the chart
               alert(filter); 
            }
         });
});
Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Do you need immediate support?
Please submit a Ticket through our
Development Ticket Portal.