Knowledge Drop

How do I set the visualization type of a query in the API?


Last tested: Jun 20, 2019
 

When using the API for endpoints such as "run_inline_query" and "create_query" we can set the visualization type of the returned visualization using the "vis_config" parameter.

The documentation is very vague for this field:

"Visualization configuration properties. These properties are typically opaque and differ based on the type of visualization used. There is no specified set of allowed keys. The values can be any type supported by JSON. A "type" key with a string value is often present, and is used by Looker to determine which visualization to present. Visualizations ignore unknown vis_config properties."

However, when using "column" or "bar" for the type value, the result is always a table. What is going on??

This is due to the last line in the description. Values "column" and "bar" are invalid for the type field so those values are ignored the vis defaults to a table type. Looker-defined visualizations begin with "looker_", so for example "looker_bar" or "looker_column" will work as expected.

An example body will look something like this:

{
...
"vis_config": {"type":"looker_bar"}
}

The best way to find out what properties are applicable to a particular kind of visualization is to set up a look with a particular vis in the Looker UI, then use the API to fetch that look's query and examine the vis_config that the Looker UI created there.

 

This content is subject to limited support.                

 

 


0 replies

Be the first to reply!

Reply