Comments (5)
I need help with this too @areski . Is the issue that it assigns the same ID to each chart so the second one overwrites the first one?
from django-nvd3.
Same here @areski !
from django-nvd3.
To achieve this, you can simply define your data dict (the one you give to render_to_respone)
like this:
data = {
'charttype1': charttypea,
'chartdata1': chartdataa,
'chartcontainer1': chartcontainera,
'extra1': {
'x_is_date': False,
'x_axis_format': '',
'tag_script_js': True,
'jquery_on_ready': False,
},
'charttype2': charttype,
'chartdata2': chartdata,
'chartcontainer2': chartcontainer,
'extra2': {
'x_is_date': True,
'x_axis_format': '%d %b %Y %H',
'tag_script_js': True,
'jquery_on_ready': False,
}
}
And then, in your template:
{% load nvd3_tags %}
<head>
{# Jquery CDN : Needed when using jquery_on_ready=True #}
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
{% include_chart_jscss %}
{% load_chart charttype1 chartdata1 chartcontainer1 extra1 %}
{% load_chart charttype2 chartdata2 chartcontainer2 extra2 %}
</head>
<body>
{% include_container chartcontainer1 %}
<br>
{% include_container chartcontainer2 %}
</body>
from django-nvd3.
To achieve this, you can simply define your data dict (the one you give to render_to_respone)
like this:
data = { 'charttype1': charttypea, 'chartdata1': chartdataa, 'chartcontainer1': chartcontainera, 'extra1': { 'x_is_date': False, 'x_axis_format': '', 'tag_script_js': True, 'jquery_on_ready': False, }, 'charttype2': charttype, 'chartdata2': chartdata, 'chartcontainer2': chartcontainer, 'extra2': { 'x_is_date': True, 'x_axis_format': '%d %b %Y %H', 'tag_script_js': True, 'jquery_on_ready': False, } }
And then, in your template:
{% load nvd3_tags %} <head> {# Jquery CDN : Needed when using jquery_on_ready=True #} <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script> {% include_chart_jscss %} {% load_chart charttype1 chartdata1 chartcontainer1 extra1 %} {% load_chart charttype2 chartdata2 chartcontainer2 extra2 %} </head> <body> {% include_container chartcontainer1 %} <br> {% include_container chartcontainer2 %} </body>
Hey @Etiennepi , I used your solution for pie chart, but it doesn't work.
from django-nvd3.
I got it working. Try the following code:
In views.py:
# ... code above omitted....
chartcontainer1 = 'piechart_container1' # container name
chartcontainer2 = 'piechart_container2' # container name
data = {
'charttype1': charttype,
'chartdata1': chartdata,
'chartcontainer1': chartcontainer1,
'extra1': {
'x_is_date': False,
'x_axis_format': '',
'tag_script_js': True,
'jquery_on_ready': False,
},
'charttype2': charttype,
'chartdata2': chartdata,
'chartcontainer2': chartcontainer2,
'extra2': {
'x_is_date': False,
'x_axis_format': '',
'tag_script_js': True,
'jquery_on_ready': False,
}
}
In template (such as piechart.html):
{% load nvd3_tags %}
<head>
{% include_chart_jscss %}
{% load_chart charttype1 chartdata1 chartcontainer1 extra1 %}
{% load_chart charttype2 chartdata2 chartcontainer2 extra2 %}
</head>
<body>
<h1>Fruits vs Calories</h1>
{% include_container chartcontainer1 %}
<br>
{% include_container chartcontainer2 %}
</body>
Here's a sample screenshot (two pie-charts based on the same dataset):
from django-nvd3.
Related Issues (20)
- Documentation is not helpful HOT 3
- Example Error: argument of type 'bool' is not iterable
- Update python-slugify [required: ==1.1.4]
- The chart can't show with error "Uncaught TypeError: a.dispatch.render_start is not a function" HOT 1
- Impossible add more than one tooltip for char
- Multibarchart x axis with text labels does shows NaN% in chart , but gets label correct in tooltip HOT 2
- Separate x for series
- data:87 Uncaught TypeError: chart.tooltipContent is not a function HOT 3
- Doesn't work demo project
- long xAxis Label
- Data from database HOT 2
- Rotate x-axis labels HOT 1
- GET /static/nvd3/build/nv.d3.min.css HTTP/1.1" 404 HOT 1
- Custom Tooltip
- Is that possible for add hyperlink to Chart?
- Getting the error "a.dispatch.render_start is not a function" HOT 4
- NaN% values displayed at x-axis of Multibar chart
- Vertical guideline? HOT 1
- pip install error HOT 3
- NVD3 not displaying the graph HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-nvd3.