How to display only one series on Altair chart - legend

For the interactive legend example, I was wondering if there is a way to display only one series and hide others on the chart after running the code. Then, when clicking on the legend, the chart can change to highlight different series.
The current example code displays all series at first, then highlights different series when clicking on the legend.
Here is the example code:
import altair as alt
from vega_datasets import data
source = data.unemployment_across_industries.url
selection = alt.selection_multi(fields=['series'], bind='legend')
alt.Chart(source).mark_area().encode(
alt.X('yearmonth(date):T', axis=alt.Axis(domain=False, format='%Y', tickSize=0)),
alt.Y('sum(count):Q', stack='center', axis=None),
alt.Color('series:N', scale=alt.Scale(scheme='category20b')),
opacity=alt.condition(selection, alt.value(1), alt.value(0.2))
).add_selection(
selection
)

You can do this using the init argument of the selection; for example:
selection = alt.selection_multi(fields=['series'], bind='legend', init=[{'series': 'Agriculture'}])

Related

Retain multi selection in Altair interactive legend when chart is clicked

I have created a compound bar chart in Altair with an interactive legend, where bars from one chart and legend elements can both be selected to filter another chart. This works well when only a single legend element is selected. However, when multiple legend elements are selected, selecting a bar alters the legend selection.
See the minimal example below. In this image, the Crookston and Duluth sites have been selected, with the result that the chart of sum of yield by year is filtered to those two sites. However, if I then click on the Manchuria bar in the sum of yield by variety chart, the legend selection changes so that only Duluth is selected, as seen in this image. (If I instead shift-click on the Manchuria bar, then only Crookston is selected in the legend.) The desired outcome is for both Crookston and Duluth to remain selected in the legend.
Is it possible to prevent the legend's selection from changing when the chart is clicked?
import altair as alt
from vega_datasets import data
source = data.barley()
bar_selection = alt.selection_multi(encodings=["y"])
legend_selection = alt.selection_multi(encodings=["color"], bind="legend")
varieties = alt.Chart(source).mark_bar().encode(
x="sum(yield)",
y="variety",
color="site",
opacity=alt.condition(
bar_selection, alt.value(1.0), alt.value(0.25)
),
).add_selection(bar_selection)
years = alt.Chart(source).mark_bar().encode(
x="sum(yield)",
y="year:N",
color="site",
).transform_filter(
bar_selection
).transform_filter(
legend_selection
)
(varieties & years).add_selection(legend_selection)

Apex 5 scatter marker chart dynamic series name

Is there a way to dynamically display the series name in Apex Scatter Marker chart type?
I tried using hidden page item but the chart is not rendering at all.
got it finally by modifying the generated XML:
...
..

list of line charts with a single calliper

I want to create a graph view as shown in the following image:
Multiple line charts has to be displayed in the ListView with a single line showing the selected value for particular x value will be displayed at the end of each chart.

rdlc: Display percentage on pie chart

I'm using Visual Studio 2010 reporting to generate a report which has a table and a pie chart. Both work just fine except that for the pie chart, I'm to put the % value on each pie chart slice.
1. Is this even possible?
2. If it is, how do I do it?
Thanks
To put the % value on each pie chart slice do this (as shown here):
On the design surface, right-click on the pie and select Show Data Labels. The data labels should appear within each slice on the pie chart.
On the design surface, right-click on the labels and select Series Label Properties. The Series Label Properties dialog box appears.
Type #PERCENT for the Label data option.
Beware: If you use multiple data fields like this:
you need to move every field to first position and perform above steps as shown here otherwise you end up with only one pie chart slice showing the percentage and the others are blank...

get label from notebook tab

I have a gtk.Notebook and i want get text of label from current gtk.noteBook tab.
I make that:
text = self.get_tab_label(self.get_nth_page(self.get_current_page()))
if i print text i see:
But in gtk help i read that: get_tab_label_text: returnvalue: the text of the tab label, or None if the tab label widget is not a gtk.Label.
How can i get tet from label in this situation?
Thank you.
Any gtk.Widget can be a Notebook tab label. It is usually a gtk.Label, but not always. So two API methods exist to cover both situations:
gtk.Notebook.get_tab_label() returns a gtk.Widget that is the label widget. If it is a gtk.Label, you will need to call gtk.Label.get_text() to get the text.
gtk.Notebook.get_tab_label_text() returns a string of text only if the label widget is a gtk.Label, otherwise will return None.