# Insert a calculated value into a classic chart

**URL:** <https://forum.inductiveautomation.com/t/insert-a-calculated-value-into-a-classic-chart/45891>\
**Category:** Ignition\
**Created:** [April 21, 2021, 9:17pm UTC](https://forum.inductiveautomation.com/t/insert-a-calculated-value-into-a-classic-chart/45891 "2021-04-21T21:17:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![christopher.berg](https://avatars.discourse-cdn.com/v4/letter/c/67e7ee/32.png) [@christopher.berg](https://forum.inductiveautomation.com/u/christopher.berg)\
**Post date:** [April 21, 2021, 9:17pm UTC](https://forum.inductiveautomation.com/t/insert-a-calculated-value-into-a-classic-chart/45891/1 "2021-04-21T21:17:34Z")

</div>

I’m trying to overlay a couple of different SQL query results into a classic chart and I’m not having any luck. I’ve got several hundred data points that I’m getting from an SQL query. The results display fine on the chart. I have a separate query that I’m using to calculate the average and standard deviation of those points. I’d like to plot those data points AND display the average as a line on the chart but the chart seems to be hung up on the average query not having a time value in the first column. The second dataset with the average causes an invalid chart configuration error. Does anyone have any idea how I can insert that average among the plotted data points?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 21, 2021, 10:33pm UTC](https://forum.inductiveautomation.com/t/insert-a-calculated-value-into-a-classic-chart/45891/2 "2021-04-21T22:33:50Z")

</div>

You’ll need to use a range marker. There’s a number of posts here on the forum describing it.

The classic chart only allows custom properties that are datasets that comply with the requirements of the chart mode chosen. If you are providing an x-axis in one dataset, any other dataset will need an x-axis, too.

---

<div class="post-metadata">

**Author:** ![christopher.berg](https://avatars.discourse-cdn.com/v4/letter/c/67e7ee/32.png) [@christopher.berg](https://forum.inductiveautomation.com/u/christopher.berg)\
**Post date:** [April 26, 2021, 9:52pm UTC](https://forum.inductiveautomation.com/t/insert-a-calculated-value-into-a-classic-chart/45891/3 "2021-04-26T21:52:12Z")

</div>

It took some fiddling but that worked. Thanks!

One more question for you: is there a quick way to add those range markers to the chart legend?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 26, 2021, 10:20pm UTC](https://forum.inductiveautomation.com/t/insert-a-calculated-value-into-a-classic-chart/45891/4 "2021-04-26T22:20:14Z")

</div>

Not off the top of my head, no.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [April 26, 2021, 11:06pm UTC](https://forum.inductiveautomation.com/t/insert-a-calculated-value-into-a-classic-chart/45891/5 "2021-04-26T23:06:25Z")

</div>

Customizing the legend is non-trivial:

> [@Dynamic report chart, legend not hiding unused pens](http://forum.inductiveautomation.com/t/dynamic-report-chart-legend-not-hiding-unused-pens/44565/2):
>
> Take a look at this other post of mine about changing the legend: The trick is to implement a ‘custom’ [XYItemRenderer](https://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/renderer/xy/XYItemRenderer.html) class that allows you to provide your own arbitrary set of legend items to display.
