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

enhancement to support horizontal bar chart. #113

Open
kw2019ltd opened this issue Nov 16, 2019 · 36 comments · May be fixed by #1803
Open

enhancement to support horizontal bar chart. #113

kw2019ltd opened this issue Nov 16, 2019 · 36 comments · May be fixed by #1803

Comments

@kw2019ltd
Copy link

enhancement to support horizontal bar and stacked bar charts.

@imaNNeo imaNNeo added the enhancement New feature or request label Nov 16, 2019
@j4nk3e
Copy link
Contributor

j4nk3e commented Jan 4, 2020

I'm working on horizontal bar charts:
https://github.com/juumixx/fl_chart/commits/horizontal-bar-chart

Things that are still not behaving nicely are backdraw bars and stack items. The rest should be production ready.

@ksankumar
Copy link

Any update for horizontal bar chart?

@eripe970
Copy link

Any update on this?

@imaNNeo
Copy link
Owner

imaNNeo commented Sep 23, 2020

I'm busy as a bee 😢😢
I appreciate your help and your PRs

@imaNNeo
Copy link
Owner

imaNNeo commented Jan 30, 2021

We added StackedBarChart feature. I remove it from the title. Now we just need the horizontal bar chart.
Thanks!

@imaNNeo imaNNeo changed the title enhancement to support horizontal bar and stacked bar charts. enhancement to support horizontal bar chart. Jan 30, 2021
@imaNNeo
Copy link
Owner

imaNNeo commented Feb 17, 2021

There is a temporary workaround mentioned here

@2shrestha22
Copy link

Any update on this?

@imaNNeo
Copy link
Owner

imaNNeo commented Jun 8, 2021

Not yet!

@2shrestha22
Copy link

2shrestha22 commented Jun 8, 2021

There is a temporary workaround mentioned here
@imaNNeoFighT
Okay, do you have any idea about rotating TooltipIndicators,

@imaNNeo
Copy link
Owner

imaNNeo commented Jun 8, 2021

Yes, it is on the way here.

@sawirricardo
Copy link

Hi, @imaNNeoFighT any updates on this? Thank you

@imaNNeo
Copy link
Owner

imaNNeo commented Oct 14, 2021

Hi @sawirricardo. Not yet sir!

@spoeck
Copy link

spoeck commented Jun 8, 2022

Hi @imaNNeoFighT , is there any update about the horizontal bar chart?

@imaNNeo
Copy link
Owner

imaNNeo commented Jun 10, 2022

Hi @spoeck.
Unfortunately, not yet!

@akshatj427
Copy link

Hi @imaNNeoFighT i have recently started working with BarCharts in flutter and came across the fl_chart library as it had the highest popularity score. The current requirement for the app i am developing requires us to create a horizontal bar chart, would love to see it added to the library, is there any update on when can we expect it to be added?

@imaNNeo
Copy link
Owner

imaNNeo commented Jun 17, 2022

Hi @akshatj427
Unfortunately, I'm not working full-time on this project (I hope I could do)
I work here in my free and leisure time. That's why everything is a little bit slow.

At the moment you can give a thumb up to make it a high-priority issue.
And also donation helps me a lot to put more time into it.

@imaNNeo
Copy link
Owner

imaNNeo commented Jun 17, 2022

I forgot to tell you that you can also contribute to developing this feature! You can start by reading our guidelines.

@vishnuagbly
Copy link

Hi @imaNNeoFighT, is there any update on this?

@Mohammedqwasmeh
Copy link

any update on this?

@ParsaBarati
Copy link

Any updates?

@huynhmytuan
Copy link

Have any updates for this?

@imaNNeo imaNNeo pinned this issue Feb 18, 2023
@zs-dima
Copy link

zs-dima commented Feb 21, 2023

Any updates are welcome

@alexandr-efimov
Copy link

Hi, are there any updates except workaround with rotation? Thanks

@svki0001
Copy link

svki0001 commented Jun 3, 2023

Any updates?

@Flynn2018
Copy link

Does this plugin support horizontal bar chart now? If yes, where can find an example?

@StnFlu
Copy link

StnFlu commented Jul 17, 2023

Any updates?

@KinsleySen
Copy link

KinsleySen commented Jul 18, 2023

hi guys, this might be a workaround not for everyone but i currently using the line chart as a horizontal bar and the result like this

image

@amirudev
Copy link

