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

Change font family #36

Closed
manuelcodigobase opened this issue Jan 26, 2022 · 6 comments
Closed

Change font family #36

manuelcodigobase opened this issue Jan 26, 2022 · 6 comments

Comments

@manuelcodigobase
Copy link

Hi,

First, Thank you so much for this amazing packages. It's really good.

I've a problem with font family. In my theme, I'm using a custom font family, but the graph is not using it.

I've seen that there is a class called LabelCommonOptions, but there isn't a option to change font family. I've tried to wrap the LineChart class with a DefaultTextStyle widget, but it doesn't work too.

Is there any way to modify it?

Thanks.

@mzimmerm
Copy link
Owner

Hi @manuelcodigobase,

Thanks for using flutter_charts and for this report. Let me ask a question with context: From this issue, I understand you are using the same font family throughout the app. Are you doing that using something like this:

return MaterialApp(
  title: 'My App With My Fonts',
  theme: ThemeData(fontFamily: 'MyCustomFont'),
  home: const MyHomePage(),
);

?

If so, I am surprised flutter_charts do not pick it up in it's TextStyle. Can you please confirm, or describe how are you setting custom font family?

Once you confirm I will create a sample app and test it myself, then provide more useful help.

Separately, I also plan to add an example on how to override the ChartOptions so clients can set TextStyle that way. But for that to work, I think I need to make a change in the code.

Thanks,
Milan

@manuelcodigobase
Copy link
Author

Hello, again.

Yes, I'm setting custom from through the theme. In the same way that your show in your example.

Thank for responding so fast!

@mzimmerm
Copy link
Owner

@manuelcodigobase : Thanks for the follow up.

The fact the custom font is not picked up from the application theme is very interesing. Thanks for the confirmation, I will look into it separately.

In the meantime, I prepared a change with an example, that allows flutter_charts ChartOptions to set it's own font on labels (which can be set by client to the same or different font as the app). I will release this during the weekend. There is a minor API change in that area, but the example should clarify how to use it.

Milan

mzimmerm added a commit that referenced this issue Jan 28, 2022
#36. Example given in
ex34OptionsDefiningUserTextStyleOnLabels.
@mzimmerm
Copy link
Owner

@manuelcodigobase:

There is a new release 0.5.0, which should address this issue. Please take a look at

https://pub.dev/packages/flutter_charts

In particular the https://pub.dev/packages/flutter_charts/changelog and the example ex40LanguagesWithYOrdinalUserLabelsAndUserColors_lineChart in https://pub.dev/packages/flutter_charts#orgc6be307 .

There are some API changes in the area, hopefully minor, all described in the changelog.

Please let me know if this works for you or if you have any issues.

Milan

@manuelcodigobase
Copy link
Author

You are amazing! Thank you so much!!

It works perfect!

@mzimmerm
Copy link
Owner

@manuelcodigobase : Happy to hear it works for you. Thanks again for reporting,

Milan

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

2 participants