windowsforms-17217-controls-and-libraries-chart-control-examples-chart-elements-how-to-show-numerical-data-using-a-logarithmic-scale.md
This example demonstrates how to use a logarithmic scale in XtraCharts, which is disabled by default.
Note
The logarithmic scale is only compatible with the numerical scale type.
To enable it, simply set the AxisBase.Logarithmic property to true , and set the AxisBase.LogarithmicBase property to the value required in your scenario.
using System;
using System.Windows.Forms;
using DevExpress.XtraCharts;
namespace LogarithmicScale {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
private void btnLogarithm10_Click(object sender, EventArgs e) {
AxisY axis = ((XYDiagram)chartControl1.Diagram).AxisY;
axis.Logarithmic = true;
axis.LogarithmicBase = 10;
axis.WholeRange.AlwaysShowZeroLevel = false;
}
private void btnLogarithm100_Click(object sender, EventArgs e) {
AxisY axis = ((XYDiagram)chartControl1.Diagram).AxisY;
axis.Logarithmic = true;
axis.LogarithmicBase = 100;
axis.WholeRange.AlwaysShowZeroLevel = false;
}
private void btnDisableLogarithm_Click(object sender, EventArgs e) {
AxisY axis = ((XYDiagram)chartControl1.Diagram).AxisY;
axis.Logarithmic = false;
axis.WholeRange.AlwaysShowZeroLevel = true;
}
}
}
Imports System
Imports System.Windows.Forms
Imports DevExpress.XtraCharts
Namespace LogarithmicScale
Partial Public Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
End Sub
Private Sub btnLogarithm10_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnLogarithm10.Click
Dim axis As AxisY = CType(chartControl1.Diagram, XYDiagram).AxisY
axis.Logarithmic = True
axis.LogarithmicBase = 10
axis.WholeRange.AlwaysShowZeroLevel = False
End Sub
Private Sub btnLogarithm100_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnLogarithm100.Click
Dim axis As AxisY = CType(chartControl1.Diagram, XYDiagram).AxisY
axis.Logarithmic = True
axis.LogarithmicBase = 100
axis.WholeRange.AlwaysShowZeroLevel = False
End Sub
Private Sub btnDisableLogarithm_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnDisableLogarithm.Click
Dim axis As AxisY = CType(chartControl1.Diagram, XYDiagram).AxisY
axis.Logarithmic = False
axis.WholeRange.AlwaysShowZeroLevel = True
End Sub
End Class
End Namespace