Posted 28 November 2024, 5:56 am EST
Hello Hai,
Calculating the bounds for a DataLabel includes complex calculations. So, it takes time to render 24*2000 labels at once.
As a workaround, you can display the labels only after the AxisScrollBar is added to the chart and use the mouse events on the AxisScrollBar’s range slider to display labels only when the user has scrolled the chart as follows:
//x - axis scrollbar
AxisScrollbar scroll = null!;
_chart.Rendering += (sender, e) =>
{
if(scroll == null)
{
scroll = new AxisScrollbar(_chart.AxisX)
{
UpperValue = 20
};
//Workaround
new Task(async () =>
{
await Task.Delay(1);
_chart.DataLabel.Position = C1.Chart.LabelPosition.Top;
}).RunSynchronously();
var down = false;
scroll.Controls[0].MouseDown += (s, ev) =>
{
down = true;
};
scroll.Controls[0].MouseMove += (s, ev) =>
{
if (down)
_chart.DataLabel.Position = C1.Chart.LabelPosition.None;
};
scroll.Controls[0].MouseUp += (s, ev) =>
{
_chart.DataLabel.Position = C1.Chart.LabelPosition.Top;
down = false;
};
}
};
Please refer to the attached sample for implementation. (see FlexChart_Sample.zip)
Regards,
Uttkarsh.