Chartjs-Chart.js legendcallback

0đź‘Ť

So here is a JSFiddle that has the solution I am looking for but with something missing that I am trying to achieve. I want to append to each legend. So if the legend prints “UUV” I want to append to that with a location to identify the user of the invoice type that is. Something like “UUV” + “Chassis”. Lets say what we are appending to it is the Invoice type, and I have a variable called ” var InvoiceTypes” and we pass it objects and we will most likely use a condition to know which location code like “UUV” matches its Invoice type then append the invoice type to the location code.

var options = {
    responsive: true,
    scaleBeginAtZero: true,
    legendTemplate: "<ul class=\"<%=name.toLowerCase()%>-legend\"> <% for (var i=0; i<segments.length; i++) {%> <li><span style=\"background-
color:<%=segments[i].fillColor%>\"></span> <%if(segments[i].label){%>
 <%=segments[i].label%>    <% } %> </li> <%}%> </ul>"
    }

    // PIE
    // PROPERTY TYPE DISTRIBUTION
    // context
    var ctxPTD = $("#property_types").get(0).getContext("2d");
    // data
    var dataPTD = [
        {
            label: "Single Family Residence",
            color: "#5093ce",
            highlight: "#78acd9",
            value: 52
        },
        {
            label: "Townhouse/Condo",
            color: "#c7ccd1",
            highlight: "#e3e6e8",
            value: 12
        },

Leave a comment