# Perspective xychart

**URL:** <https://forum.inductiveautomation.com/t/perspective-xychart/76770>\
**Category:** General Discussion\
**Tags:** perspective, ignition81\
**Created:** [July 24, 2023, 9:51am UTC](https://forum.inductiveautomation.com/t/perspective-xychart/76770 "2023-07-24T09:51:32Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![GOKULAKANNAN\_P](https://avatars.discourse-cdn.com/v4/letter/g/0ea827/32.png) [@GOKULAKANNAN\_P](https://forum.inductiveautomation.com/u/GOKULAKANNAN_P)\
**Post date:** [July 24, 2023, 9:51am UTC](https://forum.inductiveautomation.com/t/perspective-xychart/76770/1 "2023-07-24T09:51:32Z")

</div>

Hello,

I have using XY Chart for show line running status

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/0/408744b4a44c101d042765e178b12560ecba4c63.png)

for the data i have binded the dataset tag. It contains starttime,endtime and some more columns.Then i have added "Add Transform" script for convert dataset to json. Then the endtime of the last row of dataset should be show current time. so, i have put script for same in "Add Transform" script.

now , my problem is:

- when i added the new row in dataset the chart shows empty. but the output json changed with recent data in props.datasource.example property.

- Then the endtime of the last row is changed to current time when the propery binding is works. but i need the last row of end time should be always current time.

Any One Have A Idea Please Provide.

Thanks in advance!.

---

<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:** [July 24, 2023, 10:02am UTC](https://forum.inductiveautomation.com/t/perspective-xychart/76770/2 "2023-07-24T10:02:01Z")

</div>

Please show a sample of your data and your transform code. (Paste as text and use the "Preformatted text" button in the forum editor to style it as code.)

---

<div class="post-metadata">

**Author:** ![GOKULAKANNAN\_P](https://avatars.discourse-cdn.com/v4/letter/g/0ea827/32.png) [@GOKULAKANNAN\_P](https://forum.inductiveautomation.com/u/GOKULAKANNAN_P)\
**Post date:** [July 24, 2023, 10:09am UTC](https://forum.inductiveautomation.com/t/perspective-xychart/76770/3 "2023-07-24T10:09:43Z")

</div>

This the Dataset i have binded:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/8/2888bd0ed37e64d487ceaa5d5a35267f2b303693.png):

script:

```auto
	num_rows = value.getRowCount()
	
	if num_rows > 0:
	
		# Get the last row index (0-based)
		last_row_index = num_rows - 1
		
		# Get the current date and time
		current_datetime = system.date.now()
		
		# Update the 'endtime' of the last row with the current date and time
		dataset = system.dataset.setValue(value, last_row_index, "end_time", current_datetime)
		row_count = dataset.getRowCount()
		result = []
		
		for x in range(row_count):
			event_id = dataset.getValueAt(x,0)
			reason = dataset.getValueAt(x,5)
			run_status = dataset.getValueAt(x,7)
			start_milli = system.date.format(dataset.getValueAt(x,1),'yyyy-MM-dd HH:mm:ss')
			end_milli = system.date.format(dataset.getValueAt(x,2),'yyyy-MM-dd HH:mm:ss')
			
			if run_status == 1:
				color = '#8aff8a'
			elif run_status == 0 and reason == '':
				color = '#808080'
			elif run_status == 0 and reason == 'reason1':
				color = '#0b84a5'
			elif run_status == 0 and reason == 'reson2':
				color = '#ffa056'
			elif run_status == 0 and reason == 'reason3':
				color = '#8dddd0'
	
			result.append({
				"color": color,
				"fromDate": start_milli,
				"name" : "",
				"toDate" : end_milli,
				"event_id" : event_id
				})
		return result

```

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/e/8e36a9c3fbad333cebc3ca7d796e5cc567a0a207.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:** [July 24, 2023, 10:17am UTC](https://forum.inductiveautomation.com/t/perspective-xychart/76770/4 "2023-07-24T10:17:20Z")

</div>

You are turning your datetime objects into strings. Don't do that. Just pass them through directly from the dataset. (They will become 64-bit integer milliseconds in the json.)

---

<div class="post-metadata">

**Author:** ![GOKULAKANNAN\_P](https://avatars.discourse-cdn.com/v4/letter/g/0ea827/32.png) [@GOKULAKANNAN\_P](https://forum.inductiveautomation.com/u/GOKULAKANNAN_P)\
**Post date:** [July 24, 2023, 10:43am UTC](https://forum.inductiveautomation.com/t/perspective-xychart/76770/5 "2023-07-24T10:43:15Z")

</div>

Hello @pturmel ,

It is working!. But the tooltip shows only date format

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/6/d66cdc6571ea1cd6bb41ca5c731361ebe47d99a2.png)

i need HH:mm:ss (at least HH:mm)

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/a/8ae64c019be8292396fd8a604b9c4b4863076a0b.png)

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

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [July 24, 2023, 11:08am UTC](https://forum.inductiveautomation.com/t/perspective-xychart/76770/6 "2023-07-24T11:08:16Z")

</div>

> [@GOKULAKANNAN\_P](#):
>
> `'reson2'`

btw careful for typo

---

<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:** [July 24, 2023, 11:21am UTC](https://forum.inductiveautomation.com/t/perspective-xychart/76770/7 "2023-07-24T11:21:19Z")

</div>

Try setting `xAxes.date.break.format`.

From here:

[https://docs.inductiveautomation.com/display/DOC81/Perspective+-+XY+Chart#PerspectiveXYChart-Properties](https://docs.inductiveautomation.com/display/DOC81/Perspective+-+XY+Chart#PerspectiveXYChart-Properties)

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [July 24, 2023, 11:25am UTC](https://forum.inductiveautomation.com/t/perspective-xychart/76770/8 "2023-07-24T11:25:09Z")

</div>

this topic has a bunch of examples of formats

> [@Perspective XY Chart xAxes tooltip text {dateX}](https://forum.inductiveautomation.com/t/perspective-xy-chart-xaxes-tooltip-text-datex/53580/9):
>
> Further examples: Count: [bold]{valueY}[/] Time: [bold]{dateX.formatDate('HH:mm')}[/] {dateX.formatDate('yyyy-MMM-dd')} {dateX.formatDate('EEE')} This is specified in props.series.0.line.appearance.bullets.0.tooltip.text, etc. See the AM Charts [Formatting date and time](https://www.amcharts.com/docs/v4/concepts/formatters/formatting-date-time/) for more details.

---

<div class="post-metadata">

**Author:** ![GOKULAKANNAN\_P](https://avatars.discourse-cdn.com/v4/letter/g/0ea827/32.png) [@GOKULAKANNAN\_P](https://forum.inductiveautomation.com/u/GOKULAKANNAN_P)\
**Post date:** [July 24, 2023, 11:51am UTC](https://forum.inductiveautomation.com/t/perspective-xychart/76770/9 "2023-07-24T11:51:13Z")

</div>

@pturmel

it is not working . already the format is with HH:mm

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

---

<div class="post-metadata">

**Author:** ![GOKULAKANNAN\_P](https://avatars.discourse-cdn.com/v4/letter/g/0ea827/32.png) [@GOKULAKANNAN\_P](https://forum.inductiveautomation.com/u/GOKULAKANNAN_P)\
**Post date:** [July 24, 2023, 11:54am UTC](https://forum.inductiveautomation.com/t/perspective-xychart/76770/10 "2023-07-24T11:54:22Z")

</div>

Thankyou!. @victordcq

it is working.

thank you @pturmel for your quick response.

can you both give solution/idea for the my 2 nd point?

- Then the endtime of the last row is changed to current time when the propery binding is works. but i need the last row of end time should be always current time.

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [July 24, 2023, 12:13pm UTC](https://forum.inductiveautomation.com/t/perspective-xychart/76770/11 "2023-07-24T12:13:01Z")

</div>

you could do the forming of this data in a seperate custom property and then do a structered binding to this custom prop and on a now(5000) (best choose a delay) which only changes the last value.

i wouldnt do it in the same script else you will have to loop through all the data every second(or whatever you delay is)

anyway for just a small delay this seems like a very render expensive thing to do... i wouldnt do it
