score:7

Accepted answer

scalefontcolor is used to change the color of the labels.

instead of putting it in your datasets you should add it as a parameter in your function, like this:

window.myline = new chart(ctx).line(linechartdata, {
    responsive: true, scalefontcolor: "#ffffff" }
});

score:0

i found the issue together with kenan

<script>
    var randomscalingfactor = function(){ return math.round(math.random()*100)};
    var linechartdata = {
        labels : ["january","february","march","april","may","june","july"],
        datasets : [
            {
                label: "my second dataset",
                fillcolor : "rgba(255, 89, 114, 0.6)",
                strokecolor : "rgba(51, 51, 51, 1)",
                pointcolor : "rgba(255, 89, 114, 1)",
                pointstrokecolor : "#fff",
                pointhighlightfill : "#fff",
                pointhighlightstroke : "rgba(151,187,205,1)",
                maintainaspectratio: false,
                data : [1,2,10,7,3,1]
            }
        ]

    }

    window.onload = function(){
    var ctx = document.getelementbyid("canvas").getcontext("2d");

    window.myline = new chart(ctx).line(linechartdata, {
        responsive: true, scalefontcolor: "#ffffff" }
)};
</script>

it wasnt a normal datatype and i had to adjust the brackets properly!

thanks alot,looks great now.

score:3

in chart.js v3 it can be achieved with:

chart.defaults.color = "#ff0000";

score:4

for chart.js 3.x migration, text-labels on x and y axis are set this way:

set options to the following:

scales: {
  x: {
    ticks: {
      color: "red"
    }
  },
  y: {
    ticks: {
      color: "green"
    }
  }
}

similar solution is found if you want to change color of grid lines, inside of x / y value write

grid: {
  color: "white"
}

score:29

the working code is this:

chart.defaults.global.defaultfontcolor = "#fff";

have fun :)


Related Query

More Query from same tag