Skip to content

Commit

Permalink
Precision
Browse files Browse the repository at this point in the history
  • Loading branch information
artemiusgreat committed Feb 15, 2024
1 parent c211946 commit 2a341fa
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 54 deletions.
2 changes: 1 addition & 1 deletion Canvas.Core/Canvas.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>disable</Nullable>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Version>1.9.3</Version>
<Version>1.9.4</Version>
<Description>Internal package used in Canvas.Views.Web</Description>
<Authors>artemiusgreat</Authors>
<Copyright>indemos.com</Copyright>
Expand Down
49 changes: 25 additions & 24 deletions Canvas.Core/Composers/Composer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;

namespace Canvas.Core.Composers
Expand Down Expand Up @@ -209,7 +208,7 @@ public Composer()
{
Size = 0.5;
ValueCount = 3;
IndexCount = 10;
IndexCount = 9;

Domain = new DomainModel();
Items = new List<IShape>();
Expand Down Expand Up @@ -534,28 +533,29 @@ protected virtual IList<MarkerModel> GetIndices()
var minIndex = Domain.MinIndex;
var maxIndex = Domain.MaxIndex;
var center = Math.Round(minIndex + (maxIndex - minIndex) / 2.0, MidpointRounding.ToZero);
var step = Math.Round((0.0 + maxIndex - minIndex) / IndexCount, MidpointRounding.ToZero);
var step = Math.Round((0.0 + maxIndex - minIndex) / (IndexCount + 1.0), MidpointRounding.ToZero);
var items = new List<MarkerModel>();

void createItem(double i)
{
var position = GetItemPosition(View.Engine, i, 0).X;

if (i > minIndex && i < maxIndex)
items.Add(new MarkerModel
{
items.Add(new MarkerModel
{
Line = position,
Marker = position,
Caption = ShowIndex(i)
});
}
Line = position,
Marker = position,
Caption = ShowIndex(i)
});
}

for (var i = 0; i < IndexCount; i++)
var isEven = IndexCount % 2 is 0;

createItem(center);

for (var i = 1.0; i <= IndexCount / 2.0; i++)
{
createItem(center - i * step);
createItem(center + i * step);
createItem(center + i * step - (isEven ? 1 : 0));
}

return items;
Expand All @@ -569,28 +569,29 @@ protected virtual IList<MarkerModel> GetValues()
var minValue = Domain.MinValue;
var maxValue = Domain.MaxValue;
var center = Math.Round(minValue + (maxValue - minValue) / 2.0, MidpointRounding.ToZero);
var step = Math.Round((maxValue - minValue) / ValueCount, MidpointRounding.ToZero);
var step = Math.Round((maxValue - minValue) / (ValueCount + 1.0), MidpointRounding.ToZero);
var items = new List<MarkerModel>();

void createItem(double i)
{
var position = GetItemPosition(View.Engine, 0, i).Y;

if (i > minValue && i < maxValue)
items.Add(new MarkerModel
{
items.Add(new MarkerModel
{
Line = position,
Marker = position,
Caption = ShowValue(i)
});
}
Line = position,
Marker = position,
Caption = ShowValue(i)
});
}

for (var i = 0; i < ValueCount; i++)
var isEven = ValueCount % 2 is 0;

createItem(center);

for (var i = 1.0; i <= ValueCount / 2.0; i++)
{
createItem(center - i * step);
createItem(center + i * step);
createItem(center + i * step - (isEven ? 1 : 0));
}

return items;
Expand Down
50 changes: 26 additions & 24 deletions Canvas.Core/Composers/MapComposer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,26 @@ protected override IList<MarkerModel> GetIndices()
var step = Math.Round((0.0 + maxIndex - minIndex) / IndexCount, MidpointRounding.ToZero);
var items = new List<MarkerModel>();

