Initial Commit

This commit is contained in:
2024-02-23 00:46:06 -05:00
commit 2bbedc0178
470 changed files with 46035 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using Microsoft.Research.DynamicDataDisplay.Charts.Axes;
namespace Microsoft.Research.DynamicDataDisplay.Charts
{
public abstract class NumericLabelProviderBase : LabelProviderBase<double>
{
bool shouldRound = true;
private int rounding;
protected void Init(double[] ticks)
{
if (ticks.Length == 0)
return;
double start = ticks[0];
double finish = ticks[ticks.Length - 1];
if (start == finish)
{
shouldRound = false;
return;
}
double delta = finish - start;
rounding = (int)Math.Round(Math.Log10(delta));
double newStart = RoundingHelper.Round(start, rounding);
double newFinish = RoundingHelper.Round(finish, rounding);
if (newStart == newFinish)
rounding--;
}
protected override string GetStringCore(LabelTickInfo<double> tickInfo)
{
string res;
if (!shouldRound)
{
res = tickInfo.Tick.ToString();
}
else
{
int round = Math.Min(15, Math.Max(-15, rounding - 3)); // was rounding - 2
res = RoundingHelper.Round(tickInfo.Tick, round).ToString();
}
return res;
}
}
}