Draw LineChart entirely on Canvas, including indicators and labels#164
Draw LineChart entirely on Canvas, including indicators and labels#164brayellison wants to merge 2 commits intoehsannarmani:masterfrom
Conversation
… canvas instead of delegating to composables cleanup required, but it's working general cleanup, remove unused, apply formatting bugfix: coerce to inset bounds, check before `showPopup` unnecessary remove draw grid in favor of calculated heights/widths of indicators/labels, add `drawTicks`, use ticks passed from `insetDrawScope` within `LineChartCanvas`. Added test cases to initial chart in `PhoneSample` couple fixes fix errors after removing dividerProperties
ba2e51f to
968e96a
Compare
…djust inset calculation to avoid crash on screen orientation change change `clipRect` to just on the paths, avoids clipping dots on the boundary, cleanup refactor `Bounds` and `InsetPad` into utilities, add handling of label rotation update `PhoneSample` with label rotation fix imports
55daaf1 to
becd496
Compare
|
Any further updates on this? Also would it be possible to extract x,y values and provide it as an argument (similar to the Slider with SliderState and onValueChange) to the LineChart composable. This way, we can use the values elsewhere and not just be limited to viewing it in the popup. For example, in the steps per minute graph, I would be able to see the exact steps/minute value at minute 4 and display it in a Text composable. |
@kritan10 That would be interesting, I don't think it would be too difficult. I made another branch off this one that defines a space object to convert points to offsets, which you could inverse to get points from offsets. Here's a link, but it's not the latest commit. I can push up the latest commit, it may need a little cleanup first. It's a significant overhaul, so I was waiting for this to get merged, then I was gonna open another PR. Example from current iteration: |


The idea is that drawing the indicators and labels directly on the canvas opens up many additional features:
Before:

After:

I started out updating this for personal use, but I thought it might be helpful for the project overall.
One more thing that does need to be looked at, the rotation of the labels was removed. It shouldn't be difficult to add that back in within this framework though.
Let me know if there's anything else you'd like to see.