Commit Latest

This commit is contained in:
2025-07-14 22:07:35 -04:00
parent b197aeff10
commit 78964a53d3
3 changed files with 13 additions and 8 deletions

View File

@@ -19,6 +19,7 @@ using SkiaSharp;
using MarketData.Numerical;
using MarketData;
using Avalonia.Controls.Platform;
using System.Threading;
namespace PortfolioManager.Renderers
{
@@ -55,8 +56,10 @@ namespace PortfolioManager.Renderers
{
foreach(TextPlot textPlot in this)
{
if(Math.Round(screenCoordinates.X,2) >= Math.Round(textPlot.BoundingRect.Left,2) && Math.Round(screenCoordinates.X,2) <= Math.Round(textPlot.BoundingRect.Right,2) &&
Math.Round(screenCoordinates.Y,2) >= Math.Round(textPlot.BoundingRect.Top,2) && Math.Round(screenCoordinates.Y,2) <= Math.Round(textPlot.BoundingRect.Bottom,2))
if(Math.Round(screenCoordinates.X,2) >= Math.Round(textPlot.BoundingRect.Left,2) &&
Math.Round(screenCoordinates.X,2) <= Math.Round(textPlot.BoundingRect.Right,2) &&
Math.Round(screenCoordinates.Y,2) >= Math.Round(textPlot.BoundingRect.Top,2) &&
Math.Round(screenCoordinates.Y,2) <= Math.Round(textPlot.BoundingRect.Bottom,2))
{
MDTrace.WriteLine(LogLevel.DEBUG,$"The text {markerText} at Point:X:{screenCoordinates.X}:Y:{screenCoordinates.Y} is within Rect:L({textPlot.BoundingRect.Left}),T({textPlot.BoundingRect.Top}),R({textPlot.BoundingRect.Right}),B({textPlot.BoundingRect.Bottom}) with text {textPlot.MarkerText} which is plotted at Coordinates:X:{textPlot.ScreenCoordinates.X} Y:{textPlot.ScreenCoordinates.Y}");
SKRect lowestRect = FindLowestAdjacentRect(textPlot.BoundingRect);
@@ -74,7 +77,7 @@ namespace PortfolioManager.Renderers
/// <returns></returns>
private SKRect FindLowestAdjacentRect(SKRect rect)
{
List<SKRect> adjacentRects = this.Where(x=> rect.Left>=x.BoundingRect.Left && rect.Right<=x.BoundingRect.Right).Select(x=>x.BoundingRect).ToList();
List<SKRect> adjacentRects = this.Where(x=> rect.Left >= x.BoundingRect.Left && rect.Right <= x.BoundingRect.Right).Select(x=>x.BoundingRect).ToList();
if(null == adjacentRects || 0==adjacentRects.Count)return new SKRect(){Left=0,Top=0,Right=0,Bottom=0};
adjacentRects = adjacentRects.OrderByDescending(x=>x.Bottom).ToList();
return adjacentRects[0];
@@ -102,7 +105,7 @@ namespace PortfolioManager.Renderers
private Prices prices = default;
private BollingerBands bollingerBands;
private InsiderTransactionSummaries insiderTransactionSummaries = null;
private TextPlots textPlots = new TextPlots();
// private TextPlots textPlots = new TextPlots();
private OffsetDictionary offsets = new OffsetDictionary();
@@ -128,6 +131,7 @@ namespace PortfolioManager.Renderers
public void Render()
{
MDTrace.WriteLine(LogLevel.DEBUG,$"[Render] ENTER");
Plotter.Plot.Axes.Left.TickGenerator = new ScottPlot.TickGenerators.NumericAutomatic()
{
LabelFormatter = (double value) => value.ToString("C") // "C" format specifier formats as currency
@@ -138,10 +142,12 @@ namespace PortfolioManager.Renderers
Plotter.Plot.YLabel("Price");
Plotter.Refresh();
base.OnPropertyChanged("ShowLegend");
MDTrace.WriteLine(LogLevel.DEBUG,$"[Render] LEAVE");
}
public void SetData(String selectedSymbol, int selectedDayCount)
{
MDTrace.WriteLine(LogLevel.DEBUG,$"[SetData] ENTER");
this.selectedSymbol = selectedSymbol;
this.selectedDayCount = selectedDayCount;
stopLimit = PortfolioDA.GetStopLimit(selectedSymbol);
@@ -189,7 +195,6 @@ namespace PortfolioManager.Renderers
}
bollingerBands = BollingerBandGenerator.GenerateBollingerBands(prices);
// textPlots.Clear();
// textPlots = new TextPlots();
CalculateOffsets();
GenerateBollingerBands();
GenerateLeastSquares();
@@ -197,6 +202,7 @@ namespace PortfolioManager.Renderers
GenerateStopLimits();
GenerateTradePoints();
GenerateZeroPoint(zeroPrice);
MDTrace.WriteLine(LogLevel.DEBUG,$"[SetData] LEAVE");
}
/// <summary>
@@ -537,7 +543,7 @@ namespace PortfolioManager.Renderers
Low = BollingerBandModel.Low(bollingerBands);
Close = BollingerBandModel.Close(bollingerBands);
SMAN = BollingerBandModel.SMAN(bollingerBands);
Volume = BollingerBandModel.Volume(bollingerBands);
// Volume = BollingerBandModel.Volume(bollingerBands);
Scatter scatter = default;
{

View File

@@ -10,7 +10,7 @@ namespace PortfolioManager.ViewModels
public abstract class PlotterWorkspaceViewModel : WorkspaceViewModel
{
public AvaPlot Plotter { get; set; }
public AvaPlot Plotter { get; set; }
public EventHandler<PlotterLoadedEventArgs> OnPlotterLoadedEventHandler;

View File

@@ -80,7 +80,6 @@
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" FontSize="16" Text="{Binding Path=GraphTitle}" HorizontalAlignment="Center"></TextBlock>
<!-- <ScottPlot:AvaPlot Grid.Row="1" Name="AvaPlot" Loaded="AvaPlot_Loaded"/> -->
<ContentControl Grid.Row="1" Content="{Binding Path=Plotter}"/>
</Grid>
</Grid>