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>
<br/><!-- Just so that JSFiddle's Result label doesn't overlap the Chart -->
    <div class="chartWrapper">
        <div class="chartAreaWrapper">
            <div id="chartContainer" style="height: 360px; width: 200%"></div>
        </div>
        <canvas id="overlayedAxis"></canvas>
    </div>

CSS

.chartWrapper {
  position: relative;
  max-height: 350px;
}

.chartWrapper > canvas {
  position: fixed;
  left: 0;
  pointer-events: none;
}

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();

  copyAxis('chartContainer', 'overlayedAxis', stockChart);

  function copyAxis(containerId, destId, chart) {
    var chartCanvas = $(
      '#chartContainer .canvasjs-chart-canvas'
    ).get(0);
    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;

    destCtx.canvas.width = axisWidth + 16;
    destCtx.canvas.height = axisHeight;

    destCtx.fillStyle = chart.get("backgroundColor");
    destCtx.rect(0, 0, destCtx.canvas.width, destCtx.canvas.height);
    destCtx.fill();


    destCtx.drawImage(
      chartCanvas,
      0,
      chart.axisX[0].bounds.y1,
      axisWidth,
      axisHeight,
      16,
      0,
      axisWidth,
      axisHeight
    );
 ...