Teechart Axes.Bottom.Minimum 和 Maximum 不适用于蜡烛?

Teechart Axes.Bottom.Minimum and Maximum not working for candles?

我正在为 Xamarin 表单使用 Teechart。我希望能够在图表缩放后调整图表蜡烛的大小,以便它们之间的空间不大。 .Zoomed 事件有一个问题没有触发,但 Steema 团队在我报告后很快就修复了它。现在还有一个问题—— 当我使用下面的代码时,出现异常 - tChart1.Axes.Bottom.MaximumtChart1.Axes.Bottom.Minimum 没有为蜡烛返回正确的值。

public class App : Application
{
    public double tChartMax;
    public double tChartMin;
    public Steema.TeeChart.Chart tChart1;
    public Steema.TeeChart.Styles.Candle tSeries;

    double widthRatio;
    int origCandleWidth;


    public App ()
    {
        var tChart1 = new Steema.TeeChart.Chart ();

        var tSeries = new Steema.TeeChart.Styles.Candle ();
        tSeries.FillSampleValues (30);
        tChart1.Series.Add (tSeries);
        tChart1.Aspect.View3D = false;

        ChartView chartView = new ChartView {
            VerticalOptions = LayoutOptions.FillAndExpand,
            HorizontalOptions = LayoutOptions.FillAndExpand,

            WidthRequest = 400,
            HeightRequest = 500
        };

        tChart1.UndoneZoom += (object sender, EventArgs e) => {
            tSeries.Color = Color.Black;
            //double range = tChart1.Axes.Bottom.Maximum - tChart1.Axes.Bottom.Minimum;
        };

        tChart1.Zoomed += (object sender, EventArgs e) => {
            tSeries.Color = Color.Pink;
            tChartMax = tChart1.Axes.Bottom.Maximum;
            tChartMin = tChart1.Axes.Bottom.Minimum;
            double range = tChartMax - tChartMin;
        };


        tChart1.Zoomed += tChart1_Zoomed;
        tChart1.UndoneZoom += tChart1_UndoneZoom;
        tChart1.BeforeDrawSeries += tChart1_BeforeDrawSeries;

        origCandleWidth = tSeries.CandleWidth;
        widthRatio = (tChart1.Axes.Bottom.Maximum - tChart1.Axes.Bottom.Minimum) / origCandleWidth;


        chartView.Model = tChart1;

        MainPage = new ContentPage {
            Content = new StackLayout {
                Children = {
                    chartView,
                }
            },
        };
    }

    bool zoomed = false;
    void tChart1_UndoneZoom(object sender, EventArgs e)
    {
        zoomed = true;
    }

    void tChart1_Zoomed(object sender, EventArgs e)
    {
        zoomed = true;
    }

    void tChart1_BeforeDrawSeries(object sender, Graphics3D g)
    {
        if(zoomed)
        {
            double range = tChart1.Axes.Bottom.Maximum - tChart1.Axes.Bottom.Minimum;
            double tmpRatio = range / origCandleWidth;

            if (widthRatio > 0 && widthRatio != tmpRatio)
            {
                tSeries.CandleWidth = Utils.Round((widthRatio / tmpRatio) * origCandleWidth);
            }
            else
            {
                tSeries.CandleWidth = origCandleWidth;
            }
        }
        zoomed = false;
    }
}

这个问题的答案包含在 Narcis Calvet 发表的评论中:

The easiest option I can think of is setting tChart1.Touch.Style = TouchStyle.FullChart;. More info can be found at http://www.teechart.net/docs/teechart/net/libpcl/html/SteemaTeeChartTouchStyle.htm