# Help with Chart Component

**URL:** <https://forum.inductiveautomation.com/t/help-with-chart-component/4325>\
**Category:** Ignition\
**Created:** [April 20, 2012, 1:08am UTC](https://forum.inductiveautomation.com/t/help-with-chart-component/4325 "2012-04-20T01:08:53Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![0sm0](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/0sm0/32/15228_2.png) [@0sm0](https://forum.inductiveautomation.com/u/0sm0)\
**Post date:** [April 20, 2012, 1:08am UTC](https://forum.inductiveautomation.com/t/help-with-chart-component/4325/1 "2012-04-20T01:08:53Z")

</div>

Hi Guys,

I have been given a MSQL Database Table that has been populated with 3 columns.  
Column 1 has a Date, this has been set as a MSQL “Date” datatype.  
Column 2 has a Time, this has been set as a MSQL “Time” datatype  
Column 3 has intergers

I have tried to display the Data (Col 1 and col 3 only) in a Chart component but the Date as the X plot errors as an unknown value for X plot.

I tried to cast the “Date” to a datetime in the Data query which stops the error but fails to draw anything. The Dataset date column shows as 01/04/2012 00:00:00

If I remove the binding and manually manipulate the dataset Date to have an actual time eg. 01/04/2012 01:00:00 the chart works.

So getting to the question…

Is there a way to combine columns 1 and 2 to make a proper Datetime for the chart in a query or can I format just the Date (col 1) in a way that the chart likes?

Cheers for any help.

Tim…

---

<div class="post-metadata">

**Author:** ![techerdone](https://avatars.discourse-cdn.com/v4/letter/t/9fc348/32.png) [@techerdone](https://forum.inductiveautomation.com/u/techerdone)\
**Post date:** [April 23, 2012, 6:54pm UTC](https://forum.inductiveautomation.com/t/help-with-chart-component/4325/2 "2012-04-23T18:54:09Z")

</div>

When you cast the date column are you using the built in function system.db.dateFormat(date\_cell,“yyyy-MM-dd HH:mm:ss”) ? Or are you casting with your SQL call?  
I haven’t had any problems using dates that have “no actual time” like your ‘01/04/2012 00:00:00’.

---

<div class="post-metadata">

**Author:** ![techerdone](https://avatars.discourse-cdn.com/v4/letter/t/9fc348/32.png) [@techerdone](https://forum.inductiveautomation.com/u/techerdone)\
**Post date:** [April 23, 2012, 6:57pm UTC](https://forum.inductiveautomation.com/t/help-with-chart-component/4325/3 "2012-04-23T18:57:42Z")

</div>

Just saw that you did the casting it in your date query. Can you iterate through the list and do it in a script instead with the function I mentioned above?

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [April 23, 2012, 11:41pm UTC](https://forum.inductiveautomation.com/t/help-with-chart-component/4325/4 "2012-04-23T23:41:22Z")

</div>

Can you post the SQL query that you are using?

---

<div class="post-metadata">

**Author:** ![0sm0](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/0sm0/32/15228_2.png) [@0sm0](https://forum.inductiveautomation.com/u/0sm0)\
**Post date:** [April 23, 2012, 11:52pm UTC](https://forum.inductiveautomation.com/t/help-with-chart-component/4325/5 "2012-04-23T23:52:12Z")

</div>

[Log Date] is a “Date” datatype in MSQL  
Using this query the Chart errors with" Illegal type for X value"  
SELECT [Log Date] as t\_stamp, [TR#1 Today permeate (kL)] FROM datalogA

This Query has no errors, but fails to display  
SELECT cast([Log Date] as datetime) as t\_stamp, [TR#1 Today permeate (kL)] FROM datalogA

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [April 23, 2012, 11:57pm UTC](https://forum.inductiveautomation.com/t/help-with-chart-component/4325/6 "2012-04-23T23:57:39Z")

</div>

I have a feeling it is not returning an actual date object. Click on the dataset view icon (next to the binding icon) on the Data property of the component. Once opened, click on the date column and tell me what the data type? You will see it below the table.

---

<div class="post-metadata">

**Author:** ![0sm0](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/0sm0/32/15228_2.png) [@0sm0](https://forum.inductiveautomation.com/u/0sm0)\
**Post date:** [April 24, 2012, 12:00am UTC](https://forum.inductiveautomation.com/t/help-with-chart-component/4325/7 "2012-04-24T00:00:25Z")

</div>

ahhhhh…

You are correct, its still showing as a Date type??

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [April 24, 2012, 12:08am UTC](https://forum.inductiveautomation.com/t/help-with-chart-component/4325/8 "2012-04-24T00:08:48Z")

</div>

Date is correct. It should be working ok. Let’s check a couple of things:

1. What is the value of the Chart Type property on the graph?
2. If you open the chart customizer (through right click) and select the Dataset Properties tab what is the Renderer for your dataset?

---

<div class="post-metadata">

**Author:** ![0sm0](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/0sm0/32/15228_2.png) [@0sm0](https://forum.inductiveautomation.com/u/0sm0)\
**Post date:** [April 24, 2012, 12:51am UTC](https://forum.inductiveautomation.com/t/help-with-chart-component/4325/9 "2012-04-24T00:51:15Z")

</div>

1/ Default. XY Plot  
2/ Default. XY Line/Shape renderer

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [April 24, 2012, 2:42pm UTC](https://forum.inductiveautomation.com/t/help-with-chart-component/4325/10 "2012-04-24T14:42:36Z")

</div>

Can you export a copy of the window with the error on it so we can see what is going on?

---

<div class="post-metadata">

**Author:** ![0sm0](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/0sm0/32/15228_2.png) [@0sm0](https://forum.inductiveautomation.com/u/0sm0)\
**Post date:** [April 25, 2012, 2:24am UTC](https://forum.inductiveautomation.com/t/help-with-chart-component/4325/11 "2012-04-25T02:24:06Z")

</div>

Doc attached with the chart setup.

No errors just a blank chart.

The error I was finding with just using the [Log Date] without casting it as a datetime was that the Dataset column was being shown as a string even though the SQL column is a Date type.  
[Doc1.doc](https://us1.discourse-cdn.com/inductiveautomation/original/2X/6/605d7cb22825a15a84ae87a2f422bd6952118231.doc) (123 KB)

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [April 25, 2012, 3:30pm UTC](https://forum.inductiveautomation.com/t/help-with-chart-component/4325/12 "2012-04-25T15:30:10Z")

</div>

It appears you have it setup correctly but for some reason the data is not showing up. Can you post a couple more screenshots from the chart customizer? One of the X-Axes tab with the axis selected and one of the of the Dataset Properties tab with the Data selected.

---

<div class="post-metadata">

**Author:** ![0sm0](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/0sm0/32/15228_2.png) [@0sm0](https://forum.inductiveautomation.com/u/0sm0)\
**Post date:** [April 25, 2012, 9:33pm UTC](https://forum.inductiveautomation.com/t/help-with-chart-component/4325/13 "2012-04-25T21:33:27Z")

</div>

Screenshots attached

Cheers  
[Doc2.doc](https://us1.discourse-cdn.com/inductiveautomation/original/2X/5/5388cb29b6afdd7c4513658290523a43618e6f2f.doc) (99.5 KB)

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [April 25, 2012, 11:38pm UTC](https://forum.inductiveautomation.com/t/help-with-chart-component/4325/14 "2012-04-25T23:38:03Z")

</div>

Ok, I don’t know why the data is not showing up. Everything looks like it is configured correctly. Any chance you can call our tech support or export that window in the designer and send it to us (not screenshots but the actual window)?

---

<div class="post-metadata">

**Author:** ![0sm0](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/0sm0/32/15228_2.png) [@0sm0](https://forum.inductiveautomation.com/u/0sm0)\
**Post date:** [April 25, 2012, 11:44pm UTC](https://forum.inductiveautomation.com/t/help-with-chart-component/4325/15 "2012-04-25T23:44:16Z")

</div>

Window Export attached

Cheers  
[Overview\_2012-04-26\_0912\_partial.proj](https://us1.discourse-cdn.com/inductiveautomation/original/2X/c/c8dfacc4acb1a3a2be375198a05c58fbf9e2f265.proj) (46.5 KB)

---

<div class="post-metadata">

**Author:** ![0sm0](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/0sm0/32/15228_2.png) [@0sm0](https://forum.inductiveautomation.com/u/0sm0)\
**Post date:** [April 26, 2012, 12:01am UTC](https://forum.inductiveautomation.com/t/help-with-chart-component/4325/16 "2012-04-26T00:01:10Z")

</div>

I just did a couple of tests.

I tried setting the “Order by t\_stamp ASC” and found that it errored until I removed a NULL row from the first line.

Looking through the data they have given me it appears that there are a couple of dates out of place… So without sorting by ascending it shows a blank chart.

thanks for your help… I guess it pays to fully check the data your given…

Cheers

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [April 26, 2012, 12:06am UTC](https://forum.inductiveautomation.com/t/help-with-chart-component/4325/17 "2012-04-26T00:06:42Z")

</div>

No problem I am glad you got it working. The order does get you. It needs to be in ascending order.
