Reputation: 13315
I am using Django-Chartit to create a chart.
Trying to follow this example.
my problem is that i want to use data not from a model
so i tried this code
data = \
DataPool(
series=
[{'options': {
'source': [1,2,3,4,5,6,7,8,9,10]},
'terms': [
'month',
'houston_temp',
'boston_temp']}
])
chart = Chart(
datasource = data,
series_options =
[{'options':{
'type': 'line',
'stacking': False},
'terms':{
'month': [
'boston_temp',
'houston_temp']
}}],
chart_options =
{'title': {'text': 'Weather Data of Boston and Houston'},
'xAxis': {'title': {'text': 'Month number'}
}})
and i got an error message
'source' must either be a QuerySet, Model or Manager. Got [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] of type instead.
I dont think i can create a QuerySet from a list. Any idea ?
Upvotes: 4
Views: 2139
Reputation: 7450
First of all from their docs terms
must be a list or dict of valid fields on the source
which must be a Model, queryset or a manager.
So what kind of data do you want to use?
UPDATE: What is this list data source exactly? If it is a list containing id's of a model you can do this to make it a queryset
MyModel.objects.filter(id__in=[3,1,2,5,77])
Upvotes: 1
Reputation: 2722
It looks like Django-Chartit is really meant for making charts out of models. Notice the tag line:
Create charts from your Django models effortlessly
If there is a specific reason you can't use a model, I would look into using a separate web charts tool such as Flot. It's pure JavaScript, so you would need to send your data to the client-side in order to make charts.
Upvotes: 4