Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stacked bar with multiples bars widths #67

Open
miguelwycho opened this issue Nov 5, 2018 · 0 comments
Open

Stacked bar with multiples bars widths #67

miguelwycho opened this issue Nov 5, 2018 · 0 comments

Comments

@miguelwycho
Copy link

I needed to create a stacked bar chart with multiple bars widths so i came with this solution:

chartJsOptions = {
type: 'bar',

    data: {
        labels: [],
        datasets: [
            {
                label: "Ofertado",
                data: [],
                borderColor: 'rgb(83,141,213)',
                borderWidth: 3,
                xAxisID: 'x-axis-2'

            },

            {
                label: '',
                data: [],
                borderColor: '#e26b0a',
                borderWidth: 3,
                xAxisID: 'x-axis-1'
                // yAxisID: '1',
            },

            {
                label: '',
                data: [],
                borderColor: '#961709',
                xAxisID: 'x-axis-3',
                borderWidth: 3,
            },

        ],
    }
    ,
    options: {
        scales: {
            xAxes: [

                {
                    stacked: true,
                },
                {
                    id: 'x-axis-2',
                    display: false,
                    type: 'category',
                    barThickness: 50,
                    stacked: true,
                },
                {
                    id: 'x-axis-3',
                    type: 'category',
                    display: false,
                    barThickness: 40,
                    stacked: true,
                },
                {
                    id: 'x-axis-1',
                    type: 'category',
                    display: false,
                    barThickness: 30,
                    stacked: true,
                }
            ],
            yAxes: [{
                stacked: false,

            }
            ]
        },
        title: {
            display: true,
            text: ''
        }
    }
};

the widths worked but the bars are out of place and i can't get it right.
testimage

any solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant