chartjs-node icon indicating copy to clipboard operation
chartjs-node copied to clipboard

How to set font file (foo.ttf)

Open katsube opened this issue 7 years ago • 1 comments

Hi, everyone. Thank you for the wonderful library.

If Japanese language is set as the label, it will not be output to the graph image.

const chartJsOptions = {
    type: 'line',
    data: {
        labels: ['8/1','8/2','8/3'],
        datasets: [{
                label: "チャート",   // Here!
                borderColor: 'rgb(255, 0, 0)',
                data: [20, 26, 12]
        }]
    }
}

Is there a way to set a font file(foo.ttf) or solve this?

environment

  • macOS 10.13.6
  • Node.js v10.1.0
  • chart.js 2.7.2
  • chartjs-node 1.7.1
  • cairo stable 1.14.12

Thanks.

katsube avatar Aug 06 '18 15:08 katsube

Sorry, I forgot to upload the result.

const chartJsOptions = {
    type: 'line',
    data: {
        labels: ['8/1','8/2','8/3'],
        datasets: [{
            label: "チャート",
            borderColor: 'rgb(255, 0, 0)',
            data: [20, 26, 12]
        },
        {
            label: "Chart",
            borderColor: 'rgb(0, 255, 0)',
            data: [10, 12, 30]
        }]
    }
};

testimage

katsube avatar Aug 06 '18 15:08 katsube