corelibraries-devexpress-dot-xtracharts-dot-axisbase-ff26588d.md
Gets or sets whether the axis should display its numerical values using a logarithmic scale.
Namespace : DevExpress.XtraCharts
Assembly : DevExpress.XtraCharts.v25.2.dll
NuGet Package : DevExpress.Charts
[XtraChartsLocalizableCategory(XtraChartsCategory.Behavior)]
public virtual bool Logarithmic { get; set; }
<XtraChartsLocalizableCategory(XtraChartsCategory.Behavior)>
Public Overridable Property Logarithmic As Boolean
| Type | Description |
|---|---|
| Boolean |
true if the logarithmic scale should be used; otherwise, false.
|
If a chart’s series has its SeriesBase.ArgumentScaleType or SeriesBase.ValueScaleType properties set to ScaleType.Numerical, you can use the Logarithmic property to specify whether an axis should use the logarithmic scale to display axis values. When the Logarithmic property is set to true , you can also define a logarithmic base value using AxisBase.LogarithmicBase.
The axis forms its logarithmic scale as follows. The axis calculates a base axis value - minimum absolute value that is the power of the AxisBase.LogarithmicBase. These calculations are based on absolute values of data point values that the axis measures. Then, the axis marks positive and negative base values on the axis and next, positive and negative values that are the power of the AxisBase.LogarithmicBase. Note that if data point values do not contain positive or negative values, the appropriate semi axis is not plotted.
It is useful to employ the Logarithmic property when the data range of a chart’s series has significant disparity. By enabling this property, the chart’s numerical axes display all values using logarithmic equivalents. In short, if the logarithmic base is 10 , only 5 uniform axis steps will exist between 10 and 1,000,000.
The following table demonstrates how the Logarithmic property works.
|
Logarithmic = false;
|
Logarithmic = true;
LogarithmicBase = 10;
| | --- | --- | |
|
|
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, 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
See Also