JavaScript
window.onload = function () {
var chart = new CanvasJS.Chart("chartContainer", {
title:{
text: "Scaling"
},
axisY:{
/* title: 'gauge', */
gridThickness: 0,
/* labelFormatter: () => '', */
},
axisX:{
minimum: 0
},
data: [
{
type: "line",
dataPoints: [
{ x: 0, y: 13 },
{ x: 1, y: 15 },
{ x: 2, y: 13 },
{ x: 3, y: 11 },
{ x: 4, y: 9 },
{ x: 5, y: 12 },
{ x: 6, y: 11 },
{ x: 7, y: 12 },
{ x: 8, y: 14 },
{ x: 9, y: 13 },
{ x: 10, y: 13 },
{ x: 11, y: 15 },
{ x: 12, y: 13 },
{ x: 13, y: 11 },
{ x: 14, y: 9 },
{ x: 15, y: 12 },
{ x: 16, y: 11 },
{ x: 17, y: 12 },
{ x: 18, y: 14 },
{ x: 19, y: 13 },
{ x: 20, y: 13 },
]
},
{
type: "line",
markerType: "none",
lineDashType: "dash",
color:"red",
toolTipContent: null,
dataPoints: [
{x: 0, y: 10},
{x: 3, y: 10},
]
},
{
type: "line",
markerType: "none",
lineDashType: "dash",
color:"red",
toolTipContent: null,
dataPoints: [
{x: 3, y: 11},
{x: 7, y: 11}
]
}
]
});
chart.render();
var axisXBounds = chart.axisX[chart.axisX.length - 1].get("bounds");
var axisYBounds = chart.axisY[chart.axisY.length - 1].get("bounds");
var plotAreaWidth = 300;
var plotAreaHeight = 300;
var chartWidth = axisXBounds.x1 + plotAreaWidth;
var chartHeight = chart.height - (axisYBounds.y2) + axisYBounds.y1 + plotAreaHeight;
chart.set("width", chartWidth, false);
chart.set("height", chartHeight);
}