Adding Custom Data Tips to Plot Running in Real-Time

6 views (last 30 days)
I am working on designing an app that plots seven different lines in real time to indicate how certain values are trending over time. I am trying to create custom data tips for each line that is plotted to display the values of all the other lines at that time as well as a few extra values. When I create the custom data tips when the plot is originally created all the custom data tip rows don't show any values, just labels. I tried creating a function to call the custom data tip functions again, so as to update with the latest values of the variables I am trying to include in the data tips. When I do this, I get an error saying "Value must be compatible with the data source". Is there any way to update the custom data tips while plotting in real time? The functions I am using are shown below.
function CreateDataTips(app)
%Discards Line Data Tips
app.discardsplot.DataTipTemplate.DataTipRows(1).Label = 'Date-Time';
app.discardsplot.DataTipTemplate.DataTipRows(2).Label = 'Packet Discards';
app.discardsplot.DataTipTemplate.DataTipRows(3) = dataTipTextRow('Packet Retries',app.Retries_all);
app.discardsplot.DataTipTemplate.DataTipRows(4) = dataTipTextRow('Packet Fails',app.Fails_all);
app.discardsplot.DataTipTemplate.DataTipRows(5) = dataTipTextRow('Bits Recieved',app.Recieved_all);
app.discardsplot.DataTipTemplate.DataTipRows(6) = dataTipTextRow('Bits Sent',app.Sent_all);
app.discardsplot.DataTipTemplate.DataTipRows(7) = dataTipTextRow('RSSI',app.RSSI_all);
app.discardsplot.DataTipTemplate.DataTipRows(8) = dataTipTextRow('SNR',app.SNR_all);
app.discardsplot.DataTipTemplate.DataTipRows(9) = dataTipTextRow('TX Rate',app.Rate_all);
%Retries Line Data Tips
%.... Same for other 6 lines
end
function UpdateDataTips(app)
%Discards Line Data Tips
app.discardsplot.DataTipTemplate.DataTipRows(3).Value = app.Retries_all;
app.discardsplot.DataTipTemplate.DataTipRows(4).Value = app.Fails_all;
app.discardsplot.DataTipTemplate.DataTipRows(5).Value = app.Recieved_all;
app.discardsplot.DataTipTemplate.DataTipRows(6).Value = app.Sent_all;
app.discardsplot.DataTipTemplate.DataTipRows(7).Value = app.RSSI_all;
app.discardsplot.DataTipTemplate.DataTipRows(8).Value = app.SNR_all;
app.discardsplot.DataTipTemplate.DataTipRows(9).Value = app.Rate_all;
%Retries Line Data Tips
%.... Same for other 6 lines
  1 Comment
Nick Nauman
Nick Nauman on 23 Jul 2021
Is anyone able to provide an update on the options available for providing values in the custom data tip based on values from other lines on the plot that can be updated in real time? I have been working on this and still I am unable to find a solution

Sign in to comment.

Accepted Answer

Nick Nauman
Nick Nauman on 26 Jul 2021
I have found that the only way to update the Value field of the DataTipTemplate property is to first delete the property and then recreate the data tips. Reference the following code:
function CreateDataTips(app)
%Discards Line Data Tips
app.discardsplot.DataTipTemplate.DataTipRows(1).Label = 'Date-Time';
app.discardsplot.DataTipTemplate.DataTipRows(2).Label = 'Packet Discards';
app.discardsplot.DataTipTemplate.DataTipRows(3) = dataTipTextRow('Packet Retries',app.Retries_all);
app.discardsplot.DataTipTemplate.DataTipRows(4) = dataTipTextRow('Packet Fails',app.Fails_all);
app.discardsplot.DataTipTemplate.DataTipRows(5) = dataTipTextRow('Bits Recieved',app.Recieved_all);
app.discardsplot.DataTipTemplate.DataTipRows(6) = dataTipTextRow('Bits Sent',app.Sent_all);
app.discardsplot.DataTipTemplate.DataTipRows(7) = dataTipTextRow('RSSI',app.RSSI_all);
app.discardsplot.DataTipTemplate.DataTipRows(8) = dataTipTextRow('SNR',app.SNR_all);
app.discardsplot.DataTipTemplate.DataTipRows(9) = dataTipTextRow('TX Rate',app.Rate_all);
%Retries Line Data Tips
%.... Same for other 6 lines
end
function DeleteDataTips(app)
%Discards Line Data Tips
delete(app.discardsplot.DataTipTemplate);
%Retries Line Data Tips
%.... Same for other 6 lines
end
I have not had the opportunity to test how resource intensive it is to do this every 1 second (how frequently I am updating the data), especially when the amount of data gets larger. Does anyone know is this the most effective and efficient solution?

More Answers (0)

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!