Creating a custom legend using Deneb

Hello,

I’m pretty new to Deneb, but I find the prospect of using it very exciting. I have a request to create a rather unorthodox report, essentially combining 3 types of reports (stacked column, clustered column and line on 2nd Y axis). Whilst I got most of the layout desired:

I wanted to know if there is a way to create a custom legend (and colors) to look something like this:

Any help or guidance would be greatly appreciated!

Deneb Legend.pbix (1.4 MB)

Hi @Deston

You can easily add a custom legend in Deneb. Here’s a link to an eDNA forum post on this topic.

I used an example of a custom legend in my video posted to YouTube yesterday; see from 29:20

Hope this helps.
Greg

3 Likes

Thanks @Greg! This definitely gave me some ideas.

As a side note; I completed your course on Deneb today - found it very useful! Any plans in the pipeline for an advanced course that delves into the finer nuances of Deneb?

Hi @Deston. I’m glad the course was informative. No, there are no plans for more Deneb courses at this time. Deneb v2 is currently under development and may be released later this year, and I imagine we’ll see then if the additional capabilities suggest another course.
Greg

Hello @Deston

Good to see that you are having progress with your inquiry. Did the responses from @Greg help you solve your inquiry?

If it does, kindly mark as the solution the answer that solved your query.

If you have a follow question or concern that requires additional support, feel free to open a new thread and reach out to us again with the updated details.

Hi @Greg,

If I may ask a follow up question, please.

I’ve replicated the hard coding of the legend, placed it in a VCONCAT channel, and then place the various chart elements in a LAYER channel.

Whilst I can see the legend now, my charts are not rendering:

When I take out the colour encoding however, it does:

Where am I going wrong here?

Deneb Legend.pbix (1.4 MB)

Hi @Deston.

Posting to a solved thread can result in a delayed response as many forum members only look at unsolved threads. It is recommended to always begin a new thread for a new question, and if the new issue is partially explained by (or background can be gleaned from) a previous post, that post can be added as a link. For documentation’s sake, and in case its of interest, I’ll respond here.

I don’t think you did anything wrong; there seems to be a conflict in Vega-Lite (or more likely I just don’t know the correct syntax) when there are multiple automatically-generated legends in a composite visual. I played around a bit and was able to use the built-in legend generation, so I deleted the stand-alone legend we originally added, and this is what I got:

I changed your “Color” field values to lowercase so Vega-Lite could recognize them, and added a dedicated scale block to the color block. (Not sure if all these change are needed; once it started working, I didn’t go any further.) I added a labelExpr key-value pair to re-constitute the proper case of the colour.

Greg
eDNA Forum - Deneb Legend.pbix (1.4 MB)

1 Like

Hi @Greg,

Noted re posting on solved thread; and I really appreciate your response.

Unfortunately, this will not satisfy the requirement, and I must take some of the blame here. I was following your advise by building up the JSON code bit by bit, rather than attempt to do everything at once.

The final result must contain all the following elements:

and here’s where I couldn’t get the built-in legend to work.

Whilst I can definitely see the power in the application of this visual, right now I am finding traversing the chasm from standard / basic charts to complicated application a challenge. Hence the previous question around an advanced course in Deneb :slight_smile:

I realize there’s no getting away from building up competency through repetition, but as I am sure you’ve experienced; there’s an urgency from the user to achieve a result.

Thank you once again!