6
Wombat
4y

What package do you recommend for charts with Laravel?

Comments
  • 1
  • 3
    Perhaps chartjs?
  • 4
    I don't think displaying charts is dependent on the backend much right?

    I think the order goes about this: ChartJS -- Highcharts -- Plotly -- D3, that is from a very simple graph solution where you have limited control/customization options, to a very flexible but more complex library which requires more coding for each graph.

    For some purposes I actually do prefer backend rendering, in which case I tend to use a python lambda/cloudfunction, together with the very powerful matplotlib module.
  • 2
    The advantage of JS libs is that it's easy to just set up an API endpoint which provides the JSON graph data, and dynamically update the graph continuously (using a repeating API call, or sexier: using websockets). You can animate the graph, and let it respond to user input events, like filtering & zooming.

    The advantage of backend rendering is performance & compatibility. You can dump renders as PNGs to be included in the page (for max device compatibility), or go as crazy as inlining minified SVG snippets straight into a minimalistic plain HTML page (for max performance).

    Of course, backend rendering is only suitable for non-dynamic historical data, such as periodically generated reports/infographics.
  • 1
    Eh?
    You should really do that client-side.
  • 2
    @PrivateGER Most of the time, but it depends a bit on the target audience, and method of delivery.

    For all we know, Wombat is using a Laravel backend to distribute PDF reports full of bar charts, or needs to show a plot on an e-ink display connected to an Arduino which connects to a Laravel server. 😛
  • 1
    serve them a csv and a link to google sheets ;)
  • 0
    @bittersweet @alexbrooklyn @PrivateGER yeah sure, of course the obvious solution is to use front end js frameworks. But I also found Laravel packages or wrapper like Lavacharts or Larapex Charts.
  • 1
    @Wombat I personally would advise against those, unless you know for sure you will always use Blade.

    Most Laravel projects eventually dump Blade in favor of an API and separate frontend, and packages which tightly couple backend and frontend together will get in the way.
  • 0
    @bittersweet I didn't know that I am bound to blade when using them. 🙄 I use pug.... so fuck them.
  • 1
    @Wombat Yeah I usually stick to the principle that frontends (plural, I consider mobile apps and third party API consumers "frontends" as well) are 100% responsible for presentation.

    That means your data is provided by an API endpoint — and the frontends are free to choose what they do with that data. Maybe you want a D3 bar chart in the browser, but prefer a native Java Anycharts bar chart on Android. Or maybe one frontend just wants the raw data to display in a table.
  • 0
    Apexcharts
  • 0
    @edw1o1 Donkeyballs
  • 0
  • 0
    @edw1o1 What do you mean by Apexcharts? Should I avoid them? Do they cause cancer? Can I get pregnant by them? I am confused and concerned.
  • 1
    @Wombat dude, your question literally asks for a recommendation, I use apexcharts in my projects because they look modern, large variety of charts, multiple integration(js, angular, vue, react, php , etc...)
  • 0
    @edw1o1 now I get it thanks.
  • 1
    @Wombat Donkeyballs
  • 0
Add Comment