jwstegemann / fritz2

Easily build reactive web-apps in Kotlin based on flows and coroutines.
https://www.fritz2.dev
MIT License
627 stars 25 forks source link

Chart.js Integration #854

Closed objektwerks closed 4 months ago

objektwerks commented 5 months ago

Feature: Chart.js Integration

Proof: KVision has Chart.js integrated support.

Proposal: Integrate the KVision Chart.js types into Fritz2.

Resources

  1. KVision Chart Module - Kotlin Chart.js Types
  2. KVision Charts - Tutorial
Lysander commented 4 months ago

Thank you for the proposal.

Can you be more precise, how or on which level you would like to have support for such charts? Perhaps you could sketch some imaginary code, to show your idea?

As fritz2 is a general purpose UI-Framework, we try to avoid to integrate some specific library (there are many others, like apexcharts for example). After having a look into the charts.js documentation, I could of course imagine some helper factories in order to bring the JS-API more into the declarative fritz2 style. After all that would be more or less wrapping its API into some "custom" fritz2 fitting API.

I think this would be great for some charts-fritz2-project as 3rd party add-on for fritz2 based programs.

objektwerks commented 4 months ago

KVision has already done the heavy lifting by generating the Kotlin types for Chart.js ( see the above KVision Chart Module link for the code ). So integration into Fritz2 or Fritz2Charts, for instance, should be quite doable, especially by the Fritz2 maintainers and/or veterans. :)

I come from a Scala-ScalaJs background. So my KotlinJs knowledge and experience is limited. But KotlinJs appears to work similarly to ScalaJs. Yet both libraries, IMHO, have one major weakness - the lack of a chart library, integrated or external, with KVision being the exception. Like you, though, I much prefer Fritz2. :)

I hope that clarifies my proposal. BTW, Fritz2 is a most impressive library!

Note: ApexCharts is quite nice. And it has Typescript types. But does KotlinJs have a tool to correctly generate Kotlin types from Typescript types? Dukat is all I could find. I haven't tried it, though. But it hasn't been maintained in a few years.

Lysander commented 4 months ago

KVision has already done the heavy lifting by generating the Kotlin types for Chart.js ( see the above KVision Chart Module link for the code ). So integration into Fritz2 or Fritz2Charts, for instance, should be quite doable, especially by the Fritz2 maintainers and/or veterans. :)

That's probably kinda true - sadly, our time is quite limited and we definitely focus on getting the lib stable so we can finally release the 1.0 this year! :-)

But if you dare the adventure, we would definitely support you (or anybody, who tries to to that!)

I hope that clarifies my proposal. BTW, Fritz2 is a most impressive library!

Thank you very much!

Note: ApexCharts is quite nice. And it has Typescript types. But does KotlinJs have a tool to correctly generate Kotlin types from Typescript types? Dukat is all I could find. I haven't tried it, though. But it hasn't been maintained in a few years.

Sadly this is still a major pain point with KotlinJs - as Kotlin lacks language support for general sum-types, it is imho clear, that there is some "type impedance"-issue when it comes to wrap some TypeScript-API. But imho projects like Dukat should get more love by the KotlinJs devs! Sadly, the opposite seems to be true, as it was announced in some release note last year iirc, that they will stale the development. That is, wrapping TS-APIs in Kotlin is no fun at all.

If we could reuse the work done by KVision, that would be of course the major deal concerning this proposal!

I still would consider this not to be part of the core framework, but it would be useful as some add-on project!

objektwerks commented 4 months ago

Thanks for your comments. Very informative on the KotlinJs space.

Once I finish building a meaningful Fritz2 prototype; I just might take a stab at fritz2-chartjs. :)

objektwerks commented 4 months ago

Just hit the KMP-Gradle-Intellij-Ksp wall. So this might take awhile. ;) Closing this issue. Cheers! :)