Text-to-vis (Vega Lite GPT)

Nate Agrin · Friday Demos · March 29, 2024 · 8:46

Text to vis for advanced Vega Lite visualization opens up more custom vis opportunities in the longtail

Try it yourselfThe full week on docsaivisualizationworkbook

Transcript

This transcript is auto-generated. Names and product terms may be wrong.

  1. I'm going to give a quick demo of a little feature that Elliot and I worked on in the last day um and that feature is basically the ability to use AI to generate our viz um and specifically vegalite configs so let's start with a easy one we'll just do users count State gender um and you can see we've uh we got a lot of states in here we're going to also include country um and we'll do a simple one Okay so we've already got this bar chart um we're going to click on this new icon here and we get this little prompt that we can play around with um and so what we can say is uh create a bar chart uh of users can

  2. count by State uh split by gender or let's say stacked filter for country is USI and so these take a little bit of time to run I'm just going to let them run live and uh what you can see is I've produced that chart um we can say take that same chart and sort them sort each bar descending order by total users count not entirely sure how I'll interpret this but let's find out sweet did exactly what I was hoping it would do um and you can see it's also escaping the fields correctly um so note that it didn't add a tool tip so let's see that looks great now please add a tool tip um hope hopefully it will come back with the correct

  3. tool tip code all right perfect okay so that's like a pretty straightforward one let's try another workflow that um seems to be working pretty well so if I go up here to all fields and I just say uh preview um so now I've kind of created a pretty wide field and let's hopefully not crash my computer and bump this up to 50,000 and so now I've just sort of created like a a big cubish thing and switch to chart notice we default to the table but I'm just going to tell it to kind of make something for us B on the data generate chart that might show an interesting Insight oh so this is a a bug state that we definitely see pretty frequently and

  4. the issue is that it's not escaping the fields correctly so that should be pretty easy to fix oh you can see starting to get some data in again and so obviously what it's doing is it's um creating an average of the retail price uh for each product category based on this wide table that we have here um so that's kind of fun there are a bunch of uh statistical functions that um that Vega includes uh uh which you know we don't tend to use all of uh under the hood but because the AI has access to all of Vega light it can so we can do something similar like um we can go to users and say preview um and let's bump this limit up

  5. to say 10,000 and now we could say um create a chart that shows the total number of users uh by age bin each age group bin age um 10year intervals and hopefully it'll use Vega's built-in uh binning functionality you can see here step 10 to take our the data we have and in fact uh because we have many users in our uh demo data this is actually accurate we're not missing anything um but it does highlight one of the interesting aspects of using uh non-aggregated data coming back from your database um you know obviously you would need to download quite a bit more to get something akin to running a um a binning uh function in your SQL directly or an aggregation in your SQL

  6. directly um okay let's try a couple more quick demos uh that's amazing yeah really cool stuff um I would say it's like you know it's a few percent scary because it's like now Vega can do aggregation and calculation um so we got to kind of think about what people do with that kind of stuff but um like we've used Vega really well as sort of the release valve for I can't quite do the thing I need to do and that actually seems somewhat releasable for when we want to actually let people do things with those so um it's a pretty cool opportunity if if we go integrate that to make sure I'm not missing out on New I think I understand why that might be

  7. a little bit scary but for the benefit of the group could you give a little bit more context there yeah so if we wanted to in in Omni today do that sort of last example that we saw where the bars are bucketed into 10 10 year increments or things like that the sort of Sly way to do that is you create a field you only pull back you make sure you pull back every single row because you run it in SQL so we create the bins we create the counts and then we go visualize that small data set in the the Vega example what was happening was he was pulling back a part of the table uh instead of the whole table so first you

  8. need to make sure you get all the data back if you're going to go regroup in Vega that's GNA be a problem the second one is that the database and Vega might actually have different sort of corner case handling so the simple example is like do T get counted on the bottom side or the top side or do 20s get counted in the previous bucket or the next bucket or how do nulls get handled these are actually nuanced across all the databases and we spend a lot of time trying to fix those things and as soon as you create a new processing layer for data all those problems represent themselves and we could either handle them or sort of deal with the edge cases that

  9. exist and so like the things that you do might not have the exact expected response that you have in the rest of the app and so it's just like another piece of surface area that is sort of a blackbox for how the math gets done um which can be a little tricky but like you know it's if it's valuable it's valuable um so it's like this fine line between just kind of letting people do stuff and making them do it the absolute most correct way and I think that we've compromised that stuff well but we still need to be careful about it always thank you super helpful