Cancel
Showing results for 
Search instead for 
Did you mean: 

Customize chart data on the fly

Valued Contributor
Valued Contributor

Hello,

 

I have a tablefile where I record data in 4 columns to display in a chart at the end of the simulation.

 

My plan is to have a checkbox or similar  where the user can check/uncheck the data he/she wants to see in the graph after the simulation has ended. Is this possible to do?

 

Thank you.

3 REPLIES

Re: Customize chart data on the fly

Legend
Legend

How is the data going to be presented? You could use a Chart object, set the Data source to Table File and then write a custom string for the Range parameter to include those ranges that the user has selected with the checkboxes. Or you can copy the relevant columns to a table file that the chart is reading from.

Re: Customize chart data on the fly

Valued Contributor
Valued Contributor

I have experimented setting a custom range, but I haven't managed to pick exact columns I would like.

 

Trying something like:

 

{0,1}..{0,*} , {3,1}..{3,*}

to only display the 0th and 3rd column autocorrects to {*,*}..{*,*}, resulting in the chart displaying all columns. I didn't find anything in the help file regarding setting a range for specific columns and not all columns within a range.

 

Maybe I am setting a custom range wrong?

 

Also, is there a way to insert buttons within a chart object? Or would the buttons have to be in the frame, separate from the chart?

Re: Customize chart data on the fly

Legend
Legend

That syntax would work in other parts of Plant Simulation, but not here it seems.

 

But I think the better way to do it is the second way I described. Have the Chart point to a new TableFile called for example ChartData, and then when you want to display the chart (could be in an openCtrl) you copy the data you want to the table ChartData.

 

Something like this, SimTalk 2.0:

 

-- Loop through each checkbox however you want
ChartData.delete -- Make sure that the result table is empty.
for var i := 1 to TableWithCheckboxes.YDim
if TableWithCheckBoxes[1,i].Value -- If it's included
TableFileWithData.copyRangeTo({ColumnToCopy, 1}..{ColumnToCopy, *}, ChartData, ChartData.XDim+1, 1)
end
next

 

Then it depends on the type of data you want to display, but my guess is you want to se the Data: in Column under Display. 

 

 I think the best bet would be to have the buttons separate from the chart. Not sure that there's a way to include them in the chart.