JBARiskManagement / MapPIG

Probably Isn't GIS; A desktop mapping interactivity platform
MIT License
3 stars 0 forks source link

a plugin with statistical plots? #24

Open yitang opened 8 years ago

yitang commented 8 years ago

Hey, I wonder if MapThing would be suitable for generating statistical plots like this.

image

JamesRamm commented 8 years ago

Yes the plotly library is available through the MapThing API itself, currently only in MTContainer.modalChart.

You can of course just require(plotly) yourself and create the necessary elements, perhaps in a modal dialog etc...

JamesRamm commented 8 years ago

Documentation is limited at the moment: https://github.com/JamesRamm/MapThing/blob/master/docs/api/dom.md#containermodalchartdata

and you should consider the API a rough 'beta', but basically it uses the Plotly.newPlot function and passes the data.chartData and data.chartLayout properties to it:

https://plot.ly/javascript/plotlyjs-function-reference/

More work on exposing more of plotly to different parts of MapThing is welcome!

JamesRamm commented 7 years ago

@yitang Do you imagine such plots to be 'stand alone' - i.e. nothing to do with the map itself or that a plot is created by some action on the map? (e.g. someone clicks on a marker and a chart is popped up, something like this)

yitang commented 7 years ago

@JamesRamm i think it would be quite useful to have re-active plots which summarise the statistics of the current viewing region on the map (or the selected region).

JamesRamm commented 7 years ago

Hmmm what kind of statistics? I'm thinking of providing some kind of functionality to open a plot in a different window and leaving it up to the plugin developer to link it to the map. Perhaps making it easier to add a callback function for when the map is moved. Something like

 let mctrl = getMapCtrl()
 mctrl.on('moveend', myCallback)

 function myCallback(){
      //Do work to update plot here 
 }

And some kind of API to create a plot which has references to the map or certain map layers? This would be a bit more expanded than the current plotting api

yitang commented 7 years ago

For example, a histogram of the flood depth?

On 29 Sep 2016, at 16:52, James Ramm notifications@github.com wrote:

Hmmm what kind of statistics? I'm thinking of providing some kind of functionality to open a plot in a different window and leaving it up to the plugin developer to link it to the map. Perhaps making it easier to add a callback function for when the map is moved. Something like

let mctrl = getMapCtrl() mctrl.on('moveend', myCallback)

function myCallback(){ //Do work to update plot here } And some kind of API to create a plot which has references to the map or certain map layers? This would be a bit more expanded than the current plotting api

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

JamesRamm commented 7 years ago

Ok, so as mapPig is a generic tool for mapping/visualisation, it doesnt know anything about flood maps etc. However, you can use it for this, but most of the development would be done by you (the plugin developer) in writing a plugin to load flood data and compute statistics on it.

I think, the best way to go about this would be:

I think that the mapPIG development I suggested earlier - namely, a plotting API which allows you to create separate windows for the plot - is all that is required in mapPIG to allow this. You would use the mctrl.on function to add a callback to update the plot when the map moves.

From a user perspective, I imagine the plugin would simply add a panel which would allow the user to