Your search did not match any results.
Point Charts

Custom Axis Position

The Chart widget initially displays axes along pane borders. Several other predefined axis layout options are available. In this demo, the customPosition option is used to move each axis, so that it is displayed on the specified value of another axis. When you position the argument axis, use values from the value axis (in the same type and format) and vice versa.

Regardless of which automatic axis layout type you use, the Chart Control allows you to apply manual offsets. Specify the offset option in pixels to keep the axis position unchanged when users scroll or zoom the Chart data. The offset option shifts the axis from the specified position as follows:

  • If the axis is horizontal, a negative offset shifts the axis to the top, a positive offset shifts it to the bottom.

  • If the axis is vertical, a negative offset shifts the axis to the left, a positive offset shifts it to the right.

In this demo, you can use controls under the Chart to change the customPosition and offset options for both axes.

Copy to CodePen
Apply
Reset
$(function () { var chart = $("#chart").dxChart({ dataSource: generateDataSource(), commonSeriesSettings: { type: "scatter" }, series: [{ argumentField: "x1", valueField: "y1" }, { argumentField: "x2", valueField: "y2", point: { symbol: "triangleDown" } }], argumentAxis: { customPosition: 0, visualRange: [-20, 20], offset: 0, }, valueAxis: { customPosition: 0, endOnTick: false, visualRange: [-20, 20], offset: 0, }, legend: { visible: false } }).dxChart('instance'); $("#argumentCustomPosition").dxNumberBox({ value: 0, showSpinButtons: true, onValueChanged: function(e) { chart.option('argumentAxis.customPosition', e.value); } }); $("#argumentOffset").dxNumberBox({ value: 0, showSpinButtons: true, onValueChanged: function(e) { chart.option('argumentAxis.offset', e.value); } }); $("#valueCustomPosition").dxNumberBox({ value: 0, showSpinButtons: true, onValueChanged: function(e) { chart.option('valueAxis.customPosition', e.value); } }); $("#valueOffset").dxNumberBox({ value: 0, showSpinButtons: true, onValueChanged: function(e) { chart.option('valueAxis.offset', e.value); } }); });
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>DevExtreme Demo</title> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script>window.jQuery || document.write(decodeURIComponent('%3Cscript src="js/jquery.min.js"%3E%3C/script%3E'))</script> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/20.1.7/css/dx.common.css" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/20.1.7/css/dx.light.css" /> <script src="https://cdn3.devexpress.com/jslib/20.1.7/js/dx.all.js"></script> <script src="data.js"></script> <link rel="stylesheet" type="text/css" href="styles.css" /> <script src="index.js"></script> </head> <body class="dx-viewport"> <div class="demo-container"> <div id="chart"></div> <div class="options"> <div class="caption">Options</div> <div class="common"> <div class='block left'> <span>Argument Axis</span> <div class='option'> <span>Custom position:</span> <div id="argumentCustomPosition"></div> </div> <div class='option'> <span>Offset:</span> <div id="argumentOffset"></div> </div> </div> <div class='block right'> <span>Value Axis</span> <div class='option'> <span>Custom position:</span> <div id="valueCustomPosition"></div> </div> <div class='option'> <span>Offset:</span> <div id="valueOffset"></div> </div> </div> </div> </div> </div> </body> </html>
.options { padding: 20px; margin-top: 20px; background-color: rgba(191, 191, 191, 0.15); } .option { margin-top: 10px; overflow: auto; } .option > span { margin-right: 20px; margin-top: 6px; float: left; } .caption { font-size: 18px; font-weight: 700; } .option > .dx-numberbox { width: 90px; float: right; } .common { width: 488px; } .block { vertical-align: middle; margin-top: 10px; } .left { display: inline-block; } .right { float: right; } .block > span { font-size: 18px; font-weight: 500; }
function generateDataSource() { let x1, x2, y1, y2, i; const ds = []; for (i = 0; i < 20; i++) { x1 = random(5, 15); y1 = random(5, 15); ds.push({ x1: x1, y1: y1, x2: x2, y2: y2 }); } for (i = 0; i < 20; i++) { x2 = random(5, 15); y2 = random(-15, -5); ds.push({ x1: x1, y1: y1, x2: x2, y2: y2 }); } for (i = 0; i < 20; i++) { x2 = random(-15, -5); y2 = random(5, 15); ds.push({ x1: x1, y1: y1, x2: x2, y2: y2 }); } for (i = 0; i < 20; i++) { x1 = random(-15, -5); y1 = random(-15, -5); ds.push({ x1: x1, y1: y1, x2: x2, y2: y2 }); } return ds; } function random(min, max) { return Math.floor(Math.random() * (max - min + 1)) + min; }