Code Monkey home page Code Monkey logo

Comments (4)

areski avatar areski commented on August 16, 2024

Thanks!

Won't it be better to sort your data before calling django-nvd3 ?
I would imagine some peoples could be against a forced sort.

On Mon, Dec 2, 2013 at 11:34 PM, miquelcamprodon
[email protected]:

Hi areski. Great work!
There is an small issue that can be solved with a line of code: The y
series, named y1, y2, y3, ... are located in a dictionary and when data is
read sometimes it is not sorted alphabetically.

I suggest to add a sorting after the reading of the y series:

After line 36
y_axis_list = [d for d in series.keys() if 'y' in d]

Add
y_axis_list.sort()


Reply to this email directly or view it on GitHubhttps://github.com//issues/18
.

Kind regards,
/Areski


Arezqui Belaid, [email protected]
Founder at Star2Billing (www.star2billing.com)

Tel: +34650784355
Twitter: http://twitter.com/areskib
LinkedIn: http://www.linkedin.com/in/areski

from django-nvd3.

miquelcamprodon avatar miquelcamprodon commented on August 16, 2024

Hi areski,
Maybe I am not explaining the issue well (or maybe I am missing something), but my problem is that the set of series

y1: the first serie of y points
y2: the second serie of y points
y3: the third serie of y points

is a dictionary and I don't know the way to specify the order of series, as when the keys y1, y2, y3 are readen from the dict not necessarily y1 will appear before y2 and y2 before y3. For that reason I suggest to sort the keys of the dictionary before using them.

For example:

chartdata = {
    'x': xdata,
    'name1': 'Acepted', 'y1': ydata1, 'kwargs1': kwargs1, 'extra1': extra_serie1,                
    'name2': 'Not accepted', 'y2': ydata2, 'kwargs2': kwargs2, 'extra2': extra_serie2,
    'name3': 'Unknown', 'y3': ydata3, 'kwargs3': kwargs3, 'extra3': extra_serie3,        
}

I want to show the series in the specified order, and to ensure this I performed this small change.

from django-nvd3.

areski avatar areski commented on August 16, 2024

Thanks for making this clear, I just pushed your fix 44297a1

from django-nvd3.

zebulon2 avatar zebulon2 commented on August 16, 2024

To order the keys, use for chartdata a SortedDict() that Django provides. Then create it as explained here: https://code.djangoproject.com/wiki/SortedDict. Note the syntax you need to use to order the keys, it is different from a traditional Python dictionary.

from django-nvd3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.