Django Highcharts
2016-02-16 17:25
453 查看
Docs »
Django Highcharts
Edit on GitHub
Django Highchart will make it easier for you to display highcharts graphs.
Install django-highcharts using pip (we do recommend to do it in a virtualenv).
To integrate it into a Django project, simply add it to your INSTALLED_APPS:
Don’t forget to set your STATIC_ROOT path and to run the following command to update the static files:
You’re now ready to use the available views.
Warning
Please note that the highcharts.js file should be called after the JQuery library.
Views
Common options
Basic usage
Available
views
Index
Module Index
Search Page
Next
Django Highcharts
Edit on GitHub
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.git cd django-highcharts pip 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 HighChartsBarView class 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
ViewsCommon options
Basic usage
Available
views
Indices and tables
IndexModule Index
Search Page
Next
相关文章推荐
- Django 如何使用Highcharts,其实我们可以摈弃Django-chartit
- golang 环境变量配置
- golang中runtime.Gosched()的理解
- 在Winfrom下实现类似百度、Google搜索自能提示功能
- nefuoj-831:统计good
- 强大的Go开发服务器简单例子
- ubuntu 上运行的django 出现No space left on device错误
- 自学习Django中遇到的一些问题
- 尽情享受美妙音乐----英国PURE公司Jongo S3无线音箱一周使用体验
- Good Blogs for Data Structure and Algorithm
- mongoose 文档(八) Connections
- Google的Bigtable学习笔记(不保证正确性)
- 蓝桥杯 算法训练 ALGO-6 安慰奶牛
- algorithm库介绍之---- stable_sort()方法 与 sort()方法
- sogou.com的问题
- HDU——1397Goldbach's Conjecture(二分查找+素数打表)
- POJ 2195 Going Home(二分图最优匹配)
- 【Django】Django命令(Manager.py)
- Google GFS文件系统深入分析
- golang协程——通道channel阻塞