Exporting data from chart to same columns of existing Excel

I want to allow a user to run statistical analysis (best fit line, yield and R² values etc) of two datasets returned from an EasyChart. Is there a way to export the two datasets queried to the same two columns of an existing excel sheet? That way the user could set up the excel to do the analysis of Col1 and Col2 and each time they view the sheet the analysis would be ready.

unless there is a way to this type of analysis using an EasyChart directly??

First, please don’t double post. It’s like repeatedly pushing a button on an elevator. The elevator doesn’t move any faster. :slight_smile: Also it helps keep thing nice and tidy and we don’t have to run back and forth between threads.

Now for an answer.

Not within the easy chart. But possible to do with scripting and regular charts.

The math extensions I wrote a while back has a simple linear regression function.
Using a normal Chart and Date Range component:



Script attached to Date Range component:

[code]startDate=event.source.start
endDate=event.source.end
slope=float(0)
intercept=float(0)
r=float(0)

query=“SELECT t_stamp, unix_timestamp(t_stamp) AS x, Takt_Time as y FROM ds_3425_takt where StationID=‘40’ and t_stamp>=’%s’ and t_stamp<=’%s’” % (startDate,endDate)

DataIn=table = system.db.runQuery(query,“Takt”)

i=0
xList=
yList=
for row in DataIn:
i=i+1
xList.append(row[1])
yList.append(row[2])

if i>1:
slope,intercept,r=app.math.linreg(xList,yList)

headers=[“t_stamp”, “Takt”, “Trend”]
rows=
for row in DataIn:
trend=slope*row[1]+intercept
oneRow=[row[0],row[2],trend]
rows.append(oneRow)

data = system.dataset.toDataSet(headers, rows)
event.source.parent.getComponent(‘Chart’).Data=data
[/code]
That should give you a start.

Thanks Jordan, yeah apologies for the double post. I only realised after i posted in 7.7 that it may not be the correct location to post.

The reason i asked about using this function with the easy chart was that i have set the client up with the function to drag tags onto the chart from the tag browse, and additionally click to graph. Instead of trying to run this function (best fit line etc) on the easy chart, would be possible to set the ‘Normal Chart’ up to work with the click to graph? For the CTG i used the Ignition scripts.


So ideally i’d like to run the normal chart to run existing function, plus additional best fit line.