# Get sample name on the x-axis of the chart

**URL:** <https://forum.inductiveautomation.com/t/get-sample-name-on-the-x-axis-of-the-chart/73321>\
**Category:** Ignition\
**Tags:** vision, ignition81\
**Created:** [May 5, 2023, 8:51am UTC](https://forum.inductiveautomation.com/t/get-sample-name-on-the-x-axis-of-the-chart/73321 "2023-05-05T08:51:07Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![arpit\_yadav](https://avatars.discourse-cdn.com/v4/letter/a/a5b964/32.png) [@arpit\_yadav](https://forum.inductiveautomation.com/u/arpit_yadav)\
**Post date:** [May 5, 2023, 8:51am UTC](https://forum.inductiveautomation.com/t/get-sample-name-on-the-x-axis-of-the-chart/73321/1 "2023-05-05T08:51:07Z")

</div>

![sample name on x axis](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/a/0ae1090edf4c5e408dcacabfcd266d09cba16ce1.jpeg)  
Hi,  
This the the dataset of my chart I need the sample name on the x axis instead of date

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [May 5, 2023, 8:55am UTC](https://forum.inductiveautomation.com/t/get-sample-name-on-the-x-axis-of-the-chart/73321/2 "2023-05-05T08:55:06Z")

</div>

What kind of chart is this? It looks like you are using an xy plot in the place of a category plot.

---

<div class="post-metadata">

**Author:** ![arpit\_yadav](https://avatars.discourse-cdn.com/v4/letter/a/a5b964/32.png) [@arpit\_yadav](https://forum.inductiveautomation.com/u/arpit_yadav)\
**Post date:** [May 5, 2023, 8:56am UTC](https://forum.inductiveautomation.com/t/get-sample-name-on-the-x-axis-of-the-chart/73321/3 "2023-05-05T08:56:41Z")

</div>

its a simple vision chart yes seems to me I am using a x-y plot.

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [May 5, 2023, 8:57am UTC](https://forum.inductiveautomation.com/t/get-sample-name-on-the-x-axis-of-the-chart/73321/4 "2023-05-05T08:57:37Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/4/64b634120fcdbebc570b43035de134b87f52d974.png)  
Switch the chart type to Category.

---

<div class="post-metadata">

**Author:** ![arpit\_yadav](https://avatars.discourse-cdn.com/v4/letter/a/a5b964/32.png) [@arpit\_yadav](https://forum.inductiveautomation.com/u/arpit_yadav)\
**Post date:** [May 5, 2023, 9:02am UTC](https://forum.inductiveautomation.com/t/get-sample-name-on-the-x-axis-of-the-chart/73321/5 "2023-05-05T09:02:01Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/7/370e099200bf24a6d9a5bdfeac6d0f46c7fe4068.png)  
even after doing this its showing the error.

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [May 5, 2023, 9:02am UTC](https://forum.inductiveautomation.com/t/get-sample-name-on-the-x-axis-of-the-chart/73321/6 "2023-05-05T09:02:39Z")

</div>

How do you want this chart to look?

---

<div class="post-metadata">

**Author:** ![arpit\_yadav](https://avatars.discourse-cdn.com/v4/letter/a/a5b964/32.png) [@arpit\_yadav](https://forum.inductiveautomation.com/u/arpit_yadav)\
**Post date:** [May 5, 2023, 9:03am UTC](https://forum.inductiveautomation.com/t/get-sample-name-on-the-x-axis-of-the-chart/73321/7 "2023-05-05T09:03:47Z")

</div>

I want sample name to be displayed on x axis instead of date

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [May 5, 2023, 9:09am UTC](https://forum.inductiveautomation.com/t/get-sample-name-on-the-x-axis-of-the-chart/73321/8 "2023-05-05T09:09:21Z")

</div>

I understand that; have you tried the "Bar Chart" component? The classic chart component is going to try to give you either a date driven domain or a pie chart. Other things are possible using scripting and the configureChart extension function, but it isn't clear to me how you want the data displayed above the names. I don't see any dates or other potential domain axis values in your dataset

---

<div class="post-metadata">

**Author:** ![arpit\_yadav](https://avatars.discourse-cdn.com/v4/letter/a/a5b964/32.png) [@arpit\_yadav](https://forum.inductiveautomation.com/u/arpit_yadav)\
**Post date:** [May 5, 2023, 9:13am UTC](https://forum.inductiveautomation.com/t/get-sample-name-on-the-x-axis-of-the-chart/73321/9 "2023-05-05T09:13:01Z")

</div>

we can use date time for filtration but don't want them to be displayed on the chart like if their any mean to do that.

---

<div class="post-metadata">

**Author:** ![arpit\_yadav](https://avatars.discourse-cdn.com/v4/letter/a/a5b964/32.png) [@arpit\_yadav](https://forum.inductiveautomation.com/u/arpit_yadav)\
**Post date:** [May 5, 2023, 9:15am UTC](https://forum.inductiveautomation.com/t/get-sample-name-on-the-x-axis-of-the-chart/73321/10 "2023-05-05T09:15:20Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/5/051d867b74d103da2e789731f8b1f2e33a262845.png)  
lets consider this as dataset then their any mean to do that

---

<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:** [May 5, 2023, 12:44pm UTC](https://forum.inductiveautomation.com/t/get-sample-name-on-the-x-axis-of-the-chart/73321/11 "2023-05-05T12:44:38Z")

</div>

> [@arpit\_yadav](#):
>
> its showing the error.

Follow its instruction. Change the renderer to Category after changing the chart type to category.

Also, you probably need to get rid of the empty rows in your dataset.

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [May 5, 2023, 2:02pm UTC](https://forum.inductiveautomation.com/t/get-sample-name-on-the-x-axis-of-the-chart/73321/12 "2023-05-05T14:02:35Z")

</div>

> [@pturmel](#):
>
> Change the renderer to Category after changing the chart type to category

I'm going to have ask for help, because for some reason, I'm struggling on this one.  
I can set the data up like this:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/b/0b59e1533c18dec0462aee353842f2b9feef226f.png)  
...and then create the entire chart from scratch using this button script:

```auto
from org.jfree.data.category import DefaultCategoryDataset
from org.jfree.chart import ChartFactory
from org.jfree.chart.plot import PlotOrientation
from org.jfree.chart.renderer.category import LineAndShapeRenderer
chartComponent = event.source.parent.getComponent('Chart')
chart = chartComponent.chart
chartData = chartComponent.Data
catagoryDataset = DefaultCategoryDataset()
for row in range(chartData.rowCount):
	rowData = [chartData.getValueAt(row, column) for column in range(chartData.columnCount)]
	catagoryDataset.addValue(rowData[0], rowData[1], rowData[2])
lineChart = ChartFactory.createLineChart(
	'Sample Values',
	'Samples',
	'Value',
	catagoryDataset,
	PlotOrientation.VERTICAL,
	False,
	False,
	False
)
renderer = LineAndShapeRenderer(True, True)
lineChart.plot.setRenderer(renderer)
chartComponent.chart = lineChart

```

...and of course, I get the desired result:

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

...but obviously, this is not the "correct" way, and so far, I haven't found the correct settings in the chart customizer to get this to happen automatically.

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [May 5, 2023, 2:11pm UTC](https://forum.inductiveautomation.com/t/get-sample-name-on-the-x-axis-of-the-chart/73321/13 "2023-05-05T14:11:45Z")

</div>

@arpit_yadav  
Happy Cake Day by the way:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/2/826700d0368010f75dd92d1194a189d74385d038.png)

---

<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:** [May 5, 2023, 2:34pm UTC](https://forum.inductiveautomation.com/t/get-sample-name-on-the-x-axis-of-the-chart/73321/14 "2023-05-05T14:34:18Z")

</div>

> [@justinedwards.jle](#):
>
> found the correct settings

In the Axes tab.

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [May 5, 2023, 2:47pm UTC](https://forum.inductiveautomation.com/t/get-sample-name-on-the-x-axis-of-the-chart/73321/15 "2023-05-05T14:47:08Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/f/6f9398c8433a407e7d8d4c0b3dc7fc7a1587f35e.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/f/0f93ccfd8241b378d249f6bf703a477715db8695.png)

lol

---

<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:** [May 5, 2023, 3:22pm UTC](https://forum.inductiveautomation.com/t/get-sample-name-on-the-x-axis-of-the-chart/73321/16 "2023-05-05T15:22:20Z")

</div>

Oof, that's embarrassing. Those icons are also awful... I'll get a ticket going.

---

<div class="post-metadata">

**Author:** ![arpit\_yadav](https://avatars.discourse-cdn.com/v4/letter/a/a5b964/32.png) [@arpit\_yadav](https://forum.inductiveautomation.com/u/arpit_yadav)\
**Post date:** [May 10, 2023, 6:53am UTC](https://forum.inductiveautomation.com/t/get-sample-name-on-the-x-axis-of-the-chart/73321/17 "2023-05-10T06:53:19Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/7/d729d37dc4c67ac41b5fdc2c24e0f0e4c69b6a8e.png)  
can we also plot this dataset like can we configure a multiline chart.

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [May 10, 2023, 2:51pm UTC](https://forum.inductiveautomation.com/t/get-sample-name-on-the-x-axis-of-the-chart/73321/18 "2023-05-10T14:51:42Z")

</div>

> [@arpit\_yadav](#):
>
> configure a multiline chart.

To configure a multi line chat, you will need one column that specifies series, so each line will have it's own unique series name that is used to differentiate the data points.
