• Resolved andyro

    (@andyro)


    Hi, I have no problem adding a pie chart here: https://openbuilding.ca/tools/building-sankey/, but when I try to call the type of chart ‘sankey’ – I don’t appear to be calling the right script. Here there is a Charts.js community maintained chart option called ‘Sankey’ https://github.com/kurkle/chartjs-chart-sankey – how is it that I can call to display this chart in the canvas? I am pretty sure this is not doing it (even if it doesn’t refer to my fieldnames yet).

    import {Chart} from 'chart.js';
    import {SankeyController, Flow} from 'chartjs-chart-sankey'; Chart.register(SankeyController, Flow); const chart = new Chart(ctx, {
    type: 'sankey',
    data: dataObject
    }); const colors = {
    a: 'red',
    b: 'green',
    c: 'blue',
    d: 'gray'
    }; const getColor = (key) => colors[key]; const chart = new Chart(ctx, {
    type: 'sankey',
    data: {
    datasets: [{
    label: 'My sankey',
    data: [
    {from: 'a', to: 'b', flow: 10},
    {from: 'a', to: 'c', flow: 5},
    {from: 'b', to: 'c', flow: 10},
    {from: 'd', to: 'c', flow: 7}
    ],
    colorFrom: (c) => getColor(c.dataset.data[c.dataIndex].from),
    colorTo: (c) => getColor(c.dataset.data[c.dataIndex].to),
    colorMode: 'gradient', // or 'from' or 'to'
    /* optional labels / labels: { a: 'Label A', b: 'Label B', c: 'Label C', d: 'Label D' }, / optional priority / priority: { b: 1, d: 0 }, / optional column overrides */
    column: {
    d: 1
    },
    size: 'max', // or 'min' if flow overlap is preferred
    }]
    },
    });

    Thanks in advance, Andy

    • This topic was modified 10 months ago by andyro.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @andyro,

    Thank you very much for using our plugin.

    Our plugin includes the CFFCHART operation. It is a proxy for the Chart.js library. The CFFCHART operation allows you to register Chart.js plugins directly from the CFFCHART call. You don’t need to import the resources manually.

    Learn more about the CFFCHART operation by reading the following blog post:

    https://cff.dwbooster.com/blog/2019/05/27/charts

    Best regards.

Viewing 1 replies (of 1 total)
  • The topic ‘Create a Sankey Chart with CFF Charts’ is closed to new replies.