WebChart Reacting to changes in active items

If I have a chart, say a pie, and there are X items.
If I click on one of the labels in the legend it hides that item from the pie.

I’d like to react to that change so that I can update an associated list of data associated with it.

For example, if it were a set of countries and someone clicks to hide USA, I’d like my table with data to remove all the USA entries.

Make sense?
Is this doable? Seems like it should be. I must be missing something obvious.

I haven’t myself explored WebCharting, but there is a WebChart.Pressed Event which will pass you the DataSet that was clicked. When you know what DataSet was clicked, you could remove that data from your master DataSet and re-load the chart?

For a pie, the dataset has a series of values (in one dataset)
I looked at that, but couldn’t figure out how to tell which labels for that dataset were pressed.

Maybe I’m using the chart control wrong though. I haven’t spent a lot of time with it.

no no, you are right, Tim.

Thank you.

hmmmm actually no - it gets clicks on the dataset but can’t tell when a value has been enabled or disabled

The dataset class has a tag property, you should be able to use that to store some identifier.

The problem is that the dataset isn’t difficult to find.
If someone clicks the 4th legend item, it crosses it out and hides that element from the chart.
I can’t find any way to know that this has happened at all programmatically.
If I click on one of the items in the chart I get its index.
If I click on the legend the index is -1. That’s not usable at all.
I’m was hoping I could somehow interrogate the control to find out which legend items are selected or not, but there is no way.

isn’t there an IsVisible property for that?

There is also IsLegendVisible

That’s for the entire dataset
The dataset has any number of values which can be shown or hidden
The legend is show or hidden on whole - not just individual nodes

I dont know what you mean, the legend on/off (strike trough) is the dataset isn’t it?

This is a chart with one dataset

Var dataset As New ChartCircularDataset("color", values, cols)

values is double array and cols is a color array

Here I clicked “brown” and it strikes it out and hides it from the pie.
I get a pressed event with an index of -1.
There is no way to interrogate the chart or dataset to find out which elements are “hidden”

Unless I’m missing something obvious.

I’m not sure WebChart was designed to be this interactive. Latency and all that. Maybe I’m wrong.
Can you do what you want in Desktop? If so, then we may need to ask to make it work for Web.

I don’t think I can in desktop either.
I don’t think this would add any more latency issue than what’s already going on.
There just needs to be a way to determine which legend items are selected or not - that could be evaluated optionally anytime there is a pressed event.

I’ll add a feature request.

A user that will click one, then other, then other rapidly will make your webapp respond slower than the clicks.
The graph will update as it should be on the browser but whatever you want to calculate/show to the user may be slower than expected (as other sites may have that in browser and not in server).

it’s already responding. The pressed event fires.
It’s just not allowing me to get the information that I need.

What I’m trying to say is that if you add some code to the pressed event and send responses to the browser you may see the delay. It may also change if you use the send in batches or not.
Just a heads up, it may never affect your app.

I understand the Ricardo added the pressed event.

You may want to ping @Ricardo_Cruz about this and create an Issue, to either add what you need/want or for clear documentation/example.

@Chris_Halford I don’t think this is possible at the moment, could you please create a Feature Request? :folded_hands:

Edit: Just to clarify, it isn’t possible at the moment in Xojo Web, but the underlying library supports reacting to clicks on labels.

3 Likes