Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
A plugin for DjangoCMS that creates easy to use and fully customisable ChartJs (ver 2.x) charts - with a table and csv upload interface.
Add 'djangocms_charts' to your INSTALLED_APPS setting like this::
INSTALLED_APPS = [ ... 'djangocms_charts', ]
Run python manage.py migrate
to create the djangocms_charts models.
Ensure you have your own version of jQuery added to block 'js'. See here: https://django-sekizai.readthedocs.io/en/latest/#example
Add a DjangoCMS ChartJS Plugin to your web page!
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.
In settings.py
add DJANGOCMS_CHARTS_CACHE = 'djangocms_charts'
which should map to a unique cache.
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
}
},
}
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:
[url]/chartjs/get_chart_as_json/[chart_id]/
[url]/get_global_options_as_json/[options_id]/
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
settings.py
add DJANGOCMS_CHARTS_ENABLE_CHARTJS_SASS = True or False (default=True)
The following chart types can be selected with options (see below)
All input data will be used as below.
NB: Multiple datasets can be added as either:
# 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
# ...
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.
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.
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 Color Groups can be specified as a user-friendly list of colors, with a click-and-drag sortable feature.
Specifications for each group require the following:
backgroundColor, borderColor, pointBackgroundColor, ...
These color groups can then be applied as follows:
The flag to set 'Color by Dataset' will do the following:
True
[red, green, blue]
# Jan-20 Feb-20, ...
# Label_1 10 20 <- red
# Label_2 30 40 <- green
# Label_3 50 60 <- blue
False
[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
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 Adminchart.options.<option>
- see ChartOptions Group selectable for each chartchart.options.<option>
- see ChartSpecificOptions assigned to each chart individuallydataset.<option>
- see DatasetOptionsGroup selectable for each datasetdataset.<option>
- see DatasetSpecificOptions assigned to each dataset individuallychart.options.scales.<axes>.<option>
- see AxisOptionsGroup selectable for each axishttps://www.chartjs.org/docs/latest/general/options.html
ChartJS accepts various input option formats, some can be scripted, functions, numbers, or text. DjangoCMS Charts options can be input as any one of the following types:
NB. there is no validation of input types - Errors will appear in the console
#28aece
{"option_name": "#28aece"}
2 or 3.5
{"option_name": 2}
'true', 'false', 1, 0
{"option_name": true}
['red', 'blue', 'green']
{"option_name": ["red", "blue", "green"]}
"\n"
(new line)","
(comma)"\t"
(tab)" "
(space)red blue green
{"option_name": ["red", "green", "blue"}]
function(context) {
var index = context.dataIndex;
var value = context.dataset.data[index];
return value < 0 ? 'red' :
index % 2 ? 'blue' :
'green';
}
ChartJs is a dynamic JS charting application giving users an interactive and visually appealing chart in an html 5 canvas. Each type of chart is available:
FAQs
DjangoCMS Plugin to add and edit ChartJs charts
We found that djangocms-charts demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.