void createItem(double i)
void createItem(double i, double correction)
{
var position = GetItemPosition(View.Engine, i, 0).X;

if (i >= minIndex && i < maxIndex)
items.Add(new MarkerModel
{
items.Add(new MarkerModel
{
Line = 0,
Marker = position + stepSize / 2.0,
Caption = ShowIndex(i)
});
}
Line = 0,
Marker = position + correction,
Caption = ShowIndex(i)
});
}

for (var i = 0; i < IndexCount; i++)
var isEven = IndexCount % 2 is 0;

createItem(center, 0);

for (var i = 1.0; i <= IndexCount / 2.0; i++)
{
createItem(center - i * step);
createItem(center + i * step);
createItem(center - i * step, stepSize / 2.0);
createItem(center + i * step - (isEven ? 1 : 0), stepSize / 2.0);
}

return items;
Expand All @@ -58,25 +59,26 @@ protected override IList<MarkerModel> GetValues()
var step = Math.Round((maxValue - minValue) / ValueCount, MidpointRounding.ToZero);
var items = new List<MarkerModel>();

void createItem(double i)
void createItem(double i, double correction)
{
var position = GetItemPosition(View.Engine, 0, i).Y;

if (i >= minValue && i < maxValue)
items.Add(new MarkerModel
{
items.Add(new MarkerModel
{
Line = 0,
Marker = position - stepSize / 2.0,
Caption = ShowValue(i)
});
}
Line = 0,
Marker = position - correction,
Caption = ShowValue(i)
});
}

for (var i = 0; i < ValueCount; i++)
var isEven = ValueCount % 2 is 0;

createItem(center, 0);

for (var i = 1.0; i <= ValueCount / 2.0; i++)
{
createItem(center - i * step);
createItem(center + i * step);
createItem(center - i * step, stepSize / 2.0);
createItem(center + i * step - (isEven ? 1 : 0), stepSize / 2.0);
}

return items;
Expand Down
2 changes: 1 addition & 1 deletion Canvas.Views.Web/Canvas.Views.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<PropertyGroup>
<IsPackable>true</IsPackable>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Version>1.9.3</Version>
<Version>1.9.4</Version>
<PackageTags>finance chart opengl canvas trading gdi stock direct2d</PackageTags>
<Authors>artemiusgreat</Authors>
<Copyright>indemos.com</Copyright>
Expand Down
8 changes: 4 additions & 4 deletions Samples/Pages/Heatmap.razor
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
if (setup)
{
var generator = new Random();
var indexLabels = new[] { "USD", "EUR", "CHF", "AUD", "GBP", "CAD", "DKK", "NZD", "SGD", "UAH", "NOK", "JPY", "CNY", "INR", "SEK" };
var valueLabels = new[] { "USD", "EUR", "CHF", "AUD", "GBP", "CAD", "DKK", "NZD" };
var indexLabels = new[] { "EUR", "CHF", "AUD", "GBP", "CAD", "DKK", "NZD", "SGD", "UAH", "NOK", "JPY", "CNY", "INR", "SEK" };
var valueLabels = new[] { "USD", "EUR", "CHF", "AUD", "GBP", "CAD", "DKK", "NZD", "EUR", "CHF", "AUD", "GBP", "CAD", "DKK", "NZD", "SGD", "UAH", "NOK", "JPY", "CNY", "INR", "SEK" };
var max = valueLabels.Length;
var min = 0;
var colorService = new ColorService { Min = min, Max = max, Mode = ShadeEnum.Intensity };
Expand All @@ -51,8 +51,8 @@
Name = "Correlation",
Items = points,
View = View,
IndexCount = indexLabels.Length,
ValueCount = valueLabels.Length,
IndexCount = 4,
ValueCount = 4,
ShowIndex = i => indexLabels.ElementAtOrDefault((int)i),
ShowValue = i => valueLabels.ElementAtOrDefault((int)i)
};
Expand Down

0 comments on commit 2a341fa

Please sign in to comment.