gpt4 book ai didi

c# - WPF:放大 Scichart 图表上的前 3 个点

转载 作者:行者123 更新时间:2023-11-30 22:08:29 36 4
gpt4 key购买 nike

我的图表运行良好,它绘制了我需要的 11 个点,就像它应该的那样。但是,情节一出现,我就特别对前 3 点感兴趣。我想知道是否有一种方法可以让图表自动放大到绘制的前 3 个点,而不是在过程完成时查看图表的全尺寸 View 。这是 xaml:

<SciChart:SciChartSurface x:Name="sciChart" 
Grid.Row="6"
SciChart:RenderSurfaceBase.RenderSurfaceType="Abt.Controls.SciChart.Rendering.HighQualityRasterizer.HighQualityRenderSurface"
SciChart:ThemeManager.Theme="BlackSteel"
Margin="-23,-2,-8,-18" Grid.ColumnSpan="6" Loaded="sciChart_Loaded">

<!-- Declare RenderableSeries -->
<SciChart:SciChartSurface.RenderableSeries>
<SciChart:FastLineRenderableSeries SeriesColor="LightBlue" StrokeThickness="2">
<SciChart:FastLineRenderableSeries.PointMarker>
<SciChart:EllipsePointMarker Width="9" Height="9" Stroke="LightBlue" Fill="#990077FF" StrokeThickness="2"/>
</SciChart:FastLineRenderableSeries.PointMarker>
</SciChart:FastLineRenderableSeries>
</SciChart:SciChartSurface.RenderableSeries>

<!-- Declare Axes -->
<SciChart:SciChartSurface.XAxis>
<SciChart:TimeSpanAxis AxisTitle="Time" GrowBy="0.1, 0.1" DrawMajorGridLines="True" DrawMinorGridLines="True" DrawMajorTicks="True" DrawMinorTicks="True" />
</SciChart:SciChartSurface.XAxis>

<SciChart:SciChartSurface.YAxis>
<SciChart:NumericAxis AxisAlignment="Left" AxisTitle=" % in Profit" GrowBy="0.1, 0.1" DrawMajorGridLines="True" DrawMinorGridLines="True" DrawMajorTicks="True" DrawMinorTicks="True"/>
</SciChart:SciChartSurface.YAxis>

是否可以使用 Scichart 的图表来做到这一点?

最佳答案

是的,您可以直接在 SciChartSurface 上操作 XAxis.VisibleRange。为此,只需使用这样的代码

// Create your Data Series
var xyDataSeries = new XyDataSeries<TimeSpan, double>();

// Append some values
xyDataSeries.Append(TimeSpan.FromSeconds(0), 0);
xyDataSeries.Append(TimeSpan.FromSeconds(1), 1);
xyDataSeries.Append(TimeSpan.FromSeconds(2), 2);
// ...
xyDataSeries.Append(TimeSpan.FromSeconds(11), 11);

// Set the XyDataSeries on the RenderableSeries
// Assumes chart is created as per your XAML above
sciChart.RenderableSeries[0].DataSeries = xyDataSeries;

// Zoom XAxis to fit first three points
var xRange = new TimeSpanRange(xyDataSeries.XValues[0], xyDataSeries.XValues[2]);
sciChart.XAxis.VisibleRange = xRange;

// Zoom to fit in Y direction
sciChart.ZoomExtentsY();

希望这对您有所帮助!

披露:我是 SciChart WPF Charts 的总经理和所有者

关于c# - WPF:放大 Scichart 图表上的前 3 个点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22254900/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com