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

SideTitles for x value on BarChartData #342

Closed
tomosullivan8 opened this issue May 10, 2020 · 5 comments
Closed

SideTitles for x value on BarChartData #342

tomosullivan8 opened this issue May 10, 2020 · 5 comments
Labels
Bar Chart enhancement New feature or request

Comments

@tomosullivan8
Copy link

I've had a bit of an issue showing the date which I've used in as x for the BarChartGroupData and converting to the SideTitles for the group value.

It looks like the group value shows the index of the BarChartGroupData instead of the x value?

Can you let me know if there is a way to get the x value in the bottom: SideTitles?

I have been able to do it fine with the LineBarChart where it takes the x from the FLSpots, and the y value pulls through as expected for the left: SideTitle.

@imaNNeo
Copy link
Owner

imaNNeo commented May 12, 2020

Could you please show me your use-case?
I know what you mean roughly, but I'm not clear about it.
Thanks!

@tomosullivan8
Copy link
Author

I've included an example which should hopefully make it clear!

First, the BarChartGroupData where i've input my data to pull through onto the graph.

BarChartGroupData(
      x:  12,   /// This doesn't pull through to the X-axis (bottomTitles value).
      barRods: BarChartRodData(
          y: 72.0, /// This pulls through to the Y-axis (leftTitles value)
          width: 12.0,
      ),
    );

The FlTitlesData to show the data on the X and Y Axis.

titlesData: FlTitlesData(
        show: true,
        bottomTitles: SideTitles(
          interval: intervals,
          showTitles: true,
          textStyle: titleStyle(theme),
          getTitles: (double value) {
              return '$value'; // This doesn't pull through the X-axis from the above data.
          },
        ),
        leftTitles: SideTitles(
          showTitles: true,
          textStyle: titleStyle(theme),
          interval: 20.0,
          getTitles: (value) {
            return value.round().toString(); // This pulls through the Y-axis from above data.
          },
        ),
      ),

As you can see below, the 72 pulls through to the Y-Axis and the BarChartData with the intervals at 20.0, but the X-axis shows 0.0. instead of the 12.

image

I have been using the X-Axis to pull through the date in millisecondsSinceEpoch format, and it pulls through as expected for a line graph, but not for the bar chart.

image

Can you let me know if I'm using the BarChartGroupData incorrectly, or if there is a way around this?

@imaNNeo
Copy link
Owner

imaNNeo commented Jun 29, 2020

I agree with you,
It will be fixed in the new version, and thank you!

@imaNNeo imaNNeo added Bar Chart enhancement New feature or request labels Jun 29, 2020
@imaNNeo imaNNeo mentioned this issue Jun 29, 2020
@imaNNeo
Copy link
Owner

imaNNeo commented Jun 29, 2020

Check out the 0.10.1 version.
Cheers!

@imaNNeo imaNNeo closed this as completed Jun 29, 2020
@matthewrice345
Copy link

matthewrice345 commented Jul 15, 2020

Is there any way both the index and the x value can both be part of GetTitleFunction? After updating to 0.10.1 there is now no way to show the bottom tittles correctly within my application. I used the index to know where to pull the display data. I think there are valid use-cases for each piece of data.

ezmegy pushed a commit to ezmegy/fl_chart that referenced this issue Nov 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bar Chart enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants