Suppose I have 3 columns: country, date, price. I want to plot a line chart with price as y-axis and date as x-axis, where each country has its own colour.
I have looked through the options in the visualisation section and can’t find the following things:
- Settings to configure what column goes to which axis.
- Specify colour to follow column values.
How do I achieve what I want to do?
I think what you want to do is adjust your query a bit. I pulled together a similar query that looks like this: two dimension columns:
date, and a measure for
You are right, I only get one line, despite the number of countries in the first column. What you want to do in order to break up the line by
country, is to pivot that column. Hover over the column heading and you can click the gear. Then just select pivot.
Once you do that, just hit run again and the query will provide a column for each
price. You can then click the settings on the line chart (top right) and edit the
seriestab allows you to pick a color for each country or even rename them!
That should get you where you need to go. Let us know if that works!
Hi Eric, thanks for the solution. It works!
I have a follow-up question. Let’s say, in addition, to those 3 columns above, I have another column called is_app (yes/no type). Is it possible to make a chart, where:
That is totally possible so long as you also pivot by the yesno dimension as well. I was able to make simple example like the above and then changed the
yescolumns to scatter plot.
It’s not as clean as, say a dotted/dashed line graph but this is what’s currently possible. I can pass that along to Product though.
Thanks for your prompt reply, Vincent.
Yes, it would be great if Looker can customise graph based on colour, type, size, shape and besides that, ability to split plot into a matrix of panels (faceting) and choose which column goes to which axis, so that we can visualise more dimensions than what currently is possible.
Using the above example:
I’ve noticed that if this was on a dashboard with the default filters for state set to ‘New York’ and ‘California’ and I decided that I want to switch one state to Washington, then the customization will not apply to the new ones. Is there an easy way to override this so that the 1 and 2 positions are always lines and the 3/4 are always dots? alternatively, is there a way so that regardless of states filtered, No is always a line and Yes is always a dot?
@ajhong91, Thanks for your question.
Currently, there is no way to swap out states, maintain the order of the columns, and have the visualizations recognize the order and type of dimensions. This is due to the fact that predetermining the order of columns and which visualizations to apply to them will generally be different for every dataset and query. Thus, the goal is to provide customizable visualization options which allow for this level of granular control.
I see how this could be helpful and would be happy to pass this along to the product team. In the meantime, the best option will be to swap out the state and replicate the visualization.
Thank you! You guys rock!