XY Chart Not Updating with New Data

I have a few charts that have data bound to a Named Query. When the chart updates, sometimes the chart won’t properly show the line and it looks like it’s doing a zig-zag pattern (like it’s appending the bound data rather than replacing it.

Below is a picture of what I mean. That green data line is supposed to be a single line between two points. I don’t know if this is a bug or I’m missing something.

Would it be possible to post the query here, so we can see if spot anything obvious?

Yes I can do that, but I also remembered that the data binding for the XY Chart is not a simple named query.

In my View, I have a custom parameter that grabs the data using a named query (picture below)

Then, I can use that parameter multiple places (so I don’t have to keep running/polling the same Named Query from multiple sources). The XY Chart is one of those places. I’m using a Property binding that binds to that previous Custom Parameter than using a transform script to organize the data for the binding (see below).

day_data_dict = {}
day_data = []
	
day_counter = 0
for row in value:
	row_date_parse = system.date.parse(row["time"])
	row_date = [
		system.date.getMonth(row_date_parse) + 1,
		system.date.getDayOfMonth(row_date_parse),
		system.date.getYear(row_date_parse)
	]
	
	downtime = row["downtime_minutes"]

	palletizer = row["palletizer_number"]

	date_string = "{0}/{1}/{2}".format(row_date[0], row_date[1], row_date[2])
	# First entry
	if len(day_data) == 0:
		day_data_dict = {
			"date": date_string,
			"count1": 1 if palletizer == 1 else 0,
			"downtime1": downtime if palletizer == 1 else 0,
			"count2": 1 if palletizer == 2 else 0,
			"downtime2": downtime if palletizer == 2 else 0
		}
		day_data.append(day_data_dict)
	else:
		row_idx = 0
		date_exists = False
		# Loop through the existing data (that has at least one row in it)
		for date_row in day_data:
			if date_string == date_row["date"]:
				date_exists = True
				break
			row_idx += 1
		# If the date matches the date in the row, increment the frequency counter
		if date_exists:
			counter1 = day_data[row_idx]["count1"]
			counter2 = day_data[row_idx]["count2"]
			current_downtime1 = day_data[row_idx]["downtime1"]
			current_downtime2 = day_data[row_idx]["downtime2"]
			
			day_data_dict = {
				"date": date_string,
				"count1": counter1 + 1 if palletizer == 1 else counter1,
				"downtime1": current_downtime1 + downtime if palletizer == 1 else current_downtime1,
				"count2": counter2 + 1 if palletizer == 2 else counter2,
				"downtime2": current_downtime2 + downtime if palletizer == 2 else current_downtime2,
			}
			day_data[row_idx] = day_data_dict
			row_idx += 1
		# If the date does not match, create a new date entry
		else:
			day_data_dict = {
				"date": date_string,
				"count1": 1 if palletizer == 1 else 0,
				"downtime1": downtime if palletizer == 1 else 0,
				"count2": 1 if palletizer == 2 else 0,
				"downtime2": downtime if palletizer == 2 else 0,
				"palletizer": palletizer
			}
			day_data.append(day_data_dict)
			row_idx = 0
	
sorted_list = sorted(day_data, key=lambda x:x["date"])

return sorted_list