classdef BrokenChartClass < matlab.graphics.chartcontainer.ChartContainer
properties
Data timetable
end
properties (Access = private)
NumSubplots = 1
DataAxes
DataLines
end
methods
function obj = BrokenChartClass(T)
arguments
T timetable
end
obj@matlab.graphics.chartcontainer.ChartContainer();
obj.NumSubplots = length(T.Properties.VariableNames);
obj.Data = T;
end
end
methods (Access = protected)
function setup(obj)
tcl = getLayout(obj);
obj.DataAxes = arrayfun(@(n)nexttile(tcl, n), 1:obj.NumSubplots);
obj.DataLines = arrayfun(@(hax)plot(hax, NaT, NaN), obj.DataAxes);
end
function update(obj)
tbl = obj.Data;
t = tbl.Properties.RowTimes;
for k = 1:length(obj.DataLines)
set(obj.DataLines(k), 'XData', t, 'YData', tbl{:,k})
end
end
end
end
T = timetable((datetime():seconds(1):datetime+hours(1))',randn(3601,1),10*randn(3601,1));
head(T)
BrokenChartClass(T(:,1));
BrokenChartClass(T(:,1:2));