- Welcome to the TDX 20 expo demo.
My name is Skip Sauls
and I work on the Einstein Analytics product team.
And today I'm gonna talk to you
about a session that we've entitled,
Interact with Einstein Analytics Dashboards
using component methods.
So you're probably familiar with Einstein analytics
and you've done things like building dashboards
to access your data sets
and to interact with them.
And you know that we've got some great controls
to let you easily build them,
edit them, modify them and work with them.
And a lot of users find that
there's some great value in that,
but not everyone is a data analyst
who wants to go into a tool such as Studio.
A lot of our users want to embed these
into their own lightning applications.
So in the past we gave you something
called the Einstein Analytics Web SDK
for interacting with the components,
using events, lightning events.
And this works great,
as we can see in this example
where we can pick a dashboard,
we can pick a dimension such as the stage,
and then we can pick one of the values
here from stage names.
So we can pick for example, qualification,
and we'll send it over here and then click "fire".
And that sends an event over
that tells the component to respond to it.
And if you look at this list,
you can see that we're doing the same exact things
as if the user had clicked on it,
but we're doing it from these custom lightning components
on the left hand side.
At the bottom, you can see the event payload,
which is expressed as a JavaScript object
or adjacent object if you prefer.
If you look at this, it's just pure text
and we've added the qualification here
to these stage names selection.
If we add in something else
such as maybe closed won,
like, so
it builds up the payload and we can fire that.
And it makes the selection on the right again,
just as if I clicked on it.
And if I scroll up here,
I can see that closed won is now selected.
Now this works really well
for a lot of situations
where you're working in an asynchronous fashion,
but the problem is
you don't always know the state of the current dashboard.
And in the past we've had customers and partners,
who've had to build event listeners
that try to keep track of the state
every time something changes.
And the problem with that is
if your component doesn't exist
before the dashboard is realized,
you may not be able to trap all those events
and it makes it kinda tough to keep things in sync.
So what we've done
is introduced the notion of dashboards state
as a proper first class method.
In fact, a set of methods on the components.
So now you can actually look at a dashboard
and as an external component,
you can ask for the state and get it directly.
So let's go over here to the left hand side,
we're gonna click right here
and I'm gonna push the "get state" button
that is going to call
the get state method on that component.
And it shows this in the middle.
And again, this is not a business user app.
This is meant for developers
to learn how to use these new APIs.
And if we scroll down,
we can see that this now goes from existing business here,
you see right here
and then goes to needs analysis right here.
So it's very simple, very logical.
And these names map into what we call the queries
or what we used to call steps inside the dashboard.
And a lot of times this maps to a direct field in an object,
but because it's analytics,
it could be something that's actually done
through aggregation or some sort of transformation.
Well, let's change this on the right hand side,
by calling the set state method.
So this is the corresponding method
where we're gonna push this object into the dashboard.
So push set state,
and that dashboard will now update
to reflect the same state in the two.
Now a cool thing about this
is we're showing this for developers
so you can learn how it works,
and this is a live document.
So I can go to this and change it
to something like closed won.
Oops, let me
like so,
and when I press set state now
it sets it on the right hand side,
just as if I had gotten it from here and set it directly.
So again, your app will not necessarily
give anybody a text field.
I doubt many business users wanna type this kind of thing,
but you can imagine your lightning components
modifying this as they select something
as they click something in a record page
and so forth.
And we can go back and forth between them.
Like so.
You can also do things like store this state
and use it later.
It's very flexible, very open.
And it's an object
that you can just look at
just like anything else in JavaScript.
In fact, it has all the different assets
in here for the datasets,
for the pages and then all the various selections
and that sort of thing.
So with that,
we'd like you to try some of these sample outs out.
We've got a great developer center
that you'll see over in the resources,
that has links off into various trailheads
and docs and samples and that sort of thing.
And we look forward to talking to you all
on the trailblazer community.