areski / django-nvd3

Django wrapper for nvd3 - It's time for beautiful charts
Other
416 stars 124 forks source link

Multibarchart x axis with text labels does shows NaN% in chart , but gets label correct in tooltip #80

Closed pratgohi closed 8 years ago

pratgohi commented 8 years ago

Hi First of all , Great Work by writing this wrapper it is excellent piece of work.

i have following views.py function.

def Results_View(request): charttype = "multiBarChart" buildmodel_objects=Jenkins_Build.objects.all()

xdata = [obj.build for obj in buildmodel_objects]

ydata = [obj.tests_passed for obj in buildmodel_objects]
y1data = [obj.tests_failed for obj in buildmodel_objects]
xdata=['A','B','C','D']
extra_serie = {"tooltip": {"y_start": " in ", "y_end": " "}}
chartdata = { 'x': xdata,
              'name1': 'PASSED',
              'y1':ydata,
              'extra1': extra_serie,
              'extra2': extra_serie,
              'kwargs1': {'color': '#009900'},
              'name2': 'FAILED',
              'y2':y1data,
              'kwargs2': {'color': '#ff0000'}}

chartcontainer="TEST RESULTS"
data = {
    'charttype': charttype,
    'chartdata': chartdata,
    'chartcontainer': chartcontainer,
}
return render_to_response('test_results/multibarchart.html', data)
screen shot 2016-06-10 at 7 15 40 pm

How to solve this NaN% problem.

Also why it takes decimal digit's for Y axis even if the number specified is in Integer? any ways to correct the same?

pratgohi commented 8 years ago

I have got it corrected with following solutions, I was missing the extra in template tag.

   'extra': {
        'x_is_date': False,
        'x_axis_format': '',
        'y_is_date': False,
        'y_axis_format': 'd',
        'chart_attr': {'xAxis.rotateLabels': '-90'},
        'margin_bottom' : 300,
        'reduceXTicks': False,
    }

If you think it will be helpful, i can help you add this customization examples in the demo project that will help others.

coolankit commented 6 years ago

Hi @pratgohi , I'm facing same problem but your solution not working for me. please help.