Quick question that may have been asked before... ...
# gooddata-ui
v
Quick question that may have been asked before... what would be the most efficient way to extract a raw data set from a chart in the UI, to use the data without having to fetch it a second time... to say... feed to an NLG library in the browser or something like that
j
Hello @Vincil Bishop! How about the useInsightDataView hook? Would that work for you?
v
Ah nice... seems like I might have asked this before...and it will work for regular charts that are configured on the front end as well? Not just insights?
@hunger regnuh
j
You want to use useInsightDataView for executing insights created in Analyze, and useExecutionDataView for executing ad hoc payload defined in JavaScript. Makes sense? 🙂
h
we’ve decided to not use any insights so we can manage everything in the code, we’ve been using the embedded react components (in an angular app), is it possible for us to get a dataview during that execution cycle? I noticed there’s an
onExportReady
callback, it seems to only accept csv or xslx though, is there a dataView option?
or even
useExecutionDataView
to run the query, get the dataView, then we can feed it into our NLG and a chart component (and save 1 query) would be fine by us allso
j
Just to clarify, you are not using any insights created in Analyze, you define everything in the code, right? Do I understand correctly that you don't use the <InsightView /> component, but you use <ColumnChart />, etc. and also <Execute />? Or do you use raw JavaScript useExecutionDataView hook instead? Or both?
When you use components such as <ColumnChart /> or <Execute /> there's no access to the raw data for you. If you need access to the raw data, I suggest that you use the useExecutionDataView — that's exactly what it's for.
v
The first part of what you say is true, we do not use <InsightView />
👍 1
j
You can totally use the useExecutionDataView hook to run the query, get the dataView and then feed it into your NLG!
v
Instead we define the charts in code, and use LineChart, BartChart, etc
👍 1
let me look at useExecutionDataView
and to complicate things we are on Angular
so far, we've been able to translate just about everything without a lot of problem
👌 1
h
yep, pretty spot on… if we do both the chart and useExecutionDataView, then the query would run twice? Is there a way to run the query just once so we could do both NLG and the chart?
j
Aaah now I see! You want both the chart to render but you also need the raw data at the same time. Got it.
v
I'm not above running a query twice.... but you know that's not my first choice
j
Well, I don't think this is possible, but it sounds like a very reasonable request — I'll let our Product know, and I'll also ask our DevOps if there are any "workarounds" for this.
h
right now the only “hack” i can think of is to run the chart, then simulate a “drill down” to get the dataView back
j
I understand that! Smart hack.
Let me also tell you that running the query twice isn't that big of a deal due to our sophisticated caching — they are still 2 async requests in your browser, BUT once the first query is resolved it is cached so that the 2nd query is returned practically immediately. There shouldn't be a huge impact on running the query twice 😉
v
yeah the queries are pretty fast
h
aaah, good to know we have options… thanks for the great help
v
still better than sending it all up to an API and then getting the NLG back
better to do it in the browser
j
I've submitted your feedback into our internal Product channel Thank you!
h
awesome… thanks 😄