C#에서 구현을 제공하는 데 도움이 될 수 있습니다. Y 축의 값이 음수 인 경우 샘플이 작동하지 않을 수 있습니다. 희망은 누군가를 돕는다!
private double GetMajorStep(double yAxisMax)
{
int[] stepArray = {1, 2, 5, 10, 20, 25, 50, 75, 100, 200, 250, 500, 750, 1000, 2000, 2500, 5000, 7500, 10000, 20000, 50000,100000, 500000,1000000};
const int numLabels = 2;
var stepSize = (int) (yAxisMax/(numLabels - 1));
var possibleSteps = stepArray.Where(p => p < stepSize).ToList();
if (!possibleSteps.Any()) return stepSize;
var nearest = possibleSteps.OrderBy(x => Math.Abs((long)x - stepSize)).First();
return nearest;
}