通过bin值创建jfreechart直方图?

时间:2018-10-14 16:52:45

标签: java statistics histogram jfreechart

from django.http import HttpResponse, Http404, JsonResponse from django.forms.models import model_to_dict import json from .models import Continent, Country def continent_json(request, continent_code): """ Write your answer in 7.2 here. """ try: print("CONTINENT QuerySet: ", Continent.objects.filter( code__exact=continent_code).values("countries")) continent_data = json.dumps( list(Continent.objects.filter( code__exact=continent_code).values("countries") ) ) print("CONTINENT JSON: ",continent_data) except Continent.DoesNotExist: raise Http404("Requested continent does not exist.") # If JSONP if "callback" in request.GET: continent_data = "{}({})".format( request.GET["callback"], continent_data ) return HttpResponse(continent_data) # Normal JSON return HttpResponse(continent_data, content_type="application/json") def country_json(request, continent_code, country_code): """ Write your answer in 7.2 here. """ try: #print("COUNTRY_OBJECT: "Country.objects.filter(code__exact=country_code).values()) print("MODEL_LIST: ",list(Country.objects.filter(code__exact=country_code).values("capital","population","area"))) country_data = json.dumps( list(Country.objects.filter( code__exact=country_code).values("code","name") ) ) print("COUNTRY DATA: ", country_data) except Country.DoesNotExist: raise Http404("Requested country does not exist.") # If JSONP if "callback" in request.GET: country_data = "{}({})".format( request.GET["callback"], country_data ) return HttpResponse(country_data) # Normal JSON return HttpResponse(country_data, content_type="application/json") 是否支持根据bin值数组创建直方图?我想绘制一个bin值数组,以在新样本到达时更新图表。我需要在此图表上支持多个系列,并在可能的情况下对其进行动态更新。可以使用jFreeChartSimpleHistogramDataset完成吗?

我知道我可以使用允许动态更新的SimpleHistogramBin,但是我没有一次尝试两个数据集。我也想知道普通的SimpleHistogramDataset是否允许动态更新,我有点不这样做,因为您必须预先指定values数组参数。

0 个答案:

没有答案