Hi Marco,
Thank you for writing.
Indeed, the label interval is not automatically adjusted depending on the available space. You can, however, achieve a similar result as the one required by calculating the interval depending on the viewport`s width. Please check my code snippet below:
public
partial
class
Form1 : Form
{
private
int
step = 100;
public
Form1()
{
InitializeComponent();
LineSeries lineSeries =
new
LineSeries();
Random r =
new
Random();
for
(
int
i = 0; i < 100; i++)
{
lineSeries.DataPoints.Add(
new
CategoricalDataPoint(i * r.Next(100), DateTime.Now.AddDays(i)));
}
DateTimeContinuousAxis continuousAxis =
new
DateTimeContinuousAxis();
continuousAxis.PlotMode = AxisPlotMode.OnTicksPadded;
continuousAxis.LabelFitMode = AxisLabelFitMode.Rotate;
continuousAxis.LabelInterval = 8;
continuousAxis.LabelRotationAngle = 90;
lineSeries.HorizontalAxis = continuousAxis;
this
.radChartView1.Series.Add(lineSeries);
this
.radChartView1.SizeChanged += radChartView1_SizeChanged;
}
private
void
radChartView1_SizeChanged(
object
sender, EventArgs e)
{
DateTimeContinuousAxis axis = radChartView1.Axes[0]
as
DateTimeContinuousAxis;
int
diff = (
int
)radChartView1.View.Viewport.Width -
this
.step;
if
(diff > 100 && axis.LabelInterval > 1)
{
axis.LabelInterval -= 1;
this
.step = (
int
)radChartView1.View.Viewport.Width;
}
else
if
(diff < -100)
{
axis.LabelInterval += 1;
this
.step = (
int
)radChartView1.View.Viewport.Width;
}
}
}
I am also sending you a short video showing the result on my end.
I hope this helps. Should you have further questions please do not hesitate to write back.
Regards,
Hristo Merdjanov
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms. For more information check out this
blog post and share your thoughts.