# Dynamic legends and number of decimals

**URL:** <https://quantlab.discourse.group/t/dynamic-legends-and-number-of-decimals/101>\
**Category:** Quantlab Workspaces\
**Created:** [November 7, 2024, 9:23am UTC](https://quantlab.discourse.group/t/dynamic-legends-and-number-of-decimals/101 "2024-11-07T09:23:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![QuantlabAdmin](https://yyz1.discourse-cdn.com/flex003/user_avatar/quantlab.discourse.group/quantlabadmin/32/10_2.png) [@QuantlabAdmin](https://quantlab.discourse.group/u/QuantlabAdmin)\
**Post date:** [November 7, 2024, 9:23am UTC](https://quantlab.discourse.group/t/dynamic-legends-and-number-of-decimals/101/1 "2024-11-07T09:23:57Z")

</div>

We recently got a support email about legends in graphs. Namely, how to get dynamic legends and how to control decimals when presenting numbers.

First let’s look at how to create a dynamic legend. You have two parameter as input. An instrument name and a number of days to display its history.

```auto
out series<date>(number) test(instrument_name in, number days){
	return series(d:today() - days, today(); instrument(in, d, "Mid").quote());
}

```

will give your this graph:

 ![image](https://canada1.discourse-cdn.com/flex003/uploads/quantlab/original/1X/892b7ac9727b7d673ca844d18466e6bda3a19d32.png)

Now, double-click on the graph-line or the legend “test-1”. To open the formatting dialog.

 ![image](https://canada1.discourse-cdn.com/flex003/uploads/quantlab/original/1X/6bb22ce6ef9c8a5e71ca743a7b5d6fb995692469.png)

You can now change the legend by writing free text and include the available parameters included in curly brackets { param } to create a dynamic legend.

To control the number of decimals for the numeric “days” in this example. You can use {0days} to set number of decimals to zero. I.e. an integer before the numeric parameter controls the decimals.
