# DjangoCMS_Charts
[![PyPI version](https://badge.fury.io/py/djangocms-charts.svg)](https://badge.fury.io/py/djangocms-charts)
[![PyPi downloads](https://pypip.in/d/djangocms-charts/badge.png)](https://crate.io/packages/djangocms-charts/)
A plugin for DjangoCMS that creates easy to use and fully customisable ChartJs (ver 2.x) charts - with a table and csv upload interface.
## Updates
- 3.0.0
- **CAUTION** - This is a complete refactoring of DjangoCMS Charts to ChartJS version 2.x
- ***All Models, Fields, and Options have changed***
- ***Due to changes in ChartJS 1.x > 2.x - Not all Custom settings will be migrated***
- The migrations attempt to bring over any settings changed from the default values from each previous chart.
- ChartJS is enabled by default - update settings to disable as below
- All chart types are now available in the ChartsJS Plugin
- Multiple Datasets can be added as Child Plugins of the parent ChartJS Plugin
- Global Options are added in the Admin, as required.
- All Options come from the ChartJS object/dictionary and are using a Select2 list
## Quick start
1. Add 'djangocms_charts' to your INSTALLED_APPS setting like this::
INSTALLED_APPS = [
...
'djangocms_charts',
]
2. Run `python manage.py migrate` to create the djangocms_charts models.
3. Ensure you have your own version of jQuery added to block 'js'. See here: https://django-sekizai.readthedocs.io/en/latest/#example
4. Add a DjangoCMS ChartJS Plugin to your web page!
## Caching [Optional]
The queries and building up of each chart can be expensive for many options/data rows/charts etc.
To speed this up set up a dedicated DjangoCMS Charts cache.
This **should be a unique cache** as it will require to be cleared after saving any charts object due to the complex relationship between all objects.
1. In `settings.py` add `DJANGOCMS_CHARTS_CACHE = 'djangocms_charts'` which should map to a unique cache.
2. In your `CACHES` add the charts cache - sample backend below - use your own cache system:
```
CACHES = {
'default': {
...
},
'djangocms_charts':{
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
'LOCATION': 'djangocms_charts',
'TIMEOUT': CACHE_MIDDLEWARE_SECONDS,
'OPTIONS': {
'MAX_ENTRIES': 5000
}
},
}
```
## URLS [Optional]
If access to the JSON Vesion of the chart is required add the following to your `urls.py` :
```
urlpatterns = [
...
url(r'^chartjs/', include('djangocms_charts.urls')),
...
]
```
The JSON view can then be accessed via:
- Chart View: `[url]/chartjs/get_chart_as_json/[chart_id]/`
- Global Options View: `[url]/get_global_options_as_json/[options_id]/`
## ChartJs-Sass [Optional]
All chart dataset colours (backgroundColor, borderColor, etc) can be set using CSS via ChartJS-Sass. This JS library will update any unspecified colors with those specified in the CSS and built using SASS.
For more details see: https://github.com/mcldev/ChartJS-Sass
1. To disable/enable, in `settings.py` add `DJANGOCMS_CHARTS_ENABLE_CHARTJS_SASS = True or False (default=True)`
## Usage
### Chart Types
The following chart types can be selected with options (see below)
- Line
- Line XY (Scatter with line)
- Bar
- Horizontal Bar
- Radar
- Polar
- Pie
- Doughnut
- Bubble
- Scatter
- Mixed (see Multiple Datasets)
### Input Data
All input data will be used as below.
NB: Multiple datasets can be added as either:
- Dataset Plugins as child to each Chart Plugin (customisable colours/formats etc)
- Multiple rows or columns within a Chart input table (scriptable colours/formats)
```
# Line, Bar, Radar, Doughnut, Pie, PolarArea
# ------------------------------------------
# Datasets in 'cols' > TRANSPOSED
# Label_1, Label_2, ...
# Jan-20 10 30
# Feb-20 20 40
# ...
#
# OR
#
# Datasets in 'rows' > USES THIS FORMAT INTERNALLY
# Jan-20 Feb-20, ...
# Label_1 10 20
# Label_2 30 40
# ...
#
# Bubble [r], Scatter, Line_XY
# ----------------------------
# [r - radius - is ignored for line and scatter]
#
# Datasets in 'cols' > TRANSPOSED
# x 10 20 ...
# y 30 40 ...
# [r] 5 10 ...
#
# OR
#
# Datasets in 'rows' > USES THIS FORMAT INTERNALLY
# x, y, [r]
# 10 30 5
# 20 40 10
# ...
```
### Axes
https://www.chartjs.org/docs/latest/axes/
Multiple Axes can be added using X Axis or Y Axis. Each Axis can be used multiple times (e.g. Linear axis).
Options for Axes are set below.
### Multiple Datasets
https://www.chartjs.org/docs/latest/charts/mixed.html#drawing-order
Multiple datasets can be added as rows/columns of the main chart, or added as Dataset child plugins.
The rendering order for ChartJS is that the first dataset is top-most - this plugin prepends the subsequent child datasets so the last dataset is top-most.
### Mixed Types
https://www.chartjs.org/docs/latest/charts/mixed.html
Each child Dataset can have a different type, thus creating a Mixed Chart.
**NB:** Some types do not mix well (Radar/Bar etc) - we make no validation on each possible combination.
## Dataset Colors
Dataset Color Groups can be specified as a user-friendly list of colors, with a click-and-drag sortable feature.
### Specifying the color group
Specifications for each group require the following:
- Type (select multiple types with Ctrl)
- the Chart/Dataset type that these colors will be applied to
- Namespace Labels (select multiple types with Ctrl)
- the dataset namespace labels that will use these colors
- e.g. `backgroundColor, borderColor, pointBackgroundColor, ...`
- Colors
- a text list of **hex only** colors
- these can be selected/edited/rearranged through the interface
### Application of Color Groups
These color groups can then be applied as follows:
- Globally
- by assigning the color group to the Global Settings
- any Chart/Dataset (without colors specified) will use these colors
- By Chart
- all of the Chart datasets and any sub-datasets (without colors specified) will have these colors applied
- By Dataset
- any Dataset can specifically use this Color Group
### Color By Dataset or Series
The flag to set 'Color by Dataset' will do the following:
- Color by Dataset: `True`
- Each individual Dataset will use one color from the color array based on its index
- e.g. with a color array of `[red, green, blue]`
```
# Jan-20 Feb-20, ...
# Label_1 10 20 <- red
# Label_2 30 40 <- green
# Label_3 50 60 <- blue
```
- Color by Series: `False`
- Each individual Dataset will get the full color array to use for each element in Series
- e.g. with a color array of `[red, green, blue]`
```
# Jan-20 Feb-20, ...
# Label_1 10 <- red 20 <- green
# Label_2 30 <- red 40 <- green
# Label_3 50 <- red 60 <- green
```
## Options
https://www.chartjs.org/docs/latest/configuration/
Options are set in JavaScript using the settings provided by ChartJS - Use this documentation: https://www.chartjs.org/docs/latest/
The Options are assigned in ascending order of priority as:
- `Chart.defaults.global.<option>` - see GlobalOptionsGroup in Admin
- `chart.options.<option>` - see ChartOptions Group selectable for each chart
- `chart.options.<option>` - see ChartSpecificOptions assigned to each chart individually
- `dataset.<option>` - see DatasetOptionsGroup selectable for each dataset
- `dataset.<option>` - see DatasetSpecificOptions assigned to each dataset individually
- `chart.options.scales.<axes>.<option>` - see AxisOptionsGroup selectable for each axis
### Option Input Types
https://www.chartjs.org/docs/latest/general/opt
没有合适的资源?快使用搜索试试~ 我知道了~
PyPI 官网下载 | djangocms_charts-3.0.1.tar.gz
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 69 浏览量
2022-01-31
18:43:47
上传
评论
收藏 821KB GZ 举报
温馨提示
共76个文件
py:31个
js:18个
css:9个
资源来自pypi官网。 资源全名:djangocms_charts-3.0.1.tar.gz
资源详情
资源评论
资源推荐
收起资源包目录
djangocms_charts-3.0.1.tar.gz (76个子文件)
djangocms_charts-3.0.1
MANIFEST.in 179B
PKG-INFO 13KB
djangocms_charts
models.py 7KB
models_colors.py 2KB
cms_plugins.py 3KB
models_datasets.py 12KB
apps.py 135B
utils.py 1KB
templates
djangocms_charts
chartjs.html 3KB
widgets
multi-color-select.html 1022B
input-table.html 9KB
temp_js_code.txt 1KB
migration_utils.py 6KB
static
djangocms_charts
input
css
jquery.contextMenu.min.css 4KB
handsontable.full.modified.min.css 21KB
handsontable.full.modified.css 28KB
jquery.contextMenu.css 4KB
custom
multi-color-select.js 4KB
multi-color-select.min.js 0B
admin_fixes.js 496B
admin_fixes.min.js 132B
admin_styles.css 168B
js
handsontable.js 834KB
bootstrap3-typeahead.js 13KB
html5sortable.min.js 16KB
handsontable.full.js 1.04MB
jquery-ui.position.js 23KB
jquery-3.5.1.min.js 87KB
jquery.contextMenu.js 77KB
json2.js 18KB
img
chart-icon.png 6KB
output
Chart.js
2.9.4
Chart.bundle.min.js 221KB
Chart.min.js 169KB
Chart.bundle.js 566KB
Chart.js 419KB
Chart.min.css 523B
Chart.css 811B
ChartJs-Sass
2.0.0
css
chartjs-sass-default.min.css 32KB
chartjs-sass-default.css.map 12KB
chartjs-sass-default.css 35KB
js
chartjs-sass.min.js 3KB
chartjs-sass.js 5KB
sass
chartjs-sass-default.scss 221B
_chartjs-sass.scss 3KB
__init__.py 59B
migrations
0007_migrate_old_chart_options.py 4KB
0009_remove_old_charts.py 2KB
0005_complete_refactor.py 17KB
0002_add_chart_position.py 3KB
0004_auto_20200521_2007.py 10KB
0003_auto_20190201_1645.py 11KB
0008_set_new_chart_options.py 1KB
__init__.py 0B
0006_migrate_old_chart_data.py 3KB
0001_initial.py 29KB
models_options.py 7KB
models_axes.py 4KB
views.py 1KB
admin.py 3KB
templatetags
__init__.py 0B
chart_tags.py 185B
consts.py 22KB
widgets.py 2KB
tests.py 289B
urls.py 377B
cache.py 1KB
forms.py 6KB
djangocms_charts.egg-info
PKG-INFO 13KB
requires.txt 43B
SOURCES.txt 4KB
top_level.txt 17B
dependency_links.txt 1B
LICENSE 1KB
setup.cfg 42B
setup.py 1KB
README.md 10KB
共 76 条
- 1
挣扎的蓝藻
- 粉丝: 13w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0