diff --git a/Canvas.Core/Canvas.Core.csproj b/Canvas.Core/Canvas.Core.csproj index fc395a0..da9000b 100644 --- a/Canvas.Core/Canvas.Core.csproj +++ b/Canvas.Core/Canvas.Core.csproj @@ -5,7 +5,7 @@ disable disable True - 1.9.3 + 1.9.4 Internal package used in Canvas.Views.Web artemiusgreat indemos.com diff --git a/Canvas.Core/Composers/Composer.cs b/Canvas.Core/Composers/Composer.cs index 51b49f3..d8fec5f 100644 --- a/Canvas.Core/Composers/Composer.cs +++ b/Canvas.Core/Composers/Composer.cs @@ -6,7 +6,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Reflection; using System.Threading.Tasks; namespace Canvas.Core.Composers @@ -209,7 +208,7 @@ public Composer() { Size = 0.5; ValueCount = 3; - IndexCount = 10; + IndexCount = 9; Domain = new DomainModel(); Items = new List(); @@ -534,28 +533,29 @@ protected virtual IList 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(); 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; @@ -569,28 +569,29 @@ protected virtual IList 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(); 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; diff --git a/Canvas.Core/Composers/MapComposer.cs b/Canvas.Core/Composers/MapComposer.cs index e959d89..c8fbbdf 100644 --- a/Canvas.Core/Composers/MapComposer.cs +++ b/Canvas.Core/Composers/MapComposer.cs @@ -21,25 +21,26 @@ protected override IList GetIndices() var step = Math.Round((0.0 + maxIndex - minIndex) / IndexCount, MidpointRounding.ToZero); var items = new List(); - 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; @@ -58,25 +59,26 @@ protected override IList GetValues() var step = Math.Round((maxValue - minValue) / ValueCount, MidpointRounding.ToZero); var items = new List(); - 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; diff --git a/Canvas.Views.Web/Canvas.Views.Web.csproj b/Canvas.Views.Web/Canvas.Views.Web.csproj index 7e9aac1..069e394 100644 --- a/Canvas.Views.Web/Canvas.Views.Web.csproj +++ b/Canvas.Views.Web/Canvas.Views.Web.csproj @@ -10,7 +10,7 @@ true True - 1.9.3 + 1.9.4 finance chart opengl canvas trading gdi stock direct2d artemiusgreat indemos.com diff --git a/Samples/Pages/Heatmap.razor b/Samples/Pages/Heatmap.razor index c6d2537..a32902c 100644 --- a/Samples/Pages/Heatmap.razor +++ b/Samples/Pages/Heatmap.razor @@ -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 }; @@ -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) };