2 years ago
#75297

HudsonBarroso
Not showing data from django to highcharts
I'm trying to retrieve a object from a queryset in django object and show it in my html graph by highcharts.
Models:
class PbaSetOperator(models.Model):
work_ymd = models.DateField(blank=True, null=True)
line_nm = models.CharField(max_length=20, blank=True, null=True)
prodc_qty = models.IntegerField(blank=True, null=True)
work_mh = models.FloatField(blank=True, null=True)
in_house = models.FloatField(blank=True, null=True)
reduction = models.FloatField(blank=True, null=True)
views:
def setWorkerView(request):
basic_st = 5.134
set_operator = PbaSetOperator.objects.all()
set_operator_today = set_operator.filter(work_ymd__range=(date,date1)).values('line_nm').order_by('line_nm').annotate(
set_operator_today_value=((480 * (Sum('in_house') / Sum('work_mh'))) / ((1 - (Sum('reduction') /
(Sum('reduction') +
Sum('in_house')))) * basic_st)))
context = {'set_operator_today':set_operator_today}
return render(request, 'monitoring/setOperator.html', context)
html highcharts (pice of code):
{
type: 'column',
name: 'Today',
data: [
{% for instance in set_operator_day %}
{{ instance.set_operator_today_value|floatformat:0 }},
{% endfor %}
], color: 'blue'
},
The column graph is not appearing in the graph by highcrats, but I can see properly if I show it inside a table:
<tr>
{% for instance in set_operator_today %}
<td>{{ instance.set_operator_today_value|floatformat:0 }}</td>
{% endfor %}
</tr>
What is wrong?
django
highcharts
django-views
0 Answers
Your Answer