Custom Legends in a div - CanvasJS JavaScript Charts

Custom Legends in a div - CanvasJS JavaScript Charts

by canvasjs

HTML

<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
<br/><!-- Just so that JSFiddle's Result label doesn't overlap the Chart -->
<div id="chartContainer" style="height: 360px; width: 100%;"></div>
<!--Custom Legends-->
<div>
    <ul>
        <li type="square" style="color:#369EAD">Legend Text 1</li>
        <li type="square" style="color:#C24642">Legend Text 2</li>
        <li type="square" style="color:#7F6084">Legend Text 3</li>
        <li type="circle" style="color:#86B402">Legend Text 4</li>
        <li type="disc" style="color:#A2D1CF">Legend Text 5</li>
    </ul>
</div>

JavaScript

var chart = new CanvasJS.Chart("chartContainer",
	{        
      data: [
      {
        type: "column",
        dataPoints: [
        { x: 10, y: 71 },
        { x: 20, y: 55},
        { x: 30, y: 50 },
        { x: 40, y: 65 },
        { x: 50, y: 95 },        
        ]
      }
      ]
 });

chart.render();