In my previous post How to hide gridlines in charts, I showed how you can accomplish the task from XAML. This is all good when you know that rendering behavior of you chart is not going to change or you do not have to modify the display at run time based on some computed values curing run time. And works great for design time as well. But a lot of time you want to change the behavior at run time. In that case you need to know how you can change properties of axis programatically.
Each chart has a collection of Axis. By default this collection is empty. Charting controll fills this collection if you do not provide any. And it makes it decision based on the type of values you render on these axis. For example tf you are displaying DateTime type values on an axis, control will add DateTimeAxis to its collection. I have two liner axis in my chart that display simple numeric values. Following code shows how I added two linear axis, X and Y, to my chart. Most important property to set is Orientation. Without it, rendering engine does not know what axis you intend to change.
private void SetYAxis()
{
var lax = new LinearAxis();
lax.ShowGridLines = false;
lax.Orientation = AxisOrientation.Y;
lax.Title = "Response Time";
myChart.Axes.Add(lax);
}
private void SetXAxis()
{
var lax = new LinearAxis()
{
ShowGridLines = false,
Title = "Interval",
FontWeight = FontWeights.Bold,
MaxHeight = 1,
Opacity = 0,
Orientation = AxisOrientation.X
};
myChart.Axes.Add(lax);
}
How to set axis properties programatically for Silverlight charts
Automatically implemented properties must define both get and set accessors
How to plan CCSP Exam preparation
Develop a MongoDB pipeline to transform data into time buckets
Alert and Confirm pop up using BootBox in AngularJS
AngularJS Grouped Bar Chart and Line Chart using D3
How to lock and unlock account in Asp.Net Identity provider
2024 © Byteblocks, ALL Rights Reserved. Privacy Policy | Terms of Use