Basic Column Chart - CanvasJS
Basic Column Chart
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script src="https://cdn.canvasjs.com/canvasjs.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/split.js/1.6.5/split.min.js"></script>
<br/><!-- Just so that JSFiddle's Result label doesn't overlap the Chart -->
<div class="cell b split" id="split-1">
<div id="gearlist-wrapper" class="split content split-horizontal parentdivstyle scrollbar">
<ul id="quoteGearList-list" class="quoteGearList-list">
<li id="listHeaderRow">
<button id="1111111111" resourceid="undefined" style="width: 100px;">C</button>
<button id="2222222222" resourceid="undefined" style="width: 60px;">Q</button>
<button id="3333333333" resourceid="undefined" style="margin-left: 0px; color: rgb(255, 255, 255);">Inventory</button>
</li>
</ul>
</div>
<div class="spliter-div"></div>
<div id="container" class="chartWrapper split content split-horizontal parentdivstyle scrollbar">
<div class="chartAreaWrapper">
<div id="chartContainer" style="height: 360px; width: 200%"></div>
</div>
<canvas id="overlayedAxis"></canvas>
</div>
</div>
CSS
.chartWrapper {
position: relative;
max-height: 350px;
}
.chartWrapper > #overlayedAxis {
position: fixed;
left: 0;
pointer-events: none;
}
/*resizer*/
html, body {
height: 100%;
}
body {
padding: 8px;
/*background-color: #F6F6F6;*/
box-sizing: border-box;
}
.gutter {
background: #808080;
background-repeat: no-repeat;
background-position: 50%;
}
.gutter.gutter-vertical {
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAFAQMAAABo7865AAAABlBMVEVHcEzMzMzyAv2sAAAAAXRSTlMAQObYZgAAABBJREFUeF5jOAMEEAIEEFwAn3kMwcB6I2AAAAAASUVORK5CYII=');
cursor: s-resize;
}
.gutter.gutter-horizontal {
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAeCAYAAADkftS9AAAAIklEQVQoU2M4c+bMfxAGAgYYmwGrIIiDjrELjpo5aiZeMwF+yNnOs5KSvgAAAABJRU5ErkJggg==');
cursor: w-resize;
}
.split.split-horizontal,
.gutter.gutter-horizontal {
height: 100%;
float: left;
}
.split {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.content {
width: 100%;
height: calc(100% - 165px);
display: flex;
flex-direction: column;
}
.scrollbar {
overflow-x: scroll;
overflow-y: scroll;
max-height: 100%;
}
.cell {
width: 100%;
height: 100%;
padding: 0px;
border: 1px solid;
}
/*resizer end*/
JavaScript
window.onload = function () {
var stockChart = new CanvasJS.Chart("chartContainer", {
animationEnabled: true,
title: {
text: "Fortune 500 Companies by Country"
},
axisX: {
interval: 1
},
axisY2: {
interlacedColor: "rgba(1,77,101,.2)",
gridColor: "rgba(1,77,101,.1)",
title: "Number of Companies"
},
data: [{
type: "bar",
name: "companies",
color: "#014D65",
axisYType: "secondary",
dataPoints: [
{ y: 3, label: "Sweden" },
{ y: 7, label: "Taiwan" },
{ y: 5, label: "Russia" },
{ y: 9, label: "Spain" },
{ y: 7, label: "Brazil" },
{ y: 7, label: "India" },
{ y: 9, label: "Italy" },
{ y: 8, label: "Australia" },
{ y: 11, label: "Canada" },
{ y: 15, label: "South Korea" },
{ y: 12, label: "Netherlands" },
{ y: 15, label: "Switzerland" },
{ y: 25, label: "Britain" },
{ y: 28, label: "Germany" },
{ y: 29, label: "France" },
{ y: 52, label: "Japan" },
{ y: 103, label: "China" },
{ y: 134, label: "US" }
]
}]
});
stockChart.render();
///div resizer
Split(['#gearlist-wrapper', '#container'], {
sizes: [30, 70],
gutterSize: 20,
});
var overlayedAxisTopPosition = 0;
copyAxis('chartContainer', 'overlayedAxis', stockChart);
function copyAxis(containerId, destId, chart, copyContent) {
copyContent = copyContent ? true : false;
copyContent = true;
var chartCanvas = $(
'#chartContainer .canvasjs-chart-canvas'
).get(0);
var overlayedCanvas = $('#' + destId);
var destCtx = $('#' + destId)
.get(0)
.getContext('2d');
var axisWidth =
chart.axisX[0].bounds.x2
var axisHeight =
chart.axisX[0].bounds.y2 - chart.axisX[0].bounds.y1;
if(copyContent) {
destCtx.canvas.width = axisWidth;
destCtx.canvas.height = axisHeight;
destCtx.fillStyle =...