Hello,
how can I hide the x Axis empty space between the chart and the scroll bar?
Hello Markus,
From the attached screenshot, I am rather curious how you are going about hiding your X axis for your XamDataChart, but from how it looks, it looks like you are setting the Visibility property of the axis itself, which would still accommodate some room for where the labels would be on your x axis. Although, unless you were setting a label extent or something along those lines, I can't see why the space would be so much.
If this is the case, and you are setting the Visibility property on your axis, I would recommend writing a new AxisLabelSettings object for your axis instead and setting the Visibility property to "Collapsed" there. This will eliminate the space allotted for the x axis labels. Assuming you are using the CategoryXAxis, sample code for this could look like the following:
<ig:CategoryXAxis><ig:CategoryXAxis.LabelSettings><ig:AxisLabelSettings Visibility="Collapsed" />
I hope this helps. Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate Developer
Thank you for your answer. I am creating the chart series in code, and cannot set the .LabelSettings.Visibility, because I get an exception that is in a read only mode.
Here is the code snipped:
private void SetChart(XamDataChart chart) { var data = CreateData(); var xAxis = new CategoryXAxis(); var yAxis = new NumericYAxis(); xAxis.ItemsSource = data; chart.HorizontalZoomable = true; chart.HorizontalZoombarVisibility = Visibility.Visible; var series = new LineSeries(); series.ItemsSource = data; series.XAxis = xAxis; series.YAxis = yAxis; series.MarkerType = MarkerType.None; chart.Series.Add(series); chart.Axes.Add(xAxis); chart.Axes.Add(yAxis); //Throws exception: Cannot set property on object '.AxisLabelSettings' because it is in a read only state. //xAxis.LabelSettings.Visibility = Visibility.Collapsed; chart.WindowRect = new Rect(0.25, 1, 0.1, 1); }
Attached is the whole sample project.
The AxisLabelSettings object implements the abstract class Freezable, and when in use, this object is frozen. This means that each of the properties that exist on the LabelSettings property of an axis cannot be modified directly. Instead of modifying the visibility like you are currently doing, I would recommend using the following code instead:
AxisLabelSettings settings = new AxisLabelSettings(){ Visibility = Visibility.Collapsed};xAxis.LabelSettings = settings;
I have verified that this works to significantly reduce the space between your XAxis and the zoom bar of the XamDataChart in the sample project you have sent.
Please let me know if you have any other questions or concerns on this matter.