Django Highcharts
来源:互联网 发布:java教程视频百度云 编辑:程序博客网 时间:2024/06/07 08:12
Django Highcharts
Django Highchart will make it easier for you to display highcharts graphs.
Quickstart
Install django-highcharts using pip (we do recommend to do it in a virtualenv).
git clone https://github.com/novapost/django-highcharts.gitcd django-highchartspip install -e ./
To integrate it into a Django project, simply add it to your INSTALLED_APPS:
INSTALLED_APPS = [ # some interesting stuff... 'highcharts', # some other stuff...]
Don’t forget to set your STATIC_ROOT path and to run the following command to update the static files:
python manage.py collectstatic
You’re now ready to use the available views.
The view
from highcharts.views import HighChartsBarViewclass BarView(HighChartsBarView): categories = ['Orange', 'Bananas', 'Apples'] @property def series(self): result = [] for name in ('Joe', 'Jack', 'William', 'Averell'): data = [] for x in range(len(self.categories)): data.append(random.randint(0, 10)) result.append({'name': name, "data": data}) return result
The template
{% load staticfiles %}<!doctype html><html lang="en"><head> <meta charset="UTF-8"> <title>Hello</title> <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script type="text/javascript" src="{% static 'js/highcharts/highcharts.js' %}"></script> <script type="text/javascript"> $(function () { $.getJSON("{% url 'bar' %}", function(data) { $('#container').highcharts(data); }); }); </script></head><body><div id="container" style="height: 300px"></div></body></html>
Warning
Please note that the highcharts.js file should be called after the JQuery library.
Further documentation
- Views
- Common options
- Basic usage
- Available views
Indices and tables
- Index
- Module Index
- Search Page
0 0
- Django Highcharts
- django highcharts
- django中highcharts的用法
- 使用Django Highcharts制作图表
- Django 图表制作(By Highcharts)
- Django 如何使用Highcharts,其实我们可以摈弃Django-chartit
- highcharts
- HighCharts
- highcharts
- Highcharts
- Highcharts
- HighCharts
- Highcharts
- highcharts
- Highcharts
- Highcharts
- highcharts
- highcharts
- 此证书的签发者无效
- 感情整理
- 2015年总结和2016年的计划
- 学习中的感悟和总结
- android Button按钮实现点击效果代码附带demo下载
- Django Highcharts
- gradle版本下载
- 杂记
- 升级mongo3.2.1后遇到的数据重复的问题
- 设计模式之简单工厂模式
- __stdcall、__cdecl和__fastcall区别
- ElasticSearch——数据安全
- Multilayer Feedforward Networks are Universal Approximators
- windows php-redis 扩展安装