# Apex line chart not updating

**URL:** <https://forum.inductiveautomation.com/t/apex-line-chart-not-updating/78941>\
**Category:** 3rd Party Modules\
**Tags:** scripting, perspective\
**Created:** [September 9, 2023, 2:30pm UTC](https://forum.inductiveautomation.com/t/apex-line-chart-not-updating/78941 "2023-09-09T14:30:41Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Morgan1](https://avatars.discourse-cdn.com/v4/letter/j/22d042/32.png) [@John\_Morgan1](https://forum.inductiveautomation.com/u/John_Morgan1)\
**Post date:** [September 9, 2023, 2:30pm UTC](https://forum.inductiveautomation.com/t/apex-line-chart-not-updating/78941/1 "2023-09-09T14:30:41Z")

</div>

Hi folks,

I am using Apex charts to show data on a line graph and can be updated in real time mode  
I am getting data through the named query "Tank1" with no parameters

I have used 2 scripts to gather the last 8 values as integers and it worked but unfortunately it doesn't update as the value changes

It works but unfortunately it doesn't update automatically but when I open the binding and press apply the data is updated but it doesn't update on itself

Below the first transform snippet and a screenshot for the binding

```auto
		Data = system.db.runNamedQuery("Galvenize/Tank1" )
		pyData = system.dataset.toPyDataSet(Data)
		

		newList = []
		 
		# step through the rows
		for row in pyData:
		    # create a new blank dictionary for each row of the data
		    newDict = {}
		    for i in range(len(row)):
		        newDict = row[i]
		     
		    newList.append(newDict)
		    
		    # Limit the results to last 5
		    value = newList[-8:]
		     
		return value

```

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/4/143a6356e982e76e334a14e00f3245aa6d291e53.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:** [September 9, 2023, 2:47pm UTC](https://forum.inductiveautomation.com/t/apex-line-chart-not-updating/78941/2 "2023-09-09T14:47:21Z")

</div>

Bindings update when instantiated (startup), and thereafter when a tag or property they use updates. You are configuring a property binding but have not selected a property to follow. Ergo, no updates.

Consider using a query binding to run your named query, and use the polling option to run it repeatedly. Then your transform will be handed a `{value}` that is the result dataset--you won't need `system.db.runNamedQuery()` in the script.

---

<div class="post-metadata">

**Author:** ![John\_Morgan1](https://avatars.discourse-cdn.com/v4/letter/j/22d042/32.png) [@John\_Morgan1](https://forum.inductiveautomation.com/u/John_Morgan1)\
**Post date:** [September 9, 2023, 6:31pm UTC](https://forum.inductiveautomation.com/t/apex-line-chart-not-updating/78941/3 "2023-09-09T18:31:36Z")

</div>

It worked  
Thanks a lot. really appreciate it

---

<div class="post-metadata">

**Author:** ![John\_Morgan1](https://avatars.discourse-cdn.com/v4/letter/j/22d042/32.png) [@John\_Morgan1](https://forum.inductiveautomation.com/u/John_Morgan1)\
**Post date:** [September 9, 2023, 8:47pm UTC](https://forum.inductiveautomation.com/t/apex-line-chart-not-updating/78941/4 "2023-09-09T20:47:44Z")

</div>

Do you have any Idea how to make the old real time data just disappear without changing the whole graph

---

<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:** [September 10, 2023, 1:31am UTC](https://forum.inductiveautomation.com/t/apex-line-chart-not-updating/78941/5 "2023-09-10T01:31:09Z")

</div>

Not sure what you mean.

---

<div class="post-metadata">

**Author:** ![John\_Morgan1](https://avatars.discourse-cdn.com/v4/letter/j/22d042/32.png) [@John\_Morgan1](https://forum.inductiveautomation.com/u/John_Morgan1)\
**Post date:** [September 10, 2023, 4:52am UTC](https://forum.inductiveautomation.com/t/apex-line-chart-not-updating/78941/6 "2023-09-10T04:52:27Z")

</div>

[https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/5/e5f8d3e0b53bd1bec602b7b30ead417896b741fc.mp4](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/5/e5f8d3e0b53bd1bec602b7b30ead417896b741fc.mp4)

---

<div class="post-metadata">

**Author:** ![John\_Morgan1](https://avatars.discourse-cdn.com/v4/letter/j/22d042/32.png) [@John\_Morgan1](https://forum.inductiveautomation.com/u/John_Morgan1)\
**Post date:** [September 10, 2023, 4:54am UTC](https://forum.inductiveautomation.com/t/apex-line-chart-not-updating/78941/7 "2023-09-10T04:54:35Z")

</div>

The whole chart changes like in the video. If there is a method to make the old values just disappear without changing the graph. This will give much nicer graph

---

<div class="post-metadata">

**Author:** ![bmusson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmusson/32/87530_2.png) [@bmusson](https://forum.inductiveautomation.com/u/bmusson)\
**Post date:** [September 10, 2023, 9:08am UTC](https://forum.inductiveautomation.com/t/apex-line-chart-not-updating/78941/8 "2023-09-10T09:08:11Z")

</div>

For smooth animation with Apex Charts, you can only append data to the series.

This also means that for long running charts you will eventually need to prune old values when the data array for the series gets too large.

---

<div class="post-metadata">

**Author:** ![John\_Morgan1](https://avatars.discourse-cdn.com/v4/letter/j/22d042/32.png) [@John\_Morgan1](https://forum.inductiveautomation.com/u/John_Morgan1)\
**Post date:** [September 10, 2023, 4:03pm UTC](https://forum.inductiveautomation.com/t/apex-line-chart-not-updating/78941/9 "2023-09-10T16:03:33Z")

</div>

I have already done that by limiting the set to the last 8 recorded values through the script  
The problem is that the graph shape totally changes with each update as shown in the video

---

<div class="post-metadata">

**Author:** ![John\_Morgan1](https://avatars.discourse-cdn.com/v4/letter/j/22d042/32.png) [@John\_Morgan1](https://forum.inductiveautomation.com/u/John_Morgan1)\
**Post date:** [September 10, 2023, 4:05pm UTC](https://forum.inductiveautomation.com/t/apex-line-chart-not-updating/78941/10 "2023-09-10T16:05:34Z")

</div>

@Travis.Cox @nader.chinichian

Do you have any idea how can the graph be smooth with real-time data

---

<div class="post-metadata">

**Author:** ![nader.chinichian](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nader.chinichian/32/9261_2.png) [@nader.chinichian](https://forum.inductiveautomation.com/u/nader.chinichian)\
**Post date:** [September 10, 2023, 4:20pm UTC](https://forum.inductiveautomation.com/t/apex-line-chart-not-updating/78941/11 "2023-09-10T16:20:27Z")

</div>

Use this in options and also use short time range like man 10 min to make it work. Also, Update every second with Asstored Value. It is important not to use aggregation for this.

```auto
{
  "chart": {
    "animations": {
      "dynamicAnimation": {
        "speed": 1000
      },
      "easing": "linear",
      "enabled": true
    },
    "dropShadow": {
      "blur": 5,
      "color": "#52AFDE",
      "enabled": true,
      "opacity": 0.7
    },
    "id": "realtime",
    "toolbar": {
      "show": false
    },
    "zoom": {
      "enabled": false
    }
  },
  "dataLabels": {
    "enabled": false
  },
  "grid": {
    "show": true
  },
  "legend": {
    "show": false
  },
  "markers": {
    "size": 0
  },
  "stroke": {
    "colors": [
      "#4E93EF"
    ],
    "curve": "smooth",
    "width": 3
  },
  "title": {
    "align": "left",
    "style": {
      "color": "var(--color-label-0)",
      "fontFamily": "D-DIN",
      "fontSize": 20,
      "fontWeight": 300
    },
    "text": "Usage Of Last day Electricity"
  },
  "xaxis": {
    "labels": {
      "style": {
        "colors": "var(--color-label-2)",
        "cssClass": "",
        "fontFamily": "D-DIN"
      }
    },
    "range": 60000,
    "type": "datetime"
  },
  "yaxis": {
    "decimalsInFloat": false,
    "labels": {
      "align": "right",
      "style": {
        "colors": "var(--color-label-2)",
        "cssClass": "",
        "fontFamily": "D-DIN"
      }
    },
    "opposite": true
  }
}

```

---

<div class="post-metadata">

**Author:** ![bmusson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmusson/32/87530_2.png) [@bmusson](https://forum.inductiveautomation.com/u/bmusson)\
**Post date:** [September 10, 2023, 9:46pm UTC](https://forum.inductiveautomation.com/t/apex-line-chart-not-updating/78941/12 "2023-09-10T21:46:29Z")

</div>

> [@nader.chinichian](#):
>
> It is important not to use aggregation for this.

Yes exactly, you need the same values with identical timestamps each time the data refreshes.

---

<div class="post-metadata">

**Author:** ![John\_Morgan1](https://avatars.discourse-cdn.com/v4/letter/j/22d042/32.png) [@John\_Morgan1](https://forum.inductiveautomation.com/u/John_Morgan1)\
**Post date:** [September 11, 2023, 6:30pm UTC](https://forum.inductiveautomation.com/t/apex-line-chart-not-updating/78941/13 "2023-09-11T18:30:46Z")

</div>

I don't know what I have done wrong but it give me that result

[https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/1/51173dc7ad2c0b23633736cea4e6acc85c8367b0.mp4](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/1/51173dc7ad2c0b23633736cea4e6acc85c8367b0.mp4)

---

<div class="post-metadata">

**Author:** ![John\_Morgan1](https://avatars.discourse-cdn.com/v4/letter/j/22d042/32.png) [@John\_Morgan1](https://forum.inductiveautomation.com/u/John_Morgan1)\
**Post date:** [September 12, 2023, 4:30am UTC](https://forum.inductiveautomation.com/t/apex-line-chart-not-updating/78941/14 "2023-09-12T04:30:42Z")

</div>

Things had become much better  
Time on X-Axis is updating and I have changed the format with a script  
Animations give me a smooth look but I can't get rid of the snap shot style

[https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/4/544db117c8a9c54e9eeaebcc07eed4e1c56cfad4.mp4](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/4/544db117c8a9c54e9eeaebcc07eed4e1c56cfad4.mp4)
