Logarithmic axis in Vue 3D Chart component
13 Jun 202424 minutes to read
Logarithmic axis uses logarithmic scale and it is very useful in visualizing data, when it has numerical values in both lower order of magnitude (eg: 10-6) and higher order of magnitude (eg: 106).
<template>
<div id="app">
<ejs-chart3d id="container" :primaryXAxis="primaryXAxis" :primaryYAxis="primaryYAxis" :wallColor='wallColor'
:enableRotation='enableRotation' :rotation='rotation' :tilt='tilt' :depth='depth'>
<e-chart3d-series-collection>
<e-chart3d-series :dataSource="seriesData" type="Column" xName="x" yName="y"></e-chart3d-series>
</e-chart3d-series-collection>
</ejs-chart3d>
</div>
</template>
<script setup>
import { provide } from "vue";
import { Chart3DComponent as EjsChart3d, Chart3DSeriesCollectionDirective as EChart3dSeriesCollection, Chart3DSeriesDirective as EChart3dSeries, ColumnSeries3D, DateTime3D, Logarithmic3D } from '@syncfusion/ej2-vue-charts';
const seriesData = [
{ x: new Date(1995, 0, 1), y: 80 }, { x: new Date(1996, 0, 1), y: 200 },
{ x: new Date(1997, 0, 1), y: 400 }, { x: new Date(1998, 0, 1), y: 600 },
{ x: new Date(1999, 0, 1), y: 700 }, { x: new Date(2000, 0, 1), y: 1400 },
{ x: new Date(2001, 0, 1), y: 2000 }, { x: new Date(2002, 0, 1), y: 4000 },
{ x: new Date(2003, 0, 1), y: 6000 }, { x: new Date(2004, 0, 1), y: 8000 },
{ x: new Date(2005, 0, 1), y: 11000 }
];
const primaryXAxis = {
valueType: 'DateTime'
};
const primaryYAxis = {
valueType: 'Logarithmic'
};
const wallColor = 'transparent';
const enableRotation = true;
const rotation = 7;
const tilt = 10;
const depth = 100;
provide('chart3d', [ColumnSeries3D, DateTime3D, Logarithmic3D]);
</script>
<style>
#container {
height: 350px;
}
</style><template>
<div id="app">
<ejs-chart3d id="container" :primaryXAxis="primaryXAxis" :primaryYAxis="primaryYAxis" :wallColor='wallColor'
:enableRotation='enableRotation' :rotation='rotation' :tilt='tilt' :depth='depth'>
<e-chart3d-series-collection>
<e-chart3d-series :dataSource="seriesData" type="Column" xName="x" yName="y"></e-chart3d-series>
</e-chart3d-series-collection>
</ejs-chart3d>
</div>
</template>
<script>
import { Chart3DComponent, Chart3DSeriesCollectionDirective, Chart3DSeriesDirective, ColumnSeries3D, DateTime3D, Logarithmic3D } from '@syncfusion/ej2-vue-charts';
export default {
name: "App",
components: {
'ejs-chart3d': Chart3DComponent,
'e-chart3d-series-collection': Chart3DSeriesCollectionDirective,
'e-chart3d-series': Chart3DSeriesDirective
},
data() {
return {
seriesData: [
{ x: new Date(1995, 0, 1), y: 80 }, { x: new Date(1996, 0, 1), y: 200 },
{ x: new Date(1997, 0, 1), y: 400 }, { x: new Date(1998, 0, 1), y: 600 },
{ x: new Date(1999, 0, 1), y: 700 }, { x: new Date(2000, 0, 1), y: 1400 },
{ x: new Date(2001, 0, 1), y: 2000 }, { x: new Date(2002, 0, 1), y: 4000 },
{ x: new Date(2003, 0, 1), y: 6000 }, { x: new Date(2004, 0, 1), y: 8000 },
{ x: new Date(2005, 0, 1), y: 11000 }
],
primaryXAxis: {
valueType: 'DateTime'
},
primaryYAxis: {
valueType: 'Logarithmic'
},
wallColor: 'transparent',
enableRotation: true,
rotation: 7,
tilt: 10,
depth: 100
};
},
provide: {
chart3d: [ColumnSeries3D, DateTime3D, Logarithmic3D]
}
};
</script>
<style>
#container {
height: 350px;
}
</style>Note: To use logarithmic axis, we need to inject
Logarithmic3Dinto theprovideand set thevalueTypeof the axis to Logarithmic.
Range
The range of an axis will be calculated automatically based on the provided data and it can also be customized by using the minimum, maximum and interval properties of the axis.
<template>
<div id="app">
<ejs-chart3d id="container" :primaryXAxis="primaryXAxis" :primaryYAxis="primaryYAxis" :wallColor='wallColor'
:enableRotation='enableRotation' :rotation='rotation' :tilt='tilt' :depth='depth'>
<e-chart3d-series-collection>
<e-chart3d-series :dataSource="seriesData" type="Column" xName="x" yName="y"></e-chart3d-series>
</e-chart3d-series-collection>
</ejs-chart3d>
</div>
</template>
<script setup>
import { provide } from "vue";
import { Chart3DComponent as EjsChart3d, Chart3DSeriesCollectionDirective as EChart3dSeriesCollection, Chart3DSeriesDirective as EChart3dSeries, ColumnSeries3D, DateTime3D, Logarithmic3D } from '@syncfusion/ej2-vue-charts';
const seriesData = [
{ x: new Date(1995, 0, 1), y: 80 }, { x: new Date(1996, 0, 1), y: 200 },
{ x: new Date(1997, 0, 1), y: 400 }, { x: new Date(1998, 0, 1), y: 600 },
{ x: new Date(1999, 0, 1), y: 700 }, { x: new Date(2000, 0, 1), y: 1400 },
{ x: new Date(2001, 0, 1), y: 2000 }, { x: new Date(2002, 0, 1), y: 4000 },
{ x: new Date(2003, 0, 1), y: 6000 }, { x: new Date(2004, 0, 1), y: 8000 },
{ x: new Date(2005, 0, 1), y: 11000 }
];
const primaryXAxis = {
valueType: 'DateTime'
};
const primaryYAxis = {
valueType: 'Logarithmic',
minimum: 100,
maximum: 10000,
interval: 1000
};
const wallColor = 'transparent';
enableRotation = true;
rotation = 7;
tilt = 10;
depth = 100;
provide('chart3d', [ColumnSeries3D, DateTime3D, Logarithmic3D]);
</script>
<style>
#container {
height: 350px;
}
</style><template>
<div id="app">
<ejs-chart3d id="container" :primaryXAxis="primaryXAxis" :primaryYAxis="primaryYAxis" :wallColor='wallColor'
:enableRotation='enableRotation' :rotation='rotation' :tilt='tilt' :depth='depth'>
<e-chart3d-series-collection>
<e-chart3d-series :dataSource="seriesData" type="Column" xName="x" yName="y"></e-chart3d-series>
</e-chart3d-series-collection>
</ejs-chart3d>
</div>
</template>
<script>
import { Chart3DComponent, Chart3DSeriesCollectionDirective, Chart3DSeriesDirective, ColumnSeries3D, DateTime3D, Logarithmic3D } from '@syncfusion/ej2-vue-charts';
export default {
name: "App",
components: {
'ejs-chart3d': Chart3DComponent,
'e-chart3d-series-collection': Chart3DSeriesCollectionDirective,
'e-chart3d-series': Chart3DSeriesDirective
},
data() {
return {
seriesData: [
{ x: new Date(1995, 0, 1), y: 80 }, { x: new Date(1996, 0, 1), y: 200 },
{ x: new Date(1997, 0, 1), y: 400 }, { x: new Date(1998, 0, 1), y: 600 },
{ x: new Date(1999, 0, 1), y: 700 }, { x: new Date(2000, 0, 1), y: 1400 },
{ x: new Date(2001, 0, 1), y: 2000 }, { x: new Date(2002, 0, 1), y: 4000 },
{ x: new Date(2003, 0, 1), y: 6000 }, { x: new Date(2004, 0, 1), y: 8000 },
{ x: new Date(2005, 0, 1), y: 11000 }
],
primaryXAxis: {
valueType: 'DateTime'
},
primaryYAxis: {
valueType: 'Logarithmic',
minimum: 100,
maximum: 10000,
interval: 1000
},
wallColor: 'transparent',
enableRotation: true,
rotation: 7,
tilt: 10,
depth: 100
};
},
provide: {
chart3d: [ColumnSeries3D, DateTime3D, Logarithmic3D]
}
};
</script>
<style>
#container {
height: 350px;
}
</style>Logarithmic base
Logarithmic base can be customized by using the logBase property of the axis. For example when the logBase is 5, the axis values follows 5-2, 5-1, 50, 51, 52 etc.
<template>
<div id="app">
<ejs-chart3d id="container" :primaryXAxis="primaryXAxis" :primaryYAxis="primaryYAxis" :wallColor='wallColor'
:enableRotation='enableRotation' :rotation='rotation' :tilt='tilt' :depth='depth'>
<e-chart3d-series-collection>
<e-chart3d-series :dataSource="seriesData" type="Column" xName="x" yName="y" columnSpacing=0.1></e-chart3d-series>
</e-chart3d-series-collection>
</ejs-chart3d>
</div>
</template>
<script setup>
import { provide } from "vue";
import { Chart3DComponent as EjsChart3d, Chart3DSeriesCollectionDirective as EChart3dSeriesCollection, Chart3DSeriesDirective as EChart3dSeries, ColumnSeries3D, DateTime3D, Logarithmic3D } from '@syncfusion/ej2-vue-charts';
const seriesData = [
{ x: new Date(1995, 0, 1), y: 80 }, { x: new Date(1996, 0, 1), y: 200 },
{ x: new Date(1997, 0, 1), y: 400 }, { x: new Date(1998, 0, 1), y: 600 },
{ x: new Date(1999, 0, 1), y: 700 }, { x: new Date(2000, 0, 1), y: 1400 },
{ x: new Date(2001, 0, 1), y: 2000 }, { x: new Date(2002, 0, 1), y: 4000 },
{ x: new Date(2003, 0, 1), y: 6000 }, { x: new Date(2004, 0, 1), y: 8000 },
{ x: new Date(2005, 0, 1), y: 11000 }
];
const primaryXAxis = {
valueType: 'DateTime'
};
const primaryYAxis = {
valueType: 'Logarithmic',
logBase: 2
};
const wallColor = 'transparent';
const enableRotation = true;
const rotation = 7;
const tilt = 10;
const depth = 100;
provide('chart3d', [ColumnSeries3D, DateTime3D, Logarithmic3D]);
</script>
<style>
#container {
height: 350px;
}
</style><template>
<div id="app">
<ejs-chart3d id="container" :primaryXAxis="primaryXAxis" :primaryYAxis="primaryYAxis" :wallColor='wallColor'
:enableRotation='enableRotation' :rotation='rotation' :tilt='tilt' :depth='depth'>
<e-chart3d-series-collection>
<e-chart3d-series :dataSource="seriesData" type="Column" xName="x" yName="y" columnSpacing=0.1></e-chart3d-series>
</e-chart3d-series-collection>
</ejs-chart3d>
</div>
</template>
<script>
import { Chart3DComponent, Chart3DSeriesCollectionDirective, Chart3DSeriesDirective, ColumnSeries3D, DateTime3D, Logarithmic3D } from '@syncfusion/ej2-vue-charts';
export default {
name: "App",
components: {
'ejs-chart3d': Chart3DComponent,
'e-chart3d-series-collection': Chart3DSeriesCollectionDirective,
'e-chart3d-series': Chart3DSeriesDirective
},
data() {
return {
seriesData: [
{ x: new Date(1995, 0, 1), y: 80 }, { x: new Date(1996, 0, 1), y: 200 },
{ x: new Date(1997, 0, 1), y: 400 }, { x: new Date(1998, 0, 1), y: 600 },
{ x: new Date(1999, 0, 1), y: 700 }, { x: new Date(2000, 0, 1), y: 1400 },
{ x: new Date(2001, 0, 1), y: 2000 }, { x: new Date(2002, 0, 1), y: 4000 },
{ x: new Date(2003, 0, 1), y: 6000 }, { x: new Date(2004, 0, 1), y: 8000 },
{ x: new Date(2005, 0, 1), y: 11000 }
],
primaryXAxis: {
valueType: 'DateTime'
},
primaryYAxis: {
valueType: 'Logarithmic',
logBase: 2
},
wallColor: 'transparent',
enableRotation: true,
rotation: 7,
tilt: 10,
depth: 100
};
},
provide: {
chart3d: [ColumnSeries3D, DateTime3D, Logarithmic3D]
}
};
</script>
<style>
#container {
height: 350px;
}
</style>Logarithmic interval
The interval of the logarithmic axis can be customized by using the interval property in the axis. When the logarithmic base is 10 and logarithmic interval is 2, then the axis labels are placed at an interval of 102. The default value of the interval is 1.
<template>
<div id="app">
<ejs-chart3d id="container" :primaryXAxis="primaryXAxis" :primaryYAxis="primaryYAxis" :wallColor='wallColor'
:enableRotation='enableRotation' :rotation='rotation' :tilt='tilt' :depth='depth'>
<e-chart3d-series-collection>
<e-chart3d-series :dataSource="seriesData" type="Column" xName="x" yName="y"></e-chart3d-series>
</e-chart3d-series-collection>
</ejs-chart3d>
</div>
</template>
<script setup>
import { provide } from "vue";
import { Chart3DComponent as EjsChart3d, Chart3DSeriesCollectionDirective as EChart3dSeriesCollection, Chart3DSeriesDirective as EChart3dSeries, ColumnSeries3D, DateTime3D, Logarithmic3D } from '@syncfusion/ej2-vue-charts';
const seriesData = [
{ x: new Date(1995, 0, 1), y: 80 }, { x: new Date(1996, 0, 1), y: 200 },
{ x: new Date(1997, 0, 1), y: 400 }, { x: new Date(1998, 0, 1), y: 600 },
{ x: new Date(1999, 0, 1), y: 700 }, { x: new Date(2000, 0, 1), y: 1400 },
{ x: new Date(2001, 0, 1), y: 2000 }, { x: new Date(2002, 0, 1), y: 4000 },
{ x: new Date(2003, 0, 1), y: 6000 }, { x: new Date(2004, 0, 1), y: 8000 },
{ x: new Date(2005, 0, 1), y: 11000 }
];
const primaryXAxis = {
valueType: 'DateTime'
};
const primaryYAxis = {
valueType: 'Logarithmic',
interval: 2
};
const wallColor = 'transparent';
const enableRotation = true;
const rotation = 7;
const tilt = 10;
const depth = 100;
provide('chart3d', [ColumnSeries3D, DateTime3D, Logarithmic3D]);
</script>
<style>
#container {
height: 350px;
}
</style><template>
<div id="app">
<ejs-chart3d id="container" :primaryXAxis="primaryXAxis" :primaryYAxis="primaryYAxis" :wallColor='wallColor'
:enableRotation='enableRotation' :rotation='rotation' :tilt='tilt' :depth='depth'>
<e-chart3d-series-collection>
<e-chart3d-series :dataSource="seriesData" type="Column" xName="x" yName="y"></e-chart3d-series>
</e-chart3d-series-collection>
</ejs-chart3d>
</div>
</template>
<script>
import { Chart3DComponent, Chart3DSeriesCollectionDirective, Chart3DSeriesDirective, ColumnSeries3D, DateTime3D, Logarithmic3D } from '@syncfusion/ej2-vue-charts';
export default {
name: "App",
components: {
'ejs-chart3d': Chart3DComponent,
'e-chart3d-series-collection': Chart3DSeriesCollectionDirective,
'e-chart3d-series': Chart3DSeriesDirective
},
data() {
return {
seriesData: [
{ x: new Date(1995, 0, 1), y: 80 }, { x: new Date(1996, 0, 1), y: 200 },
{ x: new Date(1997, 0, 1), y: 400 }, { x: new Date(1998, 0, 1), y: 600 },
{ x: new Date(1999, 0, 1), y: 700 }, { x: new Date(2000, 0, 1), y: 1400 },
{ x: new Date(2001, 0, 1), y: 2000 }, { x: new Date(2002, 0, 1), y: 4000 },
{ x: new Date(2003, 0, 1), y: 6000 }, { x: new Date(2004, 0, 1), y: 8000 },
{ x: new Date(2005, 0, 1), y: 11000 }
],
primaryXAxis: {
valueType: 'DateTime'
},
primaryYAxis: {
valueType: 'Logarithmic',
interval: 2
},
wallColor: 'transparent',
enableRotation: true,
rotation: 7,
tilt: 10,
depth: 100
};
},
provide: {
chart3d: [ColumnSeries3D, DateTime3D, Logarithmic3D]
}
};
</script>
<style>
#container {
height: 350px;
}
</style>