Chartjs-Chart.js title is not showing

0👍

Well, I could not find my problem with my code. however, i re wrote it in another way.

var canvas = document.createElement('canvas');
canvas.id = "Convas"+commandIndex;
canvas.width = 800;
canvas.style.zIndex = 8;
canvas.style.position = "inherit";
  document.getElementById("chartdiv").insertBefore(canvas,document.getElementById("Convas"+commandIndex));

var barData = {
labels : [{% for item in labels %}
              "{{item}}",
          {% endfor %}],
datasets : [
   {
        fillColor: "rgba(151,187,205,0.2)",
        strokeColor: "rgba(151,187,205,1)",
        pointColor: "rgba(241, 14, 75, 1)",
        pointStrokeColor: "#fff",
        pointHighlightFill: "#fff",
        pointHighlightStroke: "rgba(241, 14, 75, 1)",
        backgroundColor: "rgba(241, 14, 75, 1)",
        borderColor: "rgba(241, 14, 75, 1)",
        bezierCurve : false,
        fill: false,
        label: "My First dataset",
        data : [{% for item in values %}
                  {{item}},
                {% endfor %}]
  }]
 }
   var config = {
   type: 'line',
   data: barData,
   options: {
       responsive: true,
       title:{
           display:true,
           text:'Chart.js Line Chart'
       },
       tooltips: {
           mode: 'index',
           intersect: false,
       },
       hover: {
           mode: 'nearest',
           intersect: true
       },
       scales: {
           xAxes: [{
               display: true,
               scaleLabel: {
                   display: true,
                   labelString: 'Month'
               }
           }],
           yAxes: [{
               display: true,
               scaleLabel: {
                   display: true,
                   labelString: 'Value'
               },
               ticks: {
                   min: 0,
                   max: 100,

                   // forces step size to be 5 units
                   stepSize: 5
               }
           }]
       }
   }
 };
  var mychart = 
  document.getElementById("Convas"+commandIndex).getContext("2d");

steps = 100
max = 100
// draw bar cha
  var LineChartDemo = new Chart(mychart, config);

Leave a comment