Skip to content

Commit

Permalink
Sorted dashboard widgets more meaningfully
Browse files Browse the repository at this point in the history
  • Loading branch information
jbednar committed Jan 16, 2019
1 parent f85f8a7 commit ebd7cf6
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions examples/dashboard.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"metadata": {},
"outputs": [],
"source": [
"import os, param, colorcet, holoviews as hv, panel as pn\n",
"import os, colorcet, param as pm, holoviews as hv, panel as pn\n",
"import intake, geoviews.tile_sources as gts\n",
"from holoviews.operation.datashader import rasterize, shade, spread\n",
"\n",
Expand Down Expand Up @@ -76,32 +76,32 @@
"norms = {'Histogram_Equalization': 'eq_hist', 'Linear': 'linear', 'Log': 'log', 'Cube root': 'cbrt'}\n",
"maps = ['CartoMidnight', 'StamenWatercolor', 'StamenTonerBackground', 'EsriImagery', 'EsriUSATopo', 'EsriTerrain']\n",
"bases = {name: ts.relabel(name) for name, ts in gts.tile_sources.items() if name in maps}\n",
"plots = {source.metadata['plots'][p].get('label', p):p for p in source.plots}\n",
"\n",
"class Explorer(param.Parameterized):\n",
" data_opacity = param.Magnitude(default=1.00, doc=\"Alpha value for the data opacity\")\n",
" map_opacity = param.Magnitude(default=0.75, doc=\"Alpha value for the map opacity\")\n",
" cmap = param.ObjectSelector(cmaps['fire'], objects=cmaps)\n",
" basemap = param.ObjectSelector(bases['EsriImagery'], objects=bases)\n",
" show_labels = param.Boolean(default=True)\n",
" normalization = param.ObjectSelector(default='eq_hist', objects=norms)\n",
" spreading = param.Integer(0, bounds=(0, 10), precedence=1e-9)\n",
" plot = param.ObjectSelector(default=source.plots[0], objects=source.plots, precedence=0)\n",
"class Explorer(pm.Parameterized):\n",
" plot = pm.ObjectSelector( precedence=0.10, default=source.plots[0], objects=plots)\n",
" normalization = pm.ObjectSelector( precedence=0.12, default='eq_hist', objects=norms)\n",
" cmap = pm.ObjectSelector( precedence=0.14, default=cmaps['fire'], objects=cmaps)\n",
" spreading = pm.Integer( precedence=0.16, default=0, bounds=(0, 5))\n",
" \n",
" @param.depends('plot')\n",
" basemap = pm.ObjectSelector( precedence=0.18, default=bases['EsriImagery'], objects=bases)\n",
" data_opacity = pm.Magnitude( precedence=0.20, default=1.00, doc=\"Alpha value for the data\")\n",
" map_opacity = pm.Magnitude( precedence=0.22, default=0.75, doc=\"Alpha value for the map\")\n",
" show_labels = pm.Boolean( precedence=0.24, default=True)\n",
" \n",
" @pm.depends('plot')\n",
" def points(self):\n",
" plot_method = getattr(source.plot, self.plot)\n",
" points = plot_method() # could add extra hvplot kwargs here\n",
" return points\n",
" return getattr(source.plot, self.plot)() # could add extra hvplot kwargs here\n",
"\n",
" @param.depends('map_opacity','basemap')\n",
" @pm.depends('map_opacity','basemap')\n",
" def tiles(self):\n",
" return self.basemap.opts(gopts).opts(alpha=self.map_opacity)\n",
"\n",
" @param.depends('show_labels')\n",
" @pm.depends('show_labels')\n",
" def labels(self):\n",
" return gts.StamenLabels.options(level='annotation', alpha=1 if self.show_labels else 0)\n",
" \n",
" @param.depends('data_opacity')\n",
" @pm.depends('data_opacity')\n",
" def apply_opacity(self, shaded):\n",
" return shaded.opts(alpha=self.data_opacity, show_legend=False)\n",
"\n",
Expand Down

0 comments on commit ebd7cf6

Please sign in to comment.