Logarithmic Axis on Visiblox

2019-08-16 04:20发布

问题:

I'm having trouble setting the range of an axis so that the minimum is below 1. I understand that no value less than 0 can be plotted by I don't understand why values below 1 cannot be viewed unless I can pan to them. Is there any reason for this? Or a way of resolving it?

回答1:

While this may be as designed, you could still achieve the affect you're looking for by scaling your data up into the valid range for the logarithmic axis. Then you could override the label function to set the labels you want. It's hacky, but it might work for your needs.

class MyLogarithmicAxis : LogarithmicAxis
{
    protected override string GetFormattedDataValueInternal(double dataValue, string formatString)
    {
        if (dataValue == 1)
        {
            dataValue = .1;
        }
        if (dataValue == 100)
        {
            dataValue = 10;
        }
        if (dataValue == 1000)
        {
            dataValue = 100;
        }

        return base.GetFormattedDataValueInternal(dataValue, formatString);
    }
}