Conversation
jonathanloos
commented
Nov 16, 2023
- Add chartkick gem
- Add chartkick to importmap
- Add chartkick as dependency in gemspec
- Resolve comment on readme
|
Thoughts on updating the README with any required steps? I didn't try it, but basically all an app needs to do to leverage chartkick as part of matey would be to do the js includes? (any css includes?) |
|
Question (sorry for the delay!), adding chartkick might be overly opinionated? Or maybe that is a good thing. I'm thinking that a project may use an alternate charting library (like Apex), and they may chose to only use the text-based components. If this is true, then adding chartkick as a gem dep is going to force them to pull an unused gem into their project (correct)? I feel like the previous approach probably resulted in poor DX but also didn't impose any optional dependency. Again, maybe that is the stance that we want to take as chartkick is great. |
|
@krsyoung to close the loop here, I agree that adding a hard dependency for chartkick wouldn't be the best because Matey itself isn't named accordingly. Thinking about bootstrap_form it makes sense that it has a hard requirement on bootstrap (it's in the name). In the case of Matey, we don't have any indication that it's a hard requirement. An approach I've been contemplating is actually leveraging slots in VCs to allow for consumers to pass their charts in, where Matey can provide the data. I'll work on an example implementation and let you know! |
|
Looking at implementation I don't think it will work here without some additional refactoring. I was going with the idea we could approach as something like: <%= render(Matey::ChartComponent.new) do |component| %>
<% component.with_chart do %>
<%# custom charting code here %>
<%# would need access to a Matey service to put the data into charting tool %>
<% end %>
<% end %>But this would require each dataset available in each view component to also be exposed as a service or helper method such that the following would be possible: <%= render(Matey::ChartComponent.new) do |component| %>
<% component.with_chart do %>
<%= apex_line_chart matey_helper_method(@events), @options %>
<% end %>
<% end %>What are your thoughts on the move? Worth it? The opinionated "just include chartkick or apex" route would be much less work but also less flexible.. |