Skip to content

Commit

Permalink
Use state component visualizer label in Y axis
Browse files Browse the repository at this point in the history
  • Loading branch information
glopesdev committed Jun 28, 2024
1 parent fb5c41f commit d01b703
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/Bonsai.ML.Visualizers/StateComponentVisualizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public override void Load(IServiceProvider provider)
var areaSeriesName = string.IsNullOrEmpty(Label) ? "Variance" : $"{Label} Variance";
AreaSeries = Plot.AddNewAreaSeries(areaSeriesName, color: AreaSeriesColor);

if (Label != null) Plot.ValueLabel = Label;
Plot.ResetLineSeries(LineSeries);
Plot.ResetAreaSeries(AreaSeries);
Plot.ResetAxes();
Expand Down
30 changes: 17 additions & 13 deletions src/Bonsai.ML.Visualizers/TimeSeriesOxyPlotBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ namespace Bonsai.ML.Visualizers
{
internal class TimeSeriesOxyPlotBase : UserControl
{
private PlotView view;
private PlotModel model;
private OxyColor defaultLineSeriesColor = OxyColors.Blue;
private OxyColor defaultAreaSeriesColor = OxyColors.LightBlue;
private readonly PlotView view;
private readonly PlotModel model;
private static readonly OxyColor DefaultLineSeriesColor = OxyColors.Blue;
private static readonly OxyColor DefaultAreaSeriesColor = OxyColors.LightBlue;

private Axis xAxis;
private Axis yAxis;
private readonly Axis xAxis;
private readonly Axis yAxis;

private StatusStrip statusStrip;
private readonly StatusStrip statusStrip;

/// <summary>
/// Gets or sets the datetime value that determines the starting time of the data values.
Expand All @@ -42,14 +42,18 @@ internal class TimeSeriesOxyPlotBase : UserControl
public bool BufferData { get; set; }

/// <summary>
/// Initializes a new instance of the <see cref="TimeSeriesOxyPlotBase"/> class
/// Gets or sets the label of the value axis in the time series plot.
/// </summary>
public TimeSeriesOxyPlotBase()
public string ValueLabel
{
Initialize();
get => yAxis.Title;
set => yAxis.Title = value;
}

private void Initialize()
/// <summary>
/// Initializes a new instance of the <see cref="TimeSeriesOxyPlotBase"/> class
/// </summary>
public TimeSeriesOxyPlotBase()
{
view = new PlotView
{
Expand Down Expand Up @@ -133,7 +137,7 @@ public void AddComboBoxWithLabel(string label, IEnumerable dataSource, int selec
/// </summary>
public LineSeries AddNewLineSeries(string lineSeriesName, OxyColor? color = null)
{
OxyColor _color = color.HasValue ? color.Value : defaultLineSeriesColor;
OxyColor _color = color.HasValue ? color.Value : DefaultLineSeriesColor;
LineSeries lineSeries = new LineSeries {
Title = lineSeriesName,
Color = _color
Expand All @@ -150,7 +154,7 @@ public LineSeries AddNewLineSeries(string lineSeriesName, OxyColor? color = null
/// </summary>
public AreaSeries AddNewAreaSeries(string areaSeriesName, OxyColor? color = null, OxyColor? fill = null, byte opacity = 100)
{
OxyColor _color = color.HasValue ? color.Value : defaultAreaSeriesColor;
OxyColor _color = color.HasValue ? color.Value : DefaultAreaSeriesColor;
OxyColor _fill = fill.HasValue? fill.Value : OxyColor.FromArgb(opacity, _color.R, _color.G, _color.B);
AreaSeries areaSeries = new AreaSeries {
Title = areaSeriesName,
Expand Down

0 comments on commit d01b703

Please sign in to comment.