Skip to content

Commit

Permalink
Added max min value control in heatmap
Browse files Browse the repository at this point in the history
  • Loading branch information
ncguilbeault committed Sep 5, 2024
1 parent 1ed848a commit 76a6a0d
Showing 1 changed file with 81 additions and 9 deletions.
90 changes: 81 additions & 9 deletions src/Bonsai.ML.Visualizers/HeatMapSeriesOxyPlotBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,14 @@ public class HeatMapSeriesOxyPlotBase : UserControl
private ToolStripLabel renderMethodLabel;
private int _renderMethodSelectedIndex;
private HeatMapRenderMethod renderMethod = HeatMapRenderMethod.Bitmap;

private StatusStrip statusStrip;

private ToolStripTextBox maxValueTextBox;
private ToolStripLabel maxValueLabel;

private ToolStripTextBox minValueTextBox;
private ToolStripLabel minValueLabel;

private int _numColors = 100;

/// <summary>
Expand Down Expand Up @@ -91,24 +96,93 @@ private void Initialize()

InitializeColorPalette();
InitializeRenderMethod();
InitializeColorAxisValues();

statusStrip = new StatusStrip
{
Visible = false
Visible = false,
};

statusStrip.Items.AddRange(new ToolStripItem[] {
var toolStripItems = new ToolStripItem[] {
paletteLabel,
paletteComboBox,
renderMethodLabel,
renderMethodComboBox
});
renderMethodComboBox,
maxValueLabel,
maxValueTextBox,
minValueLabel,
minValueTextBox
};

ToolStripDropDownButton visualizerPropertiesButton = new ToolStripDropDownButton("Visualizer Properties");

foreach (var item in toolStripItems)
{
visualizerPropertiesButton.DropDownItems.Add(item);
}

statusStrip.Items.Add(visualizerPropertiesButton);

Controls.Add(statusStrip);
view.MouseClick += new MouseEventHandler(onMouseClick);
AutoScaleDimensions = new SizeF(6F, 13F);
}

private void InitializeColorAxisValues()
{
maxValueLabel = new ToolStripLabel
{
Text = "Maximum Value:",
AutoSize = true
};

maxValueTextBox = new ToolStripTextBox()
{
Name = "maxValue",
AutoSize = true,
Text = "auto",
};

maxValueTextBox.TextChanged += (sender, e) =>
{
if (double.TryParse(maxValueTextBox.Text, out double maxValue))
{
colorAxis.Maximum = maxValue;
}
else
{
colorAxis.Maximum = heatMapSeries.MaxValue;
}
UpdatePlot();
};

minValueLabel = new ToolStripLabel
{
Text = "Minimum Value:",
AutoSize = true
};

minValueTextBox = new ToolStripTextBox()
{
Name = "minValue",
AutoSize = true,
Text = "auto",
};

minValueTextBox.TextChanged += (sender, e) =>
{
if (double.TryParse(minValueTextBox.Text, out double minValue))
{
colorAxis.Minimum = minValue;
}
else
{
colorAxis.Minimum = heatMapSeries.MinValue;
}
UpdatePlot();
};
}

private void InitializeColorPalette()
{
paletteLabel = new ToolStripLabel
Expand All @@ -119,8 +193,7 @@ private void InitializeColorPalette()

paletteComboBox = new ToolStripComboBox()
{
Name = "palette",
AutoSize = true,
Name = "palette"
};

foreach (var value in Enum.GetValues(typeof(ColorPalette)))
Expand Down Expand Up @@ -162,8 +235,7 @@ private void InitializeRenderMethod()

renderMethodComboBox = new ToolStripComboBox()
{
Name = "renderMethod",
AutoSize = true,
Name = "renderMethod"
};

foreach (var value in Enum.GetValues(typeof(HeatMapRenderMethod)))
Expand Down

0 comments on commit 76a6a0d

Please sign in to comment.