nasa / openmct

A web based mission control framework.
https://nasa.github.io/openmct/
Other
11.98k stars 1.24k forks source link

How can I view multiple lines on the same plot? #2991

Open KhaledSharif opened 4 years ago

KhaledSharif commented 4 years ago

How can I view multiple lines on the same plot? I am currently rendering values in a plot in OpenMCT using the following telemetry JSON:

telemetry: {
        values: [
          {
            key: "x",
            name: "X",
            units: "metres",
            format: "float",
            hints: {
              range: 1,
            }
          },
          {
            key: "y",
            name: "Y",
            units: "metres",
            format: "float",
            hints: {
              range: 1,
            }
          },
          {
            key: "z",
            name: "Z",
            units: "metres",
            format: "float",
            hints: {
              range: 1,
            }
          },
          {
            key: "w",
            name: "W",
            units: "metres",
            format: "float",
            hints: {
              range: 1,
            }
          },
          {
            key: "utc",
            source: "timestamp",
            name: "Timestamp",
            format: "utc",
            hints: {
              domain: 1,
            },
          },
        ],
      }

However, this will only plot the values of X by default. If I want to switch between them, I can through the drop-down menu that appears on the Y-axis in the plot. But I can't find a way to view a plot of multiple lines (X, Y, Z, W) on the same graph. Is this possible?

Thank you for your support!

KhaledSharif commented 4 years ago

Following up on this issue:

I realized Overlay Plots exist and I can create them pragmatically. However I can't create an overlay plot from the same telemetry object but using different yKeys. My work around to this is to split each object into multiple telemetry objects with only one yKey, and then create an Overlay Plot from the new objects.

mudinthewater commented 4 years ago

@KhaledSharif you'd typically put them in separate channels then plot together on an overlay. If you want your behavior, you'd have to define a custom telemetry type like the openmct-map repo does here:

https://github.com/nasa/openmct-map/blob/master/src/LocationMeasurementTelemetryPlugin.js Then plot each component on an overlay. (I.e define custom type, put it on an overlay 3 times, pick which hint for each axis.)

It would be far easier to just split it into its components at the query.

KhaledSharif commented 3 years ago

@mudinthewater

Thanks for the tip, I appreciate your help. I just got around to trying out your idea of defining a custom type. Unfortunately, an overlay plot won't accept the same "key" twice, so trying to plot the same component with different hints doesn't seem to work. I'm not sure if this is a bug in OpenMCT, or a feature, or if I'm doing something wrong.

akhenry commented 3 years ago

@KhaledSharif It's by design (we have code that explicitly forbids multiple-composition with the same object), but your use case is totally valid, this is just a shortcoming of our current plot implementation I'm afraid.

We have some plot enhancements coming over the next few months, we will look at addressing this issue as part of those improvements.

In the short term, as @mudinthewater suggested, your best bet is to expose each of the attributes you want to plot as separate telemetry points (rather than a single telemetry point that emits values with a number of attributes).

The suggestion to create a new telemetry type is also a good one. You could define a generic "telemetry splitter" type that references a telemetry object (this could be user-configurable, ala the TelemetryAverager plugin). You could then define a new composition provider that only applies to telemetry splitter objects, reads their telemetry metadata, and basically spits out a child telemetry object for each "range" attribute defined in the original telemetry object's metadata. A telemetry provider could then be defined that provides telemetry for these child objects by requesting and subscribing to the original telemetry object, and then "splitting" the incoming telemetry into timestamp and range value pairs.