Sorry for the delay. While you won't be able to dynamically define a DataShape, you can create a DataShape that captures all of the possible fields and populate those fields based on the user's selection. For example, your Service would take six inputs (A, B, C, D, E, F), determine the fields and values that should be returned based on those inputs, and return an +InfoTable +which you bind to the Time Series Chart.
Hope that helps.
Yes I agree with you on the Service creation which take 6 inputs (A,B,C,D,E,F) which I will bind them to the state of the check-boxes, which would help me to determine which series shall be returned based on user selection of the check-boxes.
The issue is, I will use the QueryStreamEntrieswithData for the STREAM that I used to record the time series data (all A,B,C,D,E,F series data in one stream). Then it will return me the records in infotable. However, binding this infotable directly to the chart will render all series in one chart, not based on user selection.
Shall I use any Infotable function to remove the 'unwanted' column (say C,D,E and keep A,B,F) in the infotable, before it is sent to the chart for display? If yes how to do so as I am not aware of any built-in infotable function that is suitable for that.
If that is not the concept/idea, would you please explain in further detailed with some sample code for my reference?
Thanks in advance.
You can use
to remove fields based on the user's selection. For example, a Service that has two BOOLEAN inputs (a, b) would have logic as follows:
// Get Stream entries here
if (a && !b)
result.RemoveField("fieldB"); // RemoveField() takes the name of the field as input
else if (!a && b)
else if (!a && !b)
// Remove both fields
The one downside to this solution is the chart's legend, if displayed, will show all of the fields, regardless of the user's selection. Oh, and all of the if statements you will need to write too :-)
Or you can use QueryNamedPropertyHistory with an InfoTable of properties based on user selection :
- DataShape: PropertyNamesForChart(name, description)
- New service ShowPropertiesForChart:
- Inputs: boolean (from properties' checkbox)
- Ouput: Infotable, DataShape: PropertyNamesForChart
- Build the InfoTable with AddRow based on properties' name
- In the Mashup, the ouput of ShowPropertiesForChart will be the input of QueryNamedPropertyHistory's parameter "propertyNames"
It worked for me. Hope it can help.
Thanks for the suggestion! The RemoveField() method works, and in fact, it works quite well as the 'unwanted' series legend are NOT shown at all. Work just as what I expect it to be.
Also, instead of writing all possible combination of checkboxes, I just check the states of checkboxes with multiple IF instead of IF/ELSE. That reduces the code to be written but of course consume little more computing power but I think should be negligible.
One last question on this:
I tried to search Resources-Infotable functions before but couldn't see 'RemoveField()'. It is NOT exist under the Services SNIPPET section as well. So my question is, where should I go to look for possible built-in services in normal circumstances? That would help me to self-help before checking with you all in future.
Thanks in advance for your suggestion.