areski / django-nvd3

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

Using 'chart_attr' with a dot adds extra ':' in javascript #69

Closed AlexejStukov closed 8 years ago

AlexejStukov commented 8 years ago

Using

extra = {
    'x_is_date': False,
    'x_axis_format': '',
    'jquery_on_ready': False,
    'chart_attr': {'xAxis': '.rotateLabels(45)'}
}
chart = load_chart("discreteBarChart", {"x": xdata, "y": ydata}, "chartcontainer", extra)

leads to an extra : in the Javascript output:

// ...
        var datum = data_chartcontainer;

        chart.color(d3.scale.category20().range());

                    chart.yAxis
                .tickFormat(d3.format(',.0f'));

    :    // <-- extra ":"
                chart.xAxis.rotateLabels(45);
// ...

If I use something without the dot, e.g. 'chart_attr':{"margin":"{top: 30, right: 100, bottom: 200, left: 60}"}' it works perfectly fine. Also if I replace that : the Javascript executes without an error.

AlexejStukov commented 8 years ago

Issue was resolved in upstream

nickongit commented 8 years ago

@AlexejStukov can you elaborate on what I need to fix this. I've updated django-nvd3 to django-nvd3==0.9.7 but I still get the same behaviour.

Thanks, and thank-you for writing this great app.

nickongit commented 8 years ago

It's OK, I think I have worked it out.

    'extra': {
                'chart_attr': {'xAxis.rotateLabels': '-25'},
             }
AlexejStukov commented 8 years ago

@nickongit: It was fixed in python-nvd3, but i think it's not released yet. Should be included in the next version.