mariusmuntean / ChartJs.Blazor

Brings Chart.js charts to Blazor
https://www.iheartblazor.com/
MIT License
676 stars 151 forks source link

Is it possible to create stacked horizontal bar charts, and if so how can I do it? #211

Open harryhain opened 1 year ago

harryhain commented 1 year ago

Describe your question

Is it possible to create stacked horizontal bar charts, and if so how can I do it?

Which Blazor project type is your question related to?

Server-Side

Which charts is this question related to?

Bar Charts

JavaScript equivalent

options: { indexAxis: 'y', scales: { x: { stacked: true }, y: { stacked: true } } }

Additional context

Add any additional context, screenshots or code about the question here.

fukicycle commented 1 year ago

I just had trouble implementing it too. But I was able to implement it.

       _barConfig1 = new BarConfig(true)
            {
                Options = new BarOptions
                {
                    Responsive = true,
                    Tooltips = new Tooltips
                    {
                        Mode = InteractionMode.Index,
                        Intersect = false
                    },
                    Scales = new BarScales
                    {
                        YAxes = new List<CartesianAxis>
                    {
                        new BarCategoryAxis
                        {
                            Stacked = true
                        }
                    },
                        XAxes = new List<CartesianAxis>
                    {
                        new BarLinearCartesianAxis
                        {
                            Stacked = true
                        }
                    }
                    }
                }
            };