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

Refactor BarChart with DrawScope functions #62

Open
wants to merge 1 commit into
base: main-old
Choose a base branch
from

Conversation

yingding
Copy link

Thanks for the great work to make this fantastic charty library.
It would be really great if the charty can refactor all the charts composable function into useful DrawScope function.

This will be a fantastic feature to make dynamic graphs for Wear OS 3 by google Material Tiles with the horologist lib (https://github.com/google/horologist).

The most open source compose chart libs are strictly depends on Canvas composable, if Charty can ease this dependency. It can become a valuable compose chart lib to make dynamic Tile charts for millions of potential Wear OS Material Tiles apps.

@hi-manshu
Copy link
Owner

if we expose the drawScope functions, it will be come too much exposed.
Do you think exposing a module for wearOS will be better?

@hi-manshu hi-manshu added the question Further information is requested label Jan 19, 2023
@hi-manshu hi-manshu self-assigned this Jan 19, 2023
@yingding
Copy link
Author

yingding commented Jan 19, 2023

@hi-manshu I not sure if i understand you correctly what you mean with exposing a module. The issue is that for the wear os tile api there is no renderer system behind it. Please see my resent PR to demonstrate how to build a dynamic bar chart for wear os 3 tile api (yingding/horologist@85db914)

Please see the following code example, runLive is a Wear OS systemImageResource, which will be generated directly from the DrawScope, the Canvas Composable can not be called.

        // draw with DrawScope, and set the size
        val runLive = canvasToImageResource(Size(160f, 100f), density) {
            /* DrawScope extension functions */
            gradientShadeBarChart(
                state = state,
                gradientBeginColor = BarChartHelper.gradientBeginColor,
                gradientEndColor = BarChartHelper.gradientEndColor
            )
        }

If it will be possible to create a DrawScope extension module, that would be really great. I am not sure if it makes more work, since the composable state e.g. remember can not be executed inside the Wear OS tile api. It is more like a static image which will be regenerated on the Wear OS tile api.

I would be love to discuss more in details with you in this matter.

@yingding
Copy link
Author

yingding commented Jan 19, 2023

Please refer to the ADS talk regarding this matter that Wear os Tile api has no render system and why DrawScope extension api are necessary https://youtu.be/w3KvfvgUIds?t=1033

Update: I think actually it would be a great idea to capsule the DrawScope functions into a module, and the Composable functions will hold the states and call the underline drawing functions for charts inside this DrawScope module. This way it is also possible to use some canvasToImage function to export the charty charts to downloadable image :)

@hi-manshu
Copy link
Owner

Hey buddy,
I was attending the said talk live. I will check your PR next week and come with an update!

@yingding
Copy link
Author

Thank you so much, and I am really happy to have your support on this matter.

@yingding
Copy link
Author

yingding commented Feb 6, 2023

@hi-manshu Kindly asking if you have an update on this issue. I would love to contribute and keep this moving forward.

@hi-manshu
Copy link
Owner

Hey @yingding
I will take this on priority from next week,. I was keeping busy and will start on it

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

Successfully merging this pull request may close these issues.

None yet

2 participants