$(() => {
const 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,
inputAttr: { 'aria-label': 'Argument Custom Position' },
onValueChanged(e) {
chart.option('argumentAxis.customPosition', e.value);
},
});
$('#argumentOffset').dxNumberBox({
value: 0,
showSpinButtons: true,
inputAttr: { 'aria-label': 'Argument Offset' },
onValueChanged(e) {
chart.option('argumentAxis.offset', e.value);
},
});
$('#valueCustomPosition').dxNumberBox({
value: 0,
showSpinButtons: true,
inputAttr: { 'aria-label': 'Value Custom Position' },
onValueChanged(e) {
chart.option('valueAxis.customPosition', e.value);
},
});
$('#valueOffset').dxNumberBox({
value: 0,
showSpinButtons: true,
inputAttr: { 'aria-label': 'Value Offset' },
onValueChanged(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/23.1.5/css/dx.light.css" />
<script src="https://cdn3.devexpress.com/jslib/23.1.5/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;
display: flex;
align-items: center;
justify-content: space-between;
}
.option > span {
margin-right: 20px;
}
.caption {
font-size: 18px;
font-weight: 700;
}
.option > .dx-numberbox {
width: 90px;
margin-left: auto;
}
.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; let x2; let y1; let y2; let
i;
const ds = [];
for (i = 0; i < 20; i += 1) {
x1 = random(5, 15);
y1 = random(5, 15);
ds.push({
x1, y1, x2, y2,
});
}
for (i = 0; i < 20; i += 1) {
x2 = random(5, 15);
y2 = random(-15, -5);
ds.push({
x1, y1, x2, y2,
});
}
for (i = 0; i < 20; i += 1) {
x2 = random(-15, -5);
y2 = random(5, 15);
ds.push({
x1, y1, x2, y2,
});
}
for (i = 0; i < 20; i += 1) {
x1 = random(-15, -5);
y1 = random(-15, -5);
ds.push({
x1, y1, x2, y2,
});
}
return ds;
}
function random(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}