

|
<chart:SfChart Grid.Row="1" Margin="20"
x:Name="chart" >
<chart:SfChart.PrimaryAxis>
<local:CustomNumericalAxis >
</local:CustomNumericalAxis>
</chart:SfChart.PrimaryAxis>
..
</chart:SfChart> |
|
public class CustomNumericalAxis :NumericalAxis
{
protected override void GenerateVisibleLabels()
{
DoubleRange range = VisibleRange;
double interval = (double)this.GetType().GetProperty("VisibleInterval", System.Reflection.BindingFlags.NonPublic |
System.Reflection.BindingFlags.Instance).GetValue(this);
double position = range.Start;
double previousPosition = double.NaN;
for (; position <= range.End; position += interval)
{
if (position == previousPosition)
break;
if (range.Inside(position))
{
VisibleLabels.Add(new ChartAxisLabel(position, GetActualLabelContent(position), position));
}
if (SmallTicksPerInterval>0)
{
AddSmallTicksPoint(position);
}
previousPosition = position;
}
if (((Maximum != null && range.End.Equals(Maximum))
|| EdgeLabelsVisibilityMode == EdgeLabelsVisibilityMode.AlwaysVisible
|| (EdgeLabelsVisibilityMode == EdgeLabelsVisibilityMode.Visible && ZoomFactor==0))
&& !range.End.Equals(position - interval))
{
VisibleLabels.Add(new ChartAxisLabel(range.End, GetActualLabelContent(range.End), range.End));
}
}
internal object GetActualLabelContent(double position)
{
return position.ToString(this.LabelFormat, CultureInfo.CurrentCulture);
}
} |
|
private void CustomNumericalAxis_LabelCreated(object sender, LabelCreatedEventArgs e)
{
e.AxisLabel.LabelContent = e.AxisLabel.LabelContent;
} |
|
<chart:SfChart.PrimaryAxis>
<local:CustomNumericalAxis
LabelCreated="CustomNumericalAxis_LabelCreated">
</local:CustomNumericalAxis>
</chart:SfChart.PrimaryAxis> |
|
<chart:SfChart.PrimaryAxis>
<local:CustomNumericalAxis LabelFormat="#.##E+0">
</local:CustomNumericalAxis>
</chart:SfChart.PrimaryAxis> |