<!doctype html>
<html class="zc-html">
<head>
<meta charset="utf-8">
<title>ZingSoft Demo</title>
<script nonce="undefined" src="https://cdn.zingchart.com/zingchart.min.js"></script>
<style>
.chart--container {
height: 100%;
width: 100%;
min-height: 500px;
}
.zc-ref {
display: none;
}
</style>
</head>
<body class="zc-body">
<h2>Adjust refLine and Scale Quadrants</h2>
<input onInput="adjustRefLine(this)" type="range" min=0 max=10 id="xAxis" value=5>
<input onInput="adjustRefLine(this)" type="range" min=0 max=10 id="yAxis" value=5>
<div id="myChart" class="chart--container">
<a class="zc-ref" href="https://www.zingchart.com">Powered by ZingChart</a>
</div>
<script>
ZC.LICENSE = ["569d52cefae586f634c54f86dc99e6a9", "b55b025e438fa8a98e32482b5f768ff5"]; // DEFINE DATA
// -----------------------------
let globalXAxisValue = 5;
let globalYAxisValue = 5;
let globalGradientStopString = `.${globalXAxisValue} .${globalXAxisValue}`;
// HELPER METHODS
// -----------------------------
window.adjustRefLine = function(e) {
if (e.id === 'xAxis') {
globalXAxisValue = e.value;
zingchart.exec('myChart', 'modify', {
data: {
scaleX: {
refValue: e.value,
markers: [{
// use gradients to fill quadrants vertically
type: 'area',
range: [0, globalXAxisValue],
alpha: 0.5,
fillType: 'linear',
gradientColors: 'red green',
gradientStops: globalGradientStopString,
valueRange: true,
},
{
// use gradients to fill quadrants vertically
type: 'area',
range: [globalXAxisValue, 10],
alpha: 0.5,
fillType: 'linear',
gradientColors: 'green yellow',
gradientStops: globalGradientStopString,
valueRange: true,
},
],
},
},
});
} else {
globalYAxisValue = e.value;
globalGradientStopString = `.${10 - globalYAxisValue} .${
10 - globalYAxisValue
}`;
zingchart.exec('myChart', 'modify', {
data: {
scaleY: {
refValue: e.value,
},
scaleX: {
markers: [{
// use gradients to fill quadrants vertically
type: 'area',
range: [0, globalXAxisValue],
valueRange: true,
gradientColors: 'red green',
gradientStops: globalGradientStopString,
fillType: 'linear',
alpha: 0.5,
},
{
// use gradients to fill quadrants vertically
type: 'area',
range: [globalXAxisValue, 10],
valueRange: true,
gradientColors: 'green yellow',
gradientStops: globalGradientStopString,
fillType: 'linear',
alpha: 0.5,
},
],
},
},
});
}
};
// CHART CONFIG
// -----------------------------
let chartConfig = {
graphset: [{
type: 'mixed',
title: {
text: 'Scale Quadrants',
},
scaleX: {
values: '0:10:1',
guide: {
visible: true,
},
markers: [{
// use gradients to fill quadrants vertically
type: 'area',
range: [0, globalXAxisValue],
alpha: 0.5,
fillType: 'linear',
gradientColors: 'red green',
gradientStops: '.5 .5',
valueRange: true,
},
{
// use gradients to fill quadrants vertically
type: 'area',
range: [globalXAxisValue, 10],
alpha: 0.5,
fillType: 'linear',
gradientColors: 'green yellow',
gradientStops: '.5 .5',
valueRange: true,
},
],
refLine: {
lineColor: '#424242',
lineWidth: '3px',
visible: true,
},
refValue: 5,
},
scaleY: {
values: '0:10:1',
guide: {
visible: true,
},
refLine: {
lineColor: '#424242',
lineWidth: '3px',
visible: true,
},
refValue: 5,
},
plot: {},
series: [{
type: 'bubble',
values: [
[3.65, 4.76, 7.55],
[2.92, 3.87, 7.19],
[7.19, 4.95, 6.39],
[3.58, 4.71, 7.45],
[6.86, 6.13, 6.93],
[3.05, 4.69, 7.9],
[2.49, 3.46, 5.37],
[3.76, 4.33, 8.04],
[3.54, 4.1, 7.68],
[2.92, 4.5, 7.4],
[3.84, 5.21, 7.48],
[4.84, 5.26, 6.29],
[4.35, 5.48, 6.83],
[4.35, 5.17, 7.39],
[3.87, 4.49, 6.16],
[5.05, 5.22, 6.59],
[4.06, 4.83, 6.44],
[3.86, 3.79, 6.16],
[2.49, 3.85, 6.28],
[3.99, 4.28, 5.85],
[4.12, 4.41, 7.78],
[4.65, 6.42, 7.85],
[4.65, 5.52, 6.64],
],
marker: {
backgroundColor: '#ab47bc',
},
}, ],
}, ],
};
// RENDER CHARTS
// -----------------------------
zingchart.render({
id: 'myChart',
data: chartConfig,
height: '100%',
width: '100%',
});
</script>
</body>
</html>
// DEFINE DATA
// -----------------------------
let globalXAxisValue = 5;
let globalYAxisValue = 5;
let globalGradientStopString = `.${globalXAxisValue} .${globalXAxisValue}`;
// HELPER METHODS
// -----------------------------
window.adjustRefLine = function (e) {
if (e.id === 'xAxis') {
globalXAxisValue = e.value;
zingchart.exec('myChart', 'modify', {
data: {
scaleX: {
refValue: e.value,
markers: [
{
// use gradients to fill quadrants vertically
type: 'area',
range: [0, globalXAxisValue],
alpha: 0.5,
fillType: 'linear',
gradientColors: 'red green',
gradientStops: globalGradientStopString,
valueRange: true,
},
{
// use gradients to fill quadrants vertically
type: 'area',
range: [globalXAxisValue, 10],
alpha: 0.5,
fillType: 'linear',
gradientColors: 'green yellow',
gradientStops: globalGradientStopString,
valueRange: true,
},
],
},
},
});
} else {
globalYAxisValue = e.value;
globalGradientStopString = `.${10 - globalYAxisValue} .${
10 - globalYAxisValue
}`;
zingchart.exec('myChart', 'modify', {
data: {
scaleY: {
refValue: e.value,
},
scaleX: {
markers: [
{
// use gradients to fill quadrants vertically
type: 'area',
range: [0, globalXAxisValue],
valueRange: true,
gradientColors: 'red green',
gradientStops: globalGradientStopString,
fillType: 'linear',
alpha: 0.5,
},
{
// use gradients to fill quadrants vertically
type: 'area',
range: [globalXAxisValue, 10],
valueRange: true,
gradientColors: 'green yellow',
gradientStops: globalGradientStopString,
fillType: 'linear',
alpha: 0.5,
},
],
},
},
});
}
};
// CHART CONFIG
// -----------------------------
let chartConfig = {
graphset: [
{
type: 'mixed',
title: {
text: 'Scale Quadrants',
},
scaleX: {
values: '0:10:1',
guide: {
visible: true,
},
markers: [
{
// use gradients to fill quadrants vertically
type: 'area',
range: [0, globalXAxisValue],
alpha: 0.5,
fillType: 'linear',
gradientColors: 'red green',
gradientStops: '.5 .5',
valueRange: true,
},
{
// use gradients to fill quadrants vertically
type: 'area',
range: [globalXAxisValue, 10],
alpha: 0.5,
fillType: 'linear',
gradientColors: 'green yellow',
gradientStops: '.5 .5',
valueRange: true,
},
],
refLine: {
lineColor: '#424242',
lineWidth: '3px',
visible: true,
},
refValue: 5,
},
scaleY: {
values: '0:10:1',
guide: {
visible: true,
},
refLine: {
lineColor: '#424242',
lineWidth: '3px',
visible: true,
},
refValue: 5,
},
plot: {},
series: [
{
type: 'bubble',
values: [
[3.65, 4.76, 7.55],
[2.92, 3.87, 7.19],
[7.19, 4.95, 6.39],
[3.58, 4.71, 7.45],
[6.86, 6.13, 6.93],
[3.05, 4.69, 7.9],
[2.49, 3.46, 5.37],
[3.76, 4.33, 8.04],
[3.54, 4.1, 7.68],
[2.92, 4.5, 7.4],
[3.84, 5.21, 7.48],
[4.84, 5.26, 6.29],
[4.35, 5.48, 6.83],
[4.35, 5.17, 7.39],
[3.87, 4.49, 6.16],
[5.05, 5.22, 6.59],
[4.06, 4.83, 6.44],
[3.86, 3.79, 6.16],
[2.49, 3.85, 6.28],
[3.99, 4.28, 5.85],
[4.12, 4.41, 7.78],
[4.65, 6.42, 7.85],
[4.65, 5.52, 6.64],
],
marker: {
backgroundColor: '#ab47bc',
},
},
],
},
],
};
// RENDER CHARTS
// -----------------------------
zingchart.render({
id: 'myChart',
data: chartConfig,
height: '100%',
width: '100%',
});