Is there any updates for Horizontal Bar Chart ?

@imaNNeo
Copy link
Owner

imaNNeo commented Aug 21, 2023

Hi, unfortunately, I couldn't find enough free time to do that yet.
Please stay tuned, you can also be my sponsor to motivate me, then I can put more of time into this project.

@wanglang
Copy link

any update on this?

@ThanhSon232
Copy link

ThanhSon232 commented Feb 19, 2024

y'all can wrap a RotatedBox outside and set quarterTurns: 1 to make it horizontal. That can be a temporary solve for this.

Screenshot 2024-02-19 at 14 49 33

simulator_screenshot_9294622F-8F0A-4637-BFA5-6B8087443F73

@SereinYx
Copy link

SereinYx commented Apr 11, 2024

hi all, I tried to solve this problem with the existing api, so you can refer to it.
I use the 0.67.0 version

`
RotatedBox(quarterTurns: -3,
child: BarChart(
BarChartData(
...
));

BarTouchTooltipData(
rotateAngle: 270,
);

SideTitleWidget(
angle: 4.7,
);
`
截屏2024-04-11 20 35 12

@Woozy1
Copy link

Woozy1 commented Jul 14, 2024

Hi, I am having problems with aligning bottom titles (left titles after rotating) to the left, everything i tried it just looks like its centered.

First i rotated chart with
RotatedBox(quarterTurns: 1,

This is my code for titles:

Widget bottomTitlesLanguages(double value, TitleMeta meta) {
    const style = TextStyle(fontSize: 10);
    if (value.toInt() < 0 || value.toInt() >= languageData.length) {
      return Container();
    }
    return SideTitleWidget(
      axisSide: meta.axisSide,
      space: 10, // Add space to separate the labels from the axis
      child: Transform.rotate(
        angle: -1.5708, // Rotate 90 degrees counter-clockwise (in radians)
        child: Container(
          alignment: Alignment.centerLeft, // Align text to the left
          child: Text(
            languageData[value.toInt()].x,
            style: style,
          ),
        ),
      ),
    );
  }

image

@techouse
Copy link

techouse commented Jul 14, 2024

A basic version of this could be easily implemented using FractionallySizedBox.

@joceperin
Copy link

Hi, I am having problems with aligning bottom titles (left titles after rotating) to the left, everything i tried it just looks like its centered.

First i rotated chart with RotatedBox(quarterTurns: 1,

This is my code for titles:

Widget bottomTitlesLanguages(double value, TitleMeta meta) {
    const style = TextStyle(fontSize: 10);
    if (value.toInt() < 0 || value.toInt() >= languageData.length) {
      return Container();
    }
    return SideTitleWidget(
      axisSide: meta.axisSide,
      space: 10, // Add space to separate the labels from the axis
      child: Transform.rotate(
        angle: -1.5708, // Rotate 90 degrees counter-clockwise (in radians)
        child: Container(
          alignment: Alignment.centerLeft, // Align text to the left
          child: Text(
            languageData[value.toInt()].x,
            style: style,
          ),
        ),
      ),
    );
  }

image

In your Container add the width
image
image

@jeerovan
Copy link

Meanwhile, if you just need bar-chart

import 'package:flutter/material.dart';

class BarChartWidget extends StatelessWidget {
  final List<double> barData; // Data for bar lengths
  final List<String> yLabels; // Labels for the Y-axis
  final double maxValue; // Maximum value to scale the bars

  const BarChartWidget({super.key, 
    required this.barData,
    required this.yLabels,
    required this.maxValue,
  }) : assert(barData.length == yLabels.length,
            "Bar data and labels must have the same length");

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.all(16.0),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: List.generate(
          barData.length,
          (index) {
            double barWidth = (barData[index] / maxValue) * 300; // Bar scaling
            return Padding(
              padding: const EdgeInsets.symmetric(vertical: 4.0),
              child: Row(
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  // Y-axis label
                  SizedBox(
                    width: 150,
                    child: Text(
                      yLabels[index],
                      style: const TextStyle(fontSize: 14),
                    ),
                  ),
                  // Horizontal bar
                  Container(
                    height: 20,
                    width: barWidth,
                    color: Colors.blue,
                  ),
                ],
              ),
            );
          },
        ),
      ),
    );
  }
}

MrRoy121 added a commit to MrRoy121/fl_chart that referenced this issue Dec 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.