# Illegal type for X value: class java.lang.String (column 'Date')

**URL:** <https://forum.inductiveautomation.com/t/illegal-type-for-x-value-class-java-lang-string-column-date/20124>\
**Category:** Ignition\
**Tags:** scripting, ignition79\
**Created:** [October 12, 2018, 2:52pm UTC](https://forum.inductiveautomation.com/t/illegal-type-for-x-value-class-java-lang-string-column-date/20124 "2018-10-12T14:52:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![agweb.salinas](https://avatars.discourse-cdn.com/v4/letter/a/3ec8ea/32.png) [@agweb.salinas](https://forum.inductiveautomation.com/u/agweb.salinas)\
**Post date:** [October 12, 2018, 2:52pm UTC](https://forum.inductiveautomation.com/t/illegal-type-for-x-value-class-java-lang-string-column-date/20124/1 "2018-10-12T14:52:34Z")

</div>

Hi all,

I’m trying to get a chart to graph my data that is stored inside a memory tag. I think there are differences between my values and what it wants as a date format. I tried using the chart Chart Customizer to change the X-axis to a symbol axis with no luck. Is there any way I can bypass the date format to graph my dates inside Ignition?

Here is a picture of the error ignition is throwing and what the format of my memory tag looks like.  
 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/e/eefa0633d3b6a4b23f0bf61692404cc50caab61d.PNG)

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/b/b4154c6e56ca04d6f045d86c053271e81ca6c638.PNG)

---

<div class="post-metadata">

**Author:** ![DavidWisely](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/davidwisely/32/10482_2.png) [@DavidWisely](https://forum.inductiveautomation.com/u/DavidWisely)\
**Post date:** [October 13, 2018, 12:41pm UTC](https://forum.inductiveautomation.com/t/illegal-type-for-x-value-class-java-lang-string-column-date/20124/2 "2018-10-13T12:41:26Z")

</div>

You could use this code in a propertyChange script to convert your string to a date:

```auto
from java.text import SimpleDateFormat

# set the format of the date string
format = SimpleDateFormat("MM/dd/yyyy")

# get the raw data
ds = event.source.parent.RawData # This is your memory tag in a CustomProperty
ds2 = system.dataset.toPyDataSet(ds)

newRows = []
if len(ds2) > 0:
	# convert each row
	for row in ds2:
		dateStamp = format.parse(row[0])
		newRows.append([dateStamp, row[1]])
		
# create the new dataset
headers = ['Date', 'Value']
newDS = system.dataset.toDataSet(headers, newRows)

# write it to the Chart
event.source.parent.getComponent('Chart').Data = newDS

```

---

<div class="post-metadata">

**Author:** ![agweb.salinas](https://avatars.discourse-cdn.com/v4/letter/a/3ec8ea/32.png) [@agweb.salinas](https://forum.inductiveautomation.com/u/agweb.salinas)\
**Post date:** [October 13, 2018, 3:12pm UTC](https://forum.inductiveautomation.com/t/illegal-type-for-x-value-class-java-lang-string-column-date/20124/3 "2018-10-13T15:12:58Z")

</div>

Thanks @DavidWisely this is very helpful.

I do have a quick question on line 7

> [@DavidWisely](#):
>
> ds = event.source.parent.RawData # This is your memory tag in a CustomProperty

I'm a little confused about the path to get to the memory tags dataset. Woulld something like this work?

```auto
ds = event.system.tag.read("tagPath").value

```

Also to build on my first question, where is the best place to place this code? Under a Button property change event? Under the chart property event? Or is there a better place?

---

<div class="post-metadata">

**Author:** ![agweb.salinas](https://avatars.discourse-cdn.com/v4/letter/a/3ec8ea/32.png) [@agweb.salinas](https://forum.inductiveautomation.com/u/agweb.salinas)\
**Post date:** [October 13, 2018, 8:01pm UTC](https://forum.inductiveautomation.com/t/illegal-type-for-x-value-class-java-lang-string-column-date/20124/4 "2018-10-13T20:01:03Z")

</div>

So I have made a little more progress on this problem. I placed David’s code under a button and replaced line 7 with  
`ds = system.tag.read("tagPath").value`  
This seemed to get rid the “Illegal type for X value” error but threw a new error “Illegal type for Y value”. I figured this is the same string problem the X value had before being parsed.

I figured i’d try repeating the same parsing process as done with SimpleDateFormat using NumberFormat but unfortunately I’m not to familiar with Java Script.

---

<div class="post-metadata">

**Author:** ![DavidWisely](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/davidwisely/32/10482_2.png) [@DavidWisely](https://forum.inductiveautomation.com/u/DavidWisely)\
**Post date:** [October 14, 2018, 5:31am UTC](https://forum.inductiveautomation.com/t/illegal-type-for-x-value-class-java-lang-string-column-date/20124/5 "2018-10-14T05:31:30Z")

</div>

Hi Agweb,

As always, there are a few ways to do it, this is just one:

Add a Custom Property of type Dataset to the root container. Call it GrowingDays, and bind it to your GrowingDays tag:  
 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/2/2553a8b09d1ad84f5cf29cf34abd2331336d1a9b.png)

On the root container, add a propertyChange script:

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/8/845b34321575cfb90e0a10bcb3cfd3f3c53967f4.png)

Now, every time the GrowingDays tag changes, it will update the data on the chart with the reformatted dataset!

With your second error, it sounds like you the column ‘GDD’ is of type ‘String’ and you need to convert it to type ‘integer’, I’ve added this to the script above.

Note: It would be better to make sure your data types are correct when your original dataset is created. This is really just a work around so it will work with the chart.

---

<div class="post-metadata">

**Author:** ![agweb.salinas](https://avatars.discourse-cdn.com/v4/letter/a/3ec8ea/32.png) [@agweb.salinas](https://forum.inductiveautomation.com/u/agweb.salinas)\
**Post date:** [October 14, 2018, 8:28pm UTC](https://forum.inductiveautomation.com/t/illegal-type-for-x-value-class-java-lang-string-column-date/20124/6 "2018-10-14T20:28:07Z")

</div>

Ah I see. int() doesnt work alone because I have whole numbers but I just used int(float()).  
I did it a little different under a button but this solution works.

```auto
from java.text import SimpleDateFormat

# set the format of the date string
format = SimpleDateFormat("MM/dd/yyyy")

# get the raw data
ds = system.tag.read("Growing Days").value # This is your memory tag in a CustomProperty
ds2 = system.dataset.toPyDataSet(ds)

newRows = []
if len(ds2) > 0:
	# convert each row
	for row in ds2:
		dateStamp = format.parse(row[0])
		newRows.append([dateStamp, int(float(row[1])), int(float(row[2]))])
		
# create the new dataset
headers = ['Date', 'Growing Degree Days', 'Harvest Line']
newDS = system.dataset.toDataSet(headers, newRows)

# write it to the Chart
event.source.parent.getComponent('Chart').Data = newDS

```

Thanks for the help!
