Git Product home page Git Product logo

Comments (9)

atodorov avatar atodorov commented on August 15, 2024 1

Hi @alabarga,
I think this is not a bug in the sence that loading multiple charts is possible. We're just not doing it right.

I read through the code and figured it out. See the comments in templatetags/chartit.py.

First argument to load_charts is a Chart list(or object), the second is comma separated list of HTML IDs where the charts need to be rendered.

Here's my code, which works:

 return render(request, 'index.html',
                 {
                    'charts' : [chart_1, chart_2],
                 }
             )


{{ charts|load_charts:"chart_1,chart_2" }}

<div id="chart_1">Chart will be rendered here</div>
<div id="chart_2">Chart will be rendered here</div>

I also think I know the reason this is designed in such a way. Looking at the result it is two script tags - one to load the HighCharts javascript file and the second to define an array of all chart objects to display in the page.

This said, if we wanted to use the syntax with two calls then we should have something like:

{% load_highchart_js_files %}
{{ linechart|load_chart:"container1"}}
{{ barchart|load_chart:"container2"}}

from django-chartit.

atodorov avatar atodorov commented on August 15, 2024

+1 on this.

from django-chartit.

akipkemei avatar akipkemei commented on August 15, 2024

It just worked as well for me, many thanks @atodorov and @alabarga

from django-chartit.

bbratchiv avatar bbratchiv commented on August 15, 2024

Thanks guys!

from django-chartit.

ndamulelonemakh avatar ndamulelonemakh commented on August 15, 2024

still works in 2016!

from django-chartit.

smaislin186 avatar smaislin186 commented on August 15, 2024

It is not working quite like documented here anymore. The first graph shows up fine, but the second does not appear with the below code.
{% load chartit %} {{chart_list|load_charts:"cht_1,cht_2"}} {% block main %} <p>Home</p> <body> <div id="cht_1">{{chart_list|load_charts:"cht_1"}}</div> <div id="cht_2">{{chart_list|load_charts:"cht_2"}}</div> </body> {% endblock %}

If I remove the "{{chart_list|load_charts:"cht_1"}}" from the actual html tags, it does not work at all.
I found the below does work:
{% load chartit %} {{chart_list|load_charts:"cht_1,cht_2"}} {% block main %} <p>Home</p> <body> <div id="cht_1">{{chart_list|load_charts:"cht_1,cht_2"}}</div> <div id="cht_2">{{chart_list|load_charts:"cht_1,cht_2"}}</div> </body> {% endblock %}

from django-chartit.

atodorov avatar atodorov commented on August 15, 2024

@smaislin186 your HTML doesn't look right and honestly I have no idea why it works or doesn't work in the two cases you describe. Here are a few notes for you though:

  • chart_list|load_charts should be called only once in the entire HTML page. it's job is to render the javascript charts into the container IDs given as parameters.
  • Usually chart_list|load_charts is put in the <head> section of the HTML, right after the load chartit template tag. From your description I get the feeling these two are somewhere in the <body>
  • Checkout the templates in demoproject/ to see how it is done.

and finally: this piece of code hasn't been changed in years, only documentation was updated recently. Maybe the documentation isn't 100% clear but I don't think it is broken. If this still doesn't work for you please post a link to your entire HTML template.

from django-chartit.

SandeepKumar2016 avatar SandeepKumar2016 commented on August 15, 2024

Hi, Please help me with line charts. I have posted a question in stack, please suggest.

https://stackoverflow.com/questions/46240253/getting-load-chartit-on-my-browser-charts-are-not-loading-using-chartit

from django-chartit.

atodorov avatar atodorov commented on August 15, 2024

@SandeepKumar2016 answered on SO. Sorry for the delay.

from django-chartit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.