Drilldown navigation but retain also the orginal members in icCube on click drilldown chart - iccube

How to add the standard drilldown navigation to children ($member.children), but keep the orginal data as well. Preferable, as generic as possible, so I do not have to know what is on the rows at all (might be 1 hierarchy or a combination of multiple).

It's part of the new release (6.6). You can now us $axis in the MDX expression :
$axis +$member.children
and a variant that shows only one drilldown path :
Filter($axis as t, t.currentMember.level_number <= $member.level_number) + $member.children
The result is something like :
After clicking 2006:

Related

Multiple altair charts generated by the same cell

I have a list of pandas dataframes I named entries, which I want to visualize after running code from the same cell. Below is the code I used :
alt.data_transformers.disable_max_rows()
for entry in entries :
entry['ds'] = entry.index
entry['y'] = entry['count']
entry['floor'] = 0
serie = alt.Chart(entry).mark_line(size=2, opacity=0.7, color = 'Black').encode(
x=alt.X('ds:T', title ='date'),
y='y'
).interactive().properties(
title='Evolution of '+entry.event.iloc[0]+' events over time'
)
alt.layer(serie)\
.properties(width=870, height=450)\
.configure_title(fontSize=20)
When i run the same code out of the 'for' loop, I get to see the one chart that corresponds to one dataframe, but once I run the code above, I don't get any graphs at all.
Does anyone know why It's not working or how to solve this issue?
TLDR: use chart.display()
Unless a chart appears at the end of the cell, you must manually display it.
By analogy, if you run
x + 1
by itself, Python will display the result. However, if you run
for x in range(10):
x + 1
Python will not display anything, because the last statement in the cell (in this case the for loop) has no return value to display. Instead you have to write
for x in range(10):
print(x + 1)
For altair, the mechanism is similar: if the chart is defined in the last statement in the cell, it will be automatically displayed. Otherwise, you have to manually trigger the display, which you can do using the display method:
for i in range(10:
chart = alt.Chart(...)
chart.display()
For more information on display troubleshooting in Altair, see https://altair-viz.github.io/user_guide/troubleshooting.html

How does one use a CDSView with MultiLine on GMAPPlot?

(First Question so apologies)
Bokeh 1.3.4
Situation:
I am trying top map a Bokeh MultiLine using a CDSView and all the existing examples seem to use the "figure" object which has a helper (multi_line) which accepts a view as an argument. I am doing this on top of a GMAPPlot which does not support multi_line (only MultiLine) (see below). The commented out line throws an error saying GMAPPlot does not support multi_line.
plot = GMapPlot(
x_range=Range1d(), y_range=Range1d(), map_options=map_options, sizing_mode='scale_height'
)
.
.
.
sel_sa1s = []
v_bf = [True if sa1_val in sel_sa1s else False for sa1_val in v_source.data['SA1']]
v_view = CDSView(source=v_source, filters=[BooleanFilter(v_bf)])
v_ml = MultiLine(xs="xs",ys="ys",line_color="black", line_width="w")
#v_rend = plot.multi_line(xs="xs",ys="ys",line_color="black", line_width="w", source=v_source, view=v_view)
v_rend = plot.add_glyph(v_source, v_ml, name='votes')
The snippet shown above works and maps the entire network (very crowded) because there is no filter. What I want to have happen is for the filter to be initialised to hide everything then when the user clicks on an area (SA1) it will display the network related to that SA1.
Actually I can do that but only one area at a time and it would be much more efficient to be able to load the whole map and use a filtered view to control which sub-networks are displayed.
It seems that GMAPPlot only likes the pattern:
create glyph
add glyph
So, my question is - how does one use a CDSView in this environment (how does one add it to the renderer?)
Screenshot of unfiltered data set
It seems that GMAPPlot only likes the pattern:
create glyph
add glyph
That has not been true for some time. There is a higher level bokeh.plotting.gmap function that creates and configures GMapPlot instances with deafult axes, etc, and also has all the same methods and conveniences as figure (e.g. multi_line). It will be much less work to go this route than assembling everything by hand from low-level objects.

How to use FORMATTED_VALUE in a cumulated graph?

At first, from the Data Render panel in icCube report, I used context.cumulativeCol(); in the Value field in order to create my cumulated graph.
Now, since the format of my data is not well suited for my application (I have values such as '4.547473508864641e-13' which I want to be formatted to 0.00), I tried to add parameters to the function :
var col = context.getColumnIndex();
var measure = context.getMeasures();
var property = "FORMATTED_VALUE";
return context.cumulativeCol(col, measure, property);
But I cannot get a proper output.
How should I do it?
You cannot use FORMATTED_VALUE to format numbers calculated on the client side, it's available on for data that comes directly from the server. So in your case you need to implement your own client-side formatting. You could use mathJS that bundled to the reporting i.e.:
return math.format(context.cumulativeCol(col), {notation: "fixed", precision: 2})
Or use any other JS formatting method like .toFixed(2)

Bokeh or HoloViews multiple depended dropdowns

I have a data set with 3 of the columns having categorical values. I want to create 3 drop downs in Bokeh or HoloViews in which the first drop down selection determines the values of the list in the other 2 drop downs. Can anyone point me to any of the tutorials or blog or docs that show how to this. I don't seem to fine any.​
I appreciate your time.
Thanks!
If you are working in a Jupyter notebook, you can use
paramnb to do this, taking advantage of the way a notebook separates code into different cells:
Here I did "Run all", then selected c3 in the first widget, which re-runs the two cells below it to update them. I then selected a "high" value in the second set of widgets, which re-runs the plot to update it.
This pattern will let you do arbitrary chaining like this if you have notebooks, and if Jupyter Dashboards is an option for you then you can string these cells together to make an application. But this is just one approach...
Here's an example where the values of one dropdown change dependent of the selection made in the other dropdown.
In the example, when you select a continent in one dropdown, the dropdown with possible countries changes in the other dropdown. This happens because of: #pn.depends(continent.param.value, watch=True)
import panel as pn
_countries = {
'Africa': ['Ghana', 'Togo', 'South Africa'],
'Asia' : ['China', 'Thailand', 'Japan'],
'Europe': ['Austria', 'Bulgaria', 'Greece']
}
continent = pn.widgets.Select(
value='Asia',
options=['Africa', 'Asia', 'Europe']
)
country = pn.widgets.Select(
value=_countries[continent.value][0],
options=_countries[continent.value]
)
# the countries dropdown is dependent on the continent dropdown
#pn.depends(continent.param.value, watch=True)
def _update_countries(continent):
countries = _countries[continent]
country.options = countries
country.value = countries[0]
pn.Row(continent, country)
This holoviews + panel question has an example of dropdowns that are dependent on the value of another dropdown:
How do i automatically update a dropdown selection widget when another selection widget is changed? (Python panel pyviz)
The example with dropdowns dependent on other dropdowns comes from the GoogleMapViewer on this tutorial page:
https://panel.pyviz.org/user_guide/Param.html

How to extract information from a message of an imported module?

I am trying to take the "buttons" example (http://elm-lang.org/examples/buttons) and import it from another module that would display several of them on the same page.
I am afraid that I am still thinking with components in mind, but I just want to share it anyway.
I created Main.elm that load a slightly modified version of the buttons example (Buttons.elm).
In Main.elm I have a list of Buttons.Model that I use to generate the list of buttons.
I am stucked now because I don't know how to get the necessary info from Buttons.Msg in Main.elm
To see the code:
$ git clone https://github.com/lucamug/elm-multiple-buttons.git
$ cd elm-multiple-buttons/
$ elm-package install
$ elm-reactor
and open
http://localhost:8000/source/06/buttons.elm
http://localhost:8000/source/06/main.elm
-- Solution
The problem, as pointed out by Chad Gilber in the accepted answer, was in this line:
(List.indexedMap (\position buttons -> Html.map Tag (Buttons.view position buttons)) model.buttonsList)
this is the correct version
(List.indexedMap (\position buttons -> Html.map (Tag position) (Buttons.view buttons)) model.buttonsList)
If you are interested in this implementation, you can find more details in this post https://medium.com/#l.mugnaini/recycling-elm-code-transforming-it-in-a-module-4946d5ccd3cd
You will need to update your Tag constructor to include the array index.
The relevant changes to code are:
view model =
div []
(List.indexedMap (\position buttons -> Html.map (Tag position) (Buttons.view position buttons)) model.buttonsList)
type Msg
= Tag Int Buttons.Msg
update msg model =
case msg of
Tag position button_Msg ->
And you'll want to remove the hardcoded position = 1 in your update function.
This Pull Request outlines the changes necessary.

Resources