Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log scale and adding extra settings #19

Closed
zebulon2 opened this issue Dec 11, 2013 · 5 comments
Closed

Log scale and adding extra settings #19

zebulon2 opened this issue Dec 11, 2013 · 5 comments

Comments

@zebulon2
Copy link
Contributor

Hi, I would like to be able to graph my X axis with a log scale on a lineChart. nvd3 offers this feature, using: chart.xScale(d3.scale.log());
Is it possble to add this to django-nvd3?

In a more general way, is there a way to pass supplementary settings so that they blend with the automatic building of the <script> in the HTML page? For instance, having in the extra dictionary something of the form:

'supplementary':'chart.forceY([1,1000000]);'

which would add "chart.forceY([1,1000000]);" inside the <script> section?

Thanks.

@zebulon2
Copy link
Contributor Author

I answer to myself: I added:
self.jschart += "chart.xScale(d3.scale.log());"
to NVD3Chart.py in python-nvd3 code, and this works quite well! I just need to change the axis ticks formatting to prevent the X axis to be overwhelmed with labels.
I may be able to submit a patch later, but my programming may be a bit rusty and not very high standard.

@areski
Copy link
Owner

areski commented Dec 11, 2013

Can you show us an example with nvd3 ?

@zebulon2
Copy link
Contributor Author

Do you mean a screenshot? See below:

nvd3_log

This was obtained adding in NVD3Chart.py :
self.jschart += stab(2)+"chart.xScale(d3.scale.log());\n"####
self.jschart += stab(2)+"chart.xAxis.tickValues([0.001, 0.003, 0.01, 0.03, 0.1, 0.3, 1, 3, 10, 30]);\n"####

Now of course this is only a proof-of-concept. I need to add the code correctly and edit both python-nvd3 and django-nvd3.

I also realised this is similar to qdoolaeg request here: areski/python-nvd3#13
He proposes the more generic solution where any attribute/value could be passed to chart. It is nice, because it would allow users to add non yet supported attributes for django-nvd3.

I can fork your repository and provide a pull request then.

@zebulon2
Copy link
Contributor Author

I have sent pull requests for python-nvd3 and django-nvd3. Please let me know what you think.

@areski
Copy link
Owner

areski commented Dec 17, 2013

I suppose we can close this one now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants