# XY Chart - adding batch labels

**URL:** <https://forum.inductiveautomation.com/t/xy-chart-adding-batch-labels/78428>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [August 27, 2023, 1:52pm UTC](https://forum.inductiveautomation.com/t/xy-chart-adding-batch-labels/78428 "2023-08-27T13:52:31Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [August 27, 2023, 1:52pm UTC](https://forum.inductiveautomation.com/t/xy-chart-adding-batch-labels/78428/1 "2023-08-27T13:52:31Z")

</div>

I'm migrating some old PHP web pages to Perspective. The original is generated using jqPlot which has the nice feature of being able to add in in the batch sequence numbers shown in green circles on the chart below. The batch sequence number is repeated in a table below the chart. This makes it easy to find the batch's corresponding row in the table.

 ![Weighout batch numbers](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/e/0ef888c75bc12ac9c01469d2dae34c985a792f4a.png)

Can anyone think of a way of achieving a similar result in Perspective's XY Chart?  
I can generate datapoints with X value to match the end of weighout and a constant Y-value of 70 kg.

How could I generate the labels?  
How could I embed the 1, 2, 3, ... batch numbers?

Many thanks.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [August 27, 2023, 7:10pm UTC](https://forum.inductiveautomation.com/t/xy-chart-adding-batch-labels/78428/2 "2023-08-27T19:10:40Z")

</div>

It seems that my best shot is,

- Create a batch-number dataset with (t\_stamp, number) pairs. Number is in sequence 1, 2, 3, etc.
- Create another y-axis. I set the axis range to very large numbers so that the difference in vertical position of my batch numbers is not discernable. In my case I made it `max : 1000` and `min : -10000`. This forces the zero line above the top of my other charts.
- Add another series and set it to line. Bind it to the batch-number dataset.

---

<div class="post-metadata">

**Author:** ![kyler.kamyszek](https://avatars.discourse-cdn.com/v4/letter/k/a4c791/32.png) [@kyler.kamyszek](https://forum.inductiveautomation.com/u/kyler.kamyszek)\
**Post date:** [August 29, 2023, 2:17pm UTC](https://forum.inductiveautomation.com/t/xy-chart-adding-batch-labels/78428/3 "2023-08-29T14:17:14Z")

</div>

It's not exactly what you're asking, but you could use tooltips and bullets on the weight dataset and put the batch number in that datasource.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [August 29, 2023, 9:28pm UTC](https://forum.inductiveautomation.com/t/xy-chart-adding-batch-labels/78428/4 "2023-08-29T21:28:48Z")

</div>

> [@kyler.kamyszek](#):
>
> ... and put the batch number in that datasource.

I don't think one can do that. The tooltips can read `{valueY}` but not other columns in the dataset. I've posted some work on the XY Chart tooltips [here](https://forum.inductiveautomation.com/t/perspective-xy-chart-xaxes-tooltip-text-datex/53580). In any case they don't appear until the user hovers over the point so - no use!

I've added tooltips to the batch number bullets so now I have both.

 ![Mixer batch numbers](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/8/88fa42257c45cd2d4f965a3f69123f7a02be01c2.png)

Now to try and add a circular backfill ...

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [April 22, 2024, 4:23pm UTC](https://forum.inductiveautomation.com/t/xy-chart-adding-batch-labels/78428/5 "2024-04-22T16:23:32Z")

</div>

Hi @Transistor  
I need to create feature similar kind what u did.  
I am going to develop X bar R chart in Perspective

Below image which developed in vision module

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/7/e798f189736efce5bee740fed6710b45ea8070a8.png)

if mean is above UCL limit or below the LCL limit. I need to show the datapoint in red color and label with number  
Can you give me guidance how to achieve this in XY chart perspective

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [April 22, 2024, 4:39pm UTC](https://forum.inductiveautomation.com/t/xy-chart-adding-batch-labels/78428/6 "2024-04-22T16:39:04Z")

</div>

I think your best options are:

- Create the labels as another series as I've described in post #2. You would write a script to only add in the labels for the out-of-band values. If you want labels over the high values and under the low values you will need two series.
- Create yet another series with just the red points. Set that series with  
`series.x.line.appearance.stroke.opacity : 0`  
`series.x.line.appearance.bullets.0.enabled : true`  
`series.x.line.appearance.bullets.0.fill.color : red`  
`series.x.line.appearance.bullets.0.stroke.color : red`

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [April 22, 2024, 5:00pm UTC](https://forum.inductiveautomation.com/t/xy-chart-adding-batch-labels/78428/7 "2024-04-22T17:00:35Z")

</div>

Thanks i will try it out

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [April 22, 2024, 5:03pm UTC](https://forum.inductiveautomation.com/t/xy-chart-adding-batch-labels/78428/8 "2024-04-22T17:03:49Z")

</div>

So from my understanding i need to create 2 dataset with out of bound values through scripting and then create 2 series call the dataset column right?

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [April 22, 2024, 5:11pm UTC](https://forum.inductiveautomation.com/t/xy-chart-adding-batch-labels/78428/9 "2024-04-22T17:11:41Z")

</div>

If your upper and lower deviations are both going to be the same color (red in your sample) then one dataset would do, wouldn't it?

Adding in the labels on those points might require more work.

I haven't used them but the Apex Charts may have some of the features you're looking for.

> [@KyvisLabs ApexChart Module](https://forum.inductiveautomation.com/t/kyvislabs-apexchart-module/55263/18):
>
> Hi everyone! We now have the module as an open source project on Github: Check it out and feel free to contribute. The license is Apache 2.0.

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [April 22, 2024, 5:16pm UTC](https://forum.inductiveautomation.com/t/xy-chart-adding-batch-labels/78428/10 "2024-04-22T17:16:12Z")

</div>

Yes one dataset is enough

But apex chart is third party chart right?

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [April 22, 2024, 5:18pm UTC](https://forum.inductiveautomation.com/t/xy-chart-adding-batch-labels/78428/11 "2024-04-22T17:18:42Z")

</div>

Yes. It is written by KyvisLabs. That is all I know about it.
