-
Notifications
You must be signed in to change notification settings - Fork 2
/
MainPage.xaml.cs
48 lines (39 loc) · 1.12 KB
/
MainPage.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using Syncfusion.Maui.Gauges;
namespace CustomScale;
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
}
public class RadialAxisExt : RadialAxis
{
int labelsCount = 0;
protected override List<GaugeLabelInfo> GenerateVisibleLabels()
{
List<GaugeLabelInfo> customLabels = new List<GaugeLabelInfo>();
var _minimum = (int)logBase(this.Minimum, 10);
var _maximum = (int)logBase(this.Maximum, 10);
for (var i = _minimum; i <= _maximum; i++)
{
int value = (int)Math.Floor(Math.Pow(10, i));// logBase value is 10
GaugeLabelInfo label = new GaugeLabelInfo
{
Value = value,
Text = value.ToString()
};
customLabels.Add(label);
}
labelsCount = customLabels.Count;
return customLabels;
}
double logBase(double value, double baseValue)
{
return Math.Log(value) / Math.Log(baseValue);
}
public override double ValueToFactor(double value)
{
return logBase(value, 10) / (labelsCount - 1);
}
}