
Chart type swapper pattern
A quick modeling pattern for dynamically swapping the chart type with a filter.
Transcript
This transcript is auto-generated. Names and product terms may be wrong.
Uh, cool. I'm going to watch. I got two quick ones. Wait a second. Just ready. Oh, wait. Sorry. Okay. Uh, first one. Someone came on chat this morning and asked about toggling visualizations. Um, and my response was, "We don't do it." But then I realized that maybe we can do it. Um, so what I've built over here, as you can see, is a visualization where we can actually toggle between types.
And it's not perfect, but it toggles between types. And the way this is working is uh with some mildly unpleasant uh templated filters. So you can see that we built a filter toggler that takes in value of bar or line. We pass that into a catch. We pass that catch into a case statement. Uh so you know if it's bar then one, if it's line then one etc.
And then we just pass that into a pair of replicated measures. Um so you have to turn these into measures but then you can replicate them. We have count bar and count line and as you'll see all that we're doing behind the scenes here is we have the total and as we toggle this templated filter we will swap the viz type and then at the visualization level we just configure our two series independently.
So it's not going to work with much more complex visualizations, at least not well. Um, but this gives you actually a fairly straightforward way to toggle between visualization. Um, so in a pinch, this is an option. That is the first one. Uh second