Commit Latest

This commit is contained in:
2025-06-20 20:13:27 -04:00
parent 9e6feaf252
commit 8647d86ea2
2 changed files with 18 additions and 9 deletions

View File

@@ -32,13 +32,21 @@ namespace PortfolioManager.ViewModels
public static Image GenerateImage(String text)
{
ImageHelper imageHelper = new ImageHelper();
int fontSize = 36;
int fontSize = 12;
int width = 130;
imageHelper.CreateImage(width, fontSize);
int height = 24;
imageHelper.CreateImage(width, height); //, new PointMapping(width,height,width,0,height,0));
imageHelper.Fill(SKColors.White);
SKTextAlign align = SKTextAlign.Center;
SKFont font = new SKFont(SKTypeface.FromFamilyName("Helvetica"), fontSize);
imageHelper.DrawText(text, new SKPoint(width / 2, fontSize - 2), SKColors.Black, align, font);
// SKFont font = new SKFont(SKTypeface.FromFamilyName("Arial",SKFontStyle.Normal), fontSize);
SKFont font = new SKFont(SKTypeface.FromFamilyName("Arial",500,5,SKFontStyleSlant.Upright), fontSize);
// SKFont font = new SKFont(SKTypeface.Default, fontSize);
imageHelper.DrawLine(SKColors.Black,1, new SKPoint(0,0), new SKPoint(width-1,0)); // bottom left to right
imageHelper.DrawLine(SKColors.Black,1, new SKPoint(width-1,0), new SKPoint(width-1,height-1)); // up lefthand side
imageHelper.DrawLine(SKColors.Black,1, new SKPoint(0,height-1), new SKPoint(width-1,height-1)); // top left to right
imageHelper.DrawLine(SKColors.Black,1, new SKPoint(0,height-1), new SKPoint(0,0)); // left hand side top to bottom
imageHelper.DrawText(text, new SKPoint(width / 2, height-8), SKColors.Black, align, font);
using MemoryStream memoryStream = new MemoryStream();
imageHelper.ToStream().CopyTo(memoryStream);
return new ScottPlot.Image(memoryStream.ToArray());

View File

@@ -23,6 +23,7 @@ namespace PortfolioManager.ViewModels
public void Render(AvaPlot plotter)
{
plotter.Plot.Axes.AutoScale();
plotter.Plot.HideLegend();
plotter.Refresh();
}
@@ -52,10 +53,10 @@ namespace PortfolioManager.ViewModels
// marker.MarkerStyle.Shape = MarkerShape.TriUp;
// marker.MarkerStyle.Size = 15;
IImage image = TextMarkerImageGenerator.GenerateImage("Even $52.14 (+.25%");
Coordinates coordinates = new Coordinates(dates[0].ToOADate(), values[0] / 1.025);
Marker marker = plotter.Plot.Add.ImageMarker(coordinates, image);
Image image = default;
Image image = TextMarkerImageGenerator.GenerateImage("Even $52.14 (+.25%)");
Coordinates coordinates = new Coordinates(dates[0].ToOADate(), values[0] / 1.0125);
ImageMarker marker = plotter.Plot.Add.ImageMarker(coordinates, image);
@@ -176,7 +177,7 @@ namespace PortfolioManager.ViewModels
public void PlotterLoadedEvent(object sender, PlotterLoadedEventArgs e)
{
String selectedSymbol = "SPY";
String selectedSymbol = "CRS";
int selectedDayCount = 180;
plotter = e.AvaPlot; // we should store this somewhere