简体   繁体   English

C# Winforms Livecharts:CartesianChart 渲染完成时触发事件

[英]C# Winforms Livecharts: Fire Event when rendering of CartesianChart is finished

I am using LiveCharts.WinForms.CartesianChart to render a large amount of points:我正在使用LiveCharts.WinForms.CartesianChart来渲染大量的点:

myChart.Zoom = ZoomingOptions.X;
myChart.Pan = PanningOptions.X;

myChart.Series.Add(new LineSeries
{
    Values = chartValuesScores,
    Fill = System.Windows.Media.Brushes.Transparent,
    PointGeometrySize = 5
});
myChart.AxisX.Add(new Axis
{
    Labels = labels
});

What I want to do is to display some kind of a progressbar and stop the time LiveCharts needs to render this points.我想要做的是显示某种进度条并停止LiveCharts需要渲染这些点的时间。 But it seems that LiveCharts renders the points asynchronously.但似乎LiveCharts异步渲染点。 That means that after running the code above, it continues running other code lines and exits the function.这意味着在运行上面的代码后,它会继续运行其他代码行并退出该函数。 Thus, my question is: Is there a way to detect that LiveCharts.WinForms.CartesianChart is finished with rendering?因此,我的问题是:有没有办法检测LiveCharts.WinForms.CartesianChart是否已完成渲染? I could not find an event or something else.我找不到活动或其他东西。

I found this while checking the docs: https://lvcharts.net/App/examples/v1/wpf/Events我在检查文档时发现了这一点: https : //lvcharts.net/App/examples/v1/wpf/Events

It lists Chart.UpdaterTick as one of the events.它将Chart.UpdaterTick列为事件之一。 That events seems to fire when the graph has finished loading the data and had rendered it on screen, I believe what you were looking for?当图表完成加载数据并将其呈现在屏幕上时,该事件似乎会触发,我相信您在寻找什么?

I've tested myself and appears to work as I expect.我已经对自己进行了测试,并且似乎按我的预期工作。

There is an CartesianChart.Loaded event, which is fired after the chart is rendered.有一个CartesianChart.Loaded事件,它在图表呈现后触发。

myChart.Loaded += myChart_Loaded;

private void myChart_Loaded(object sender, RoutedEventArgs e)
{
    // chart is rendered
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM