How to fix ChartJS legend not working issue










0















i'm using chartjs for my project and all my charts are working fine without legends. the issue is no matter what i do legend is not showing up. here's my code.



var ctx1 = document.getElementById("chart1").getContext("2d");
var data1 =
labels: ["2018-11-05","2018-11-06","2018-11-07","2018-11-08","2018-11-09","2018-11-10","2018-11-11","2018-11-12","2018-11-13","2018-11-14"],
datasets: [

label: "Total Calls received",
fillColor: "rgba(220,220,220,0)",
strokeColor: "rgba(220,220,220,1)",
pointColor: "rgba(220,220,220,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(18,175,203,1)",
data: [0,"2539","8091","9119","15621","13293","6892","6486","6605","931"] ,

label: "Total Calls Accepted",
fillColor: "rgba(34,186,160,0)",
strokeColor: "rgba(34,186,160,1)",
pointColor: "rgba(34,186,160,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(75,131,13,1)",
data: [0,"274","1443","1069","377","22","1268","1201","1356","236"] ,

label: "Eligible For Offers",
fillColor: "rgba(41,121,255,0)",
strokeColor: "rgba(41,121,255,1)",
pointColor: "rgba(41,121,255,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(0,78,203,1)",
data: [0,0,0,"2854","5573","6846","3270","3007","3413","649"]
]
;

var chart1 = new Chart(ctx1).Line(data1,
scaleShowGridLines: true,
scaleGridLineColor: "rgba(0,0,0,.05)",
scaleGridLineWidth: 1,
scaleShowHorizontalLines: true,
scaleShowVerticalLines: true,
bezierCurve: true,
bezierCurveTension: 0.4,
pointDot: true,
pointDotRadius: 4,
pointDotStrokeWidth: 1,
pointHitDetectionRadius: 20,
datasetStroke: true,
datasetStrokeWidth: 2,
datasetFill: true,
responsive: true
);


Note* adding legend option to the end of last code segment is not working.










share|improve this question






















  • can you please make a fiddle?

    – Negi Rox
    Nov 14 '18 at 5:38















0















i'm using chartjs for my project and all my charts are working fine without legends. the issue is no matter what i do legend is not showing up. here's my code.



var ctx1 = document.getElementById("chart1").getContext("2d");
var data1 =
labels: ["2018-11-05","2018-11-06","2018-11-07","2018-11-08","2018-11-09","2018-11-10","2018-11-11","2018-11-12","2018-11-13","2018-11-14"],
datasets: [

label: "Total Calls received",
fillColor: "rgba(220,220,220,0)",
strokeColor: "rgba(220,220,220,1)",
pointColor: "rgba(220,220,220,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(18,175,203,1)",
data: [0,"2539","8091","9119","15621","13293","6892","6486","6605","931"] ,

label: "Total Calls Accepted",
fillColor: "rgba(34,186,160,0)",
strokeColor: "rgba(34,186,160,1)",
pointColor: "rgba(34,186,160,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(75,131,13,1)",
data: [0,"274","1443","1069","377","22","1268","1201","1356","236"] ,

label: "Eligible For Offers",
fillColor: "rgba(41,121,255,0)",
strokeColor: "rgba(41,121,255,1)",
pointColor: "rgba(41,121,255,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(0,78,203,1)",
data: [0,0,0,"2854","5573","6846","3270","3007","3413","649"]
]
;

var chart1 = new Chart(ctx1).Line(data1,
scaleShowGridLines: true,
scaleGridLineColor: "rgba(0,0,0,.05)",
scaleGridLineWidth: 1,
scaleShowHorizontalLines: true,
scaleShowVerticalLines: true,
bezierCurve: true,
bezierCurveTension: 0.4,
pointDot: true,
pointDotRadius: 4,
pointDotStrokeWidth: 1,
pointHitDetectionRadius: 20,
datasetStroke: true,
datasetStrokeWidth: 2,
datasetFill: true,
responsive: true
);


Note* adding legend option to the end of last code segment is not working.










share|improve this question






















  • can you please make a fiddle?

    – Negi Rox
    Nov 14 '18 at 5:38













0












0








0








i'm using chartjs for my project and all my charts are working fine without legends. the issue is no matter what i do legend is not showing up. here's my code.



var ctx1 = document.getElementById("chart1").getContext("2d");
var data1 =
labels: ["2018-11-05","2018-11-06","2018-11-07","2018-11-08","2018-11-09","2018-11-10","2018-11-11","2018-11-12","2018-11-13","2018-11-14"],
datasets: [

label: "Total Calls received",
fillColor: "rgba(220,220,220,0)",
strokeColor: "rgba(220,220,220,1)",
pointColor: "rgba(220,220,220,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(18,175,203,1)",
data: [0,"2539","8091","9119","15621","13293","6892","6486","6605","931"] ,

label: "Total Calls Accepted",
fillColor: "rgba(34,186,160,0)",
strokeColor: "rgba(34,186,160,1)",
pointColor: "rgba(34,186,160,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(75,131,13,1)",
data: [0,"274","1443","1069","377","22","1268","1201","1356","236"] ,

label: "Eligible For Offers",
fillColor: "rgba(41,121,255,0)",
strokeColor: "rgba(41,121,255,1)",
pointColor: "rgba(41,121,255,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(0,78,203,1)",
data: [0,0,0,"2854","5573","6846","3270","3007","3413","649"]
]
;

var chart1 = new Chart(ctx1).Line(data1,
scaleShowGridLines: true,
scaleGridLineColor: "rgba(0,0,0,.05)",
scaleGridLineWidth: 1,
scaleShowHorizontalLines: true,
scaleShowVerticalLines: true,
bezierCurve: true,
bezierCurveTension: 0.4,
pointDot: true,
pointDotRadius: 4,
pointDotStrokeWidth: 1,
pointHitDetectionRadius: 20,
datasetStroke: true,
datasetStrokeWidth: 2,
datasetFill: true,
responsive: true
);


Note* adding legend option to the end of last code segment is not working.










share|improve this question














i'm using chartjs for my project and all my charts are working fine without legends. the issue is no matter what i do legend is not showing up. here's my code.



var ctx1 = document.getElementById("chart1").getContext("2d");
var data1 =
labels: ["2018-11-05","2018-11-06","2018-11-07","2018-11-08","2018-11-09","2018-11-10","2018-11-11","2018-11-12","2018-11-13","2018-11-14"],
datasets: [

label: "Total Calls received",
fillColor: "rgba(220,220,220,0)",
strokeColor: "rgba(220,220,220,1)",
pointColor: "rgba(220,220,220,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(18,175,203,1)",
data: [0,"2539","8091","9119","15621","13293","6892","6486","6605","931"] ,

label: "Total Calls Accepted",
fillColor: "rgba(34,186,160,0)",
strokeColor: "rgba(34,186,160,1)",
pointColor: "rgba(34,186,160,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(75,131,13,1)",
data: [0,"274","1443","1069","377","22","1268","1201","1356","236"] ,

label: "Eligible For Offers",
fillColor: "rgba(41,121,255,0)",
strokeColor: "rgba(41,121,255,1)",
pointColor: "rgba(41,121,255,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(0,78,203,1)",
data: [0,0,0,"2854","5573","6846","3270","3007","3413","649"]
]
;

var chart1 = new Chart(ctx1).Line(data1,
scaleShowGridLines: true,
scaleGridLineColor: "rgba(0,0,0,.05)",
scaleGridLineWidth: 1,
scaleShowHorizontalLines: true,
scaleShowVerticalLines: true,
bezierCurve: true,
bezierCurveTension: 0.4,
pointDot: true,
pointDotRadius: 4,
pointDotStrokeWidth: 1,
pointHitDetectionRadius: 20,
datasetStroke: true,
datasetStrokeWidth: 2,
datasetFill: true,
responsive: true
);


Note* adding legend option to the end of last code segment is not working.







javascript jquery charts






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 14 '18 at 4:52









Lahiru MadusankaLahiru Madusanka

13210




13210












  • can you please make a fiddle?

    – Negi Rox
    Nov 14 '18 at 5:38

















  • can you please make a fiddle?

    – Negi Rox
    Nov 14 '18 at 5:38
















can you please make a fiddle?

– Negi Rox
Nov 14 '18 at 5:38





can you please make a fiddle?

– Negi Rox
Nov 14 '18 at 5:38












1 Answer
1






active

oldest

votes


















1














try this...






var ctx1 = document.getElementById("chart1").getContext("2d");
var data1 =
labels: ["2018-11-05","2018-11-06","2018-11-07","2018-11-08","2018-11-09","2018-11-10","2018-11-11","2018-11-12","2018-11-13","2018-11-14"],
datasets: [

label: "Total Calls received",
fillColor: "rgba(220,220,220,0)",
strokeColor: "rgba(220,220,220,1)",
pointColor: "rgba(220,220,220,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(18,175,203,1)",
data: [0,"2539","8091","9119","15621","13293","6892","6486","6605","931"] ,

label: "Total Calls Accepted",
fillColor: "rgba(34,186,160,0)",
strokeColor: "rgba(34,186,160,1)",
pointColor: "rgba(34,186,160,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(75,131,13,1)",
data: [0,"274","1443","1069","377","22","1268","1201","1356","236"] ,

label: "Eligible For Offers",
fillColor: "rgba(41,121,255,0)",
strokeColor: "rgba(41,121,255,1)",
pointColor: "rgba(41,121,255,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(0,78,203,1)",
data: [0,0,0,"2854","5573","6846","3270","3007","3413","649"]
]
;

var chart1 = new Chart(ctx1).Line(data1,
scaleShowGridLines: true,
scaleGridLineColor: "rgba(0,0,0,.05)",
scaleGridLineWidth: 1,
scaleShowHorizontalLines: true,
scaleShowVerticalLines: true,
bezierCurve: true,
bezierCurveTension: 0.4,
pointDot: true,
pointDotRadius: 4,
pointDotStrokeWidth: 1,
pointHitDetectionRadius: 20,
datasetStroke: true,
datasetStrokeWidth: 2,
datasetFill: true,
responsive: true
);

document.getElementById('legends').innerHTML = chart1.generateLegend();

.chart-legend li span 
display: inline-block;
width: 12px;
height: 12px;
margin-right: 5px;

<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.1/Chart.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div style="width: 100%; height: 100%;">
<canvas id="chart1" style="width: 100%; height: auto;"></canvas>
</div>
<div id="legends" class="chart-legend"></div>








share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53293375%2fhow-to-fix-chartjs-legend-not-working-issue%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    try this...






    var ctx1 = document.getElementById("chart1").getContext("2d");
    var data1 =
    labels: ["2018-11-05","2018-11-06","2018-11-07","2018-11-08","2018-11-09","2018-11-10","2018-11-11","2018-11-12","2018-11-13","2018-11-14"],
    datasets: [

    label: "Total Calls received",
    fillColor: "rgba(220,220,220,0)",
    strokeColor: "rgba(220,220,220,1)",
    pointColor: "rgba(220,220,220,1)",
    pointStrokeColor: "#fff",
    pointHighlightFill: "#fff",
    pointHighlightStroke: "rgba(18,175,203,1)",
    data: [0,"2539","8091","9119","15621","13293","6892","6486","6605","931"] ,

    label: "Total Calls Accepted",
    fillColor: "rgba(34,186,160,0)",
    strokeColor: "rgba(34,186,160,1)",
    pointColor: "rgba(34,186,160,1)",
    pointStrokeColor: "#fff",
    pointHighlightFill: "#fff",
    pointHighlightStroke: "rgba(75,131,13,1)",
    data: [0,"274","1443","1069","377","22","1268","1201","1356","236"] ,

    label: "Eligible For Offers",
    fillColor: "rgba(41,121,255,0)",
    strokeColor: "rgba(41,121,255,1)",
    pointColor: "rgba(41,121,255,1)",
    pointStrokeColor: "#fff",
    pointHighlightFill: "#fff",
    pointHighlightStroke: "rgba(0,78,203,1)",
    data: [0,0,0,"2854","5573","6846","3270","3007","3413","649"]
    ]
    ;

    var chart1 = new Chart(ctx1).Line(data1,
    scaleShowGridLines: true,
    scaleGridLineColor: "rgba(0,0,0,.05)",
    scaleGridLineWidth: 1,
    scaleShowHorizontalLines: true,
    scaleShowVerticalLines: true,
    bezierCurve: true,
    bezierCurveTension: 0.4,
    pointDot: true,
    pointDotRadius: 4,
    pointDotStrokeWidth: 1,
    pointHitDetectionRadius: 20,
    datasetStroke: true,
    datasetStrokeWidth: 2,
    datasetFill: true,
    responsive: true
    );

    document.getElementById('legends').innerHTML = chart1.generateLegend();

    .chart-legend li span 
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-right: 5px;

    <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.1/Chart.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <div style="width: 100%; height: 100%;">
    <canvas id="chart1" style="width: 100%; height: auto;"></canvas>
    </div>
    <div id="legends" class="chart-legend"></div>








    share|improve this answer



























      1














      try this...






      var ctx1 = document.getElementById("chart1").getContext("2d");
      var data1 =
      labels: ["2018-11-05","2018-11-06","2018-11-07","2018-11-08","2018-11-09","2018-11-10","2018-11-11","2018-11-12","2018-11-13","2018-11-14"],
      datasets: [

      label: "Total Calls received",
      fillColor: "rgba(220,220,220,0)",
      strokeColor: "rgba(220,220,220,1)",
      pointColor: "rgba(220,220,220,1)",
      pointStrokeColor: "#fff",
      pointHighlightFill: "#fff",
      pointHighlightStroke: "rgba(18,175,203,1)",
      data: [0,"2539","8091","9119","15621","13293","6892","6486","6605","931"] ,

      label: "Total Calls Accepted",
      fillColor: "rgba(34,186,160,0)",
      strokeColor: "rgba(34,186,160,1)",
      pointColor: "rgba(34,186,160,1)",
      pointStrokeColor: "#fff",
      pointHighlightFill: "#fff",
      pointHighlightStroke: "rgba(75,131,13,1)",
      data: [0,"274","1443","1069","377","22","1268","1201","1356","236"] ,

      label: "Eligible For Offers",
      fillColor: "rgba(41,121,255,0)",
      strokeColor: "rgba(41,121,255,1)",
      pointColor: "rgba(41,121,255,1)",
      pointStrokeColor: "#fff",
      pointHighlightFill: "#fff",
      pointHighlightStroke: "rgba(0,78,203,1)",
      data: [0,0,0,"2854","5573","6846","3270","3007","3413","649"]
      ]
      ;

      var chart1 = new Chart(ctx1).Line(data1,
      scaleShowGridLines: true,
      scaleGridLineColor: "rgba(0,0,0,.05)",
      scaleGridLineWidth: 1,
      scaleShowHorizontalLines: true,
      scaleShowVerticalLines: true,
      bezierCurve: true,
      bezierCurveTension: 0.4,
      pointDot: true,
      pointDotRadius: 4,
      pointDotStrokeWidth: 1,
      pointHitDetectionRadius: 20,
      datasetStroke: true,
      datasetStrokeWidth: 2,
      datasetFill: true,
      responsive: true
      );

      document.getElementById('legends').innerHTML = chart1.generateLegend();

      .chart-legend li span 
      display: inline-block;
      width: 12px;
      height: 12px;
      margin-right: 5px;

      <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.1/Chart.min.js"></script>
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
      <div style="width: 100%; height: 100%;">
      <canvas id="chart1" style="width: 100%; height: auto;"></canvas>
      </div>
      <div id="legends" class="chart-legend"></div>








      share|improve this answer

























        1












        1








        1







        try this...






        var ctx1 = document.getElementById("chart1").getContext("2d");
        var data1 =
        labels: ["2018-11-05","2018-11-06","2018-11-07","2018-11-08","2018-11-09","2018-11-10","2018-11-11","2018-11-12","2018-11-13","2018-11-14"],
        datasets: [

        label: "Total Calls received",
        fillColor: "rgba(220,220,220,0)",
        strokeColor: "rgba(220,220,220,1)",
        pointColor: "rgba(220,220,220,1)",
        pointStrokeColor: "#fff",
        pointHighlightFill: "#fff",
        pointHighlightStroke: "rgba(18,175,203,1)",
        data: [0,"2539","8091","9119","15621","13293","6892","6486","6605","931"] ,

        label: "Total Calls Accepted",
        fillColor: "rgba(34,186,160,0)",
        strokeColor: "rgba(34,186,160,1)",
        pointColor: "rgba(34,186,160,1)",
        pointStrokeColor: "#fff",
        pointHighlightFill: "#fff",
        pointHighlightStroke: "rgba(75,131,13,1)",
        data: [0,"274","1443","1069","377","22","1268","1201","1356","236"] ,

        label: "Eligible For Offers",
        fillColor: "rgba(41,121,255,0)",
        strokeColor: "rgba(41,121,255,1)",
        pointColor: "rgba(41,121,255,1)",
        pointStrokeColor: "#fff",
        pointHighlightFill: "#fff",
        pointHighlightStroke: "rgba(0,78,203,1)",
        data: [0,0,0,"2854","5573","6846","3270","3007","3413","649"]
        ]
        ;

        var chart1 = new Chart(ctx1).Line(data1,
        scaleShowGridLines: true,
        scaleGridLineColor: "rgba(0,0,0,.05)",
        scaleGridLineWidth: 1,
        scaleShowHorizontalLines: true,
        scaleShowVerticalLines: true,
        bezierCurve: true,
        bezierCurveTension: 0.4,
        pointDot: true,
        pointDotRadius: 4,
        pointDotStrokeWidth: 1,
        pointHitDetectionRadius: 20,
        datasetStroke: true,
        datasetStrokeWidth: 2,
        datasetFill: true,
        responsive: true
        );

        document.getElementById('legends').innerHTML = chart1.generateLegend();

        .chart-legend li span 
        display: inline-block;
        width: 12px;
        height: 12px;
        margin-right: 5px;

        <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.1/Chart.min.js"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
        <div style="width: 100%; height: 100%;">
        <canvas id="chart1" style="width: 100%; height: auto;"></canvas>
        </div>
        <div id="legends" class="chart-legend"></div>








        share|improve this answer













        try this...






        var ctx1 = document.getElementById("chart1").getContext("2d");
        var data1 =
        labels: ["2018-11-05","2018-11-06","2018-11-07","2018-11-08","2018-11-09","2018-11-10","2018-11-11","2018-11-12","2018-11-13","2018-11-14"],
        datasets: [

        label: "Total Calls received",
        fillColor: "rgba(220,220,220,0)",
        strokeColor: "rgba(220,220,220,1)",
        pointColor: "rgba(220,220,220,1)",
        pointStrokeColor: "#fff",
        pointHighlightFill: "#fff",
        pointHighlightStroke: "rgba(18,175,203,1)",
        data: [0,"2539","8091","9119","15621","13293","6892","6486","6605","931"] ,

        label: "Total Calls Accepted",
        fillColor: "rgba(34,186,160,0)",
        strokeColor: "rgba(34,186,160,1)",
        pointColor: "rgba(34,186,160,1)",
        pointStrokeColor: "#fff",
        pointHighlightFill: "#fff",
        pointHighlightStroke: "rgba(75,131,13,1)",
        data: [0,"274","1443","1069","377","22","1268","1201","1356","236"] ,

        label: "Eligible For Offers",
        fillColor: "rgba(41,121,255,0)",
        strokeColor: "rgba(41,121,255,1)",
        pointColor: "rgba(41,121,255,1)",
        pointStrokeColor: "#fff",
        pointHighlightFill: "#fff",
        pointHighlightStroke: "rgba(0,78,203,1)",
        data: [0,0,0,"2854","5573","6846","3270","3007","3413","649"]
        ]
        ;

        var chart1 = new Chart(ctx1).Line(data1,
        scaleShowGridLines: true,
        scaleGridLineColor: "rgba(0,0,0,.05)",
        scaleGridLineWidth: 1,
        scaleShowHorizontalLines: true,
        scaleShowVerticalLines: true,
        bezierCurve: true,
        bezierCurveTension: 0.4,
        pointDot: true,
        pointDotRadius: 4,
        pointDotStrokeWidth: 1,
        pointHitDetectionRadius: 20,
        datasetStroke: true,
        datasetStrokeWidth: 2,
        datasetFill: true,
        responsive: true
        );

        document.getElementById('legends').innerHTML = chart1.generateLegend();

        .chart-legend li span 
        display: inline-block;
        width: 12px;
        height: 12px;
        margin-right: 5px;

        <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.1/Chart.min.js"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
        <div style="width: 100%; height: 100%;">
        <canvas id="chart1" style="width: 100%; height: auto;"></canvas>
        </div>
        <div id="legends" class="chart-legend"></div>








        var ctx1 = document.getElementById("chart1").getContext("2d");
        var data1 =
        labels: ["2018-11-05","2018-11-06","2018-11-07","2018-11-08","2018-11-09","2018-11-10","2018-11-11","2018-11-12","2018-11-13","2018-11-14"],
        datasets: [

        label: "Total Calls received",
        fillColor: "rgba(220,220,220,0)",
        strokeColor: "rgba(220,220,220,1)",
        pointColor: "rgba(220,220,220,1)",
        pointStrokeColor: "#fff",
        pointHighlightFill: "#fff",
        pointHighlightStroke: "rgba(18,175,203,1)",
        data: [0,"2539","8091","9119","15621","13293","6892","6486","6605","931"] ,

        label: "Total Calls Accepted",
        fillColor: "rgba(34,186,160,0)",
        strokeColor: "rgba(34,186,160,1)",
        pointColor: "rgba(34,186,160,1)",
        pointStrokeColor: "#fff",
        pointHighlightFill: "#fff",
        pointHighlightStroke: "rgba(75,131,13,1)",
        data: [0,"274","1443","1069","377","22","1268","1201","1356","236"] ,

        label: "Eligible For Offers",
        fillColor: "rgba(41,121,255,0)",
        strokeColor: "rgba(41,121,255,1)",
        pointColor: "rgba(41,121,255,1)",
        pointStrokeColor: "#fff",
        pointHighlightFill: "#fff",
        pointHighlightStroke: "rgba(0,78,203,1)",
        data: [0,0,0,"2854","5573","6846","3270","3007","3413","649"]
        ]
        ;

        var chart1 = new Chart(ctx1).Line(data1,
        scaleShowGridLines: true,
        scaleGridLineColor: "rgba(0,0,0,.05)",
        scaleGridLineWidth: 1,
        scaleShowHorizontalLines: true,
        scaleShowVerticalLines: true,
        bezierCurve: true,
        bezierCurveTension: 0.4,
        pointDot: true,
        pointDotRadius: 4,
        pointDotStrokeWidth: 1,
        pointHitDetectionRadius: 20,
        datasetStroke: true,
        datasetStrokeWidth: 2,
        datasetFill: true,
        responsive: true
        );

        document.getElementById('legends').innerHTML = chart1.generateLegend();

        .chart-legend li span 
        display: inline-block;
        width: 12px;
        height: 12px;
        margin-right: 5px;

        <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.1/Chart.min.js"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
        <div style="width: 100%; height: 100%;">
        <canvas id="chart1" style="width: 100%; height: auto;"></canvas>
        </div>
        <div id="legends" class="chart-legend"></div>





        var ctx1 = document.getElementById("chart1").getContext("2d");
        var data1 =
        labels: ["2018-11-05","2018-11-06","2018-11-07","2018-11-08","2018-11-09","2018-11-10","2018-11-11","2018-11-12","2018-11-13","2018-11-14"],
        datasets: [

        label: "Total Calls received",
        fillColor: "rgba(220,220,220,0)",
        strokeColor: "rgba(220,220,220,1)",
        pointColor: "rgba(220,220,220,1)",
        pointStrokeColor: "#fff",
        pointHighlightFill: "#fff",
        pointHighlightStroke: "rgba(18,175,203,1)",
        data: [0,"2539","8091","9119","15621","13293","6892","6486","6605","931"] ,

        label: "Total Calls Accepted",
        fillColor: "rgba(34,186,160,0)",
        strokeColor: "rgba(34,186,160,1)",
        pointColor: "rgba(34,186,160,1)",
        pointStrokeColor: "#fff",
        pointHighlightFill: "#fff",
        pointHighlightStroke: "rgba(75,131,13,1)",
        data: [0,"274","1443","1069","377","22","1268","1201","1356","236"] ,

        label: "Eligible For Offers",
        fillColor: "rgba(41,121,255,0)",
        strokeColor: "rgba(41,121,255,1)",
        pointColor: "rgba(41,121,255,1)",
        pointStrokeColor: "#fff",
        pointHighlightFill: "#fff",
        pointHighlightStroke: "rgba(0,78,203,1)",
        data: [0,0,0,"2854","5573","6846","3270","3007","3413","649"]
        ]
        ;

        var chart1 = new Chart(ctx1).Line(data1,
        scaleShowGridLines: true,
        scaleGridLineColor: "rgba(0,0,0,.05)",
        scaleGridLineWidth: 1,
        scaleShowHorizontalLines: true,
        scaleShowVerticalLines: true,
        bezierCurve: true,
        bezierCurveTension: 0.4,
        pointDot: true,
        pointDotRadius: 4,
        pointDotStrokeWidth: 1,
        pointHitDetectionRadius: 20,
        datasetStroke: true,
        datasetStrokeWidth: 2,
        datasetFill: true,
        responsive: true
        );

        document.getElementById('legends').innerHTML = chart1.generateLegend();

        .chart-legend li span 
        display: inline-block;
        width: 12px;
        height: 12px;
        margin-right: 5px;

        <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.1/Chart.min.js"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
        <div style="width: 100%; height: 100%;">
        <canvas id="chart1" style="width: 100%; height: auto;"></canvas>
        </div>
        <div id="legends" class="chart-legend"></div>






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 14 '18 at 5:27









        Udhay TitusUdhay Titus

        2,24611230




        2,24611230



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53293375%2fhow-to-fix-chartjs-legend-not-working-issue%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            這個網誌中的熱門文章

            What does pagestruct do in Eviews?

            Dutch intervention in Lombok and Karangasem

            Channel Islands