Xamarin.forms Teechart轴。底部。最小值和最大值不适用于蜡烛?
我正在使用Teechart进行Xamarin表单。我希望能够在图表缩放后调整图表蜡烛的大小,这样它们之间就不会有太大的空间。.Zoom事件有一个问题没有触发,但是Steema团队在我报告后很快就解决了。现在还有另一个问题- 当我使用下面的代码时,我得到一个异常-tChart1.Axes.Bottom.Maximum和tChart1.Axes.Bottom.Minimum没有为蜡烛返回正确的值Xamarin.forms Teechart轴。底部。最小值和最大值不适用于蜡烛?,xamarin.forms,teechart,Xamarin.forms,Teechart,我正在使用Teechart进行Xamarin表单。我希望能够在图表缩放后调整图表蜡烛的大小,这样它们之间就不会有太大的空间。.Zoom事件有一个问题没有触发,但是Steema团队在我报告后很快就解决了。现在还有另一个问题- 当我使用下面的代码时,我得到一个异常-tChart1.Axes.Bottom.Maximum和tChart1.Axes.Bottom.Minimum没有为蜡烛返回正确的值 public class App : Application { public double t
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的评论中:
我能想到的最简单的选项是设置tChart1.Touch.Style=touchtyle.FullChart;。有关更多信息,请访问
由于该阶段尚未绘制系列,轴值可能尚未初始化,因此没有有效值。你试过在TChart.AfterDraw事件上使用该代码吗?行为类似,但我开始认为,即使我成功了,这也不是控制蜡烛大小的正确方法。teechart是否提供了任何方法,使蜡烛宽度随着缩放级别的增加而增加,以便在放大时不会出现较大的空白?我能想到的最简单的选项是设置tChart1.Touch.Style=touchtyle.FullChart;。有关更多信息,请访问