GithubHelp home page GithubHelp logo

Comments (1)

turnerniles avatar turnerniles commented on July 21, 2024

Data should be returned sorted alphabetically A-Z. Currently, up to two levels of pivoting maintain sort but a third causes the issue above. Instead can we sort all levels A-Z after pivoting?

const dataArray = [ ['name', 'gender', 'house', 'age'], ['Jon', 'm', 'Stark', 14], ['Arya', 'f', 'Stark', 10], ['Cersei', 'f', 'Baratheon', 38], ['Tywin', 'm', 'Lannister', 67], ['Tyrion', 'm', 'Lannister', 34], ['Joffrey', 'm', 'Baratheon', 18], ['Bran', 'm', 'Stark', 8], ['Jaime', 'm', 'Lannister', 32], ['Sansa', 'f', 'Stark', 12] ];

const testPivot = new pivot(dataArray, ['house', 'gender', 'name'], [], 'age', 'sum');

JSON.stringify(testPivot.data.table)

"[{"value":["sum age","sum age"],"depth":0,"type":"colHeader","row":0},{"value":["Stark",44],"depth":0,"type":"rowHeader","row":1},{"value":["f",22],"depth":1,"type":"rowHeader","row":2},{"value":["Arya",10],"type":"data","depth":2,"row":3},{"value":["Sansa",12],"type":"data","depth":2,"row":4},{"value":["m",22],"depth":1,"type":"rowHeader","row":5},{"value":["Bran",8],"type":"data","depth":2,"row":6},{"value":["Jon",14],"type":"data","depth":2,"row":7},{"value":["Baratheon",56],"depth":0,"type":"rowHeader","row":8},{"value":["f",38],"depth":1,"type":"rowHeader","row":9},{"value":["Cersei",38],"type":"data","depth":2,"row":10},{"value":["m",18],"depth":1,"type":"rowHeader","row":11},{"value":["Joffrey",18],"type":"data","depth":2,"row":12},{"value":["Lannister",133],"depth":0,"type":"rowHeader","row":13},{"value":["m",133],"depth":1,"type":"rowHeader","row":14},{"value":["Jaime",32],"type":"data","depth":2,"row":15},{"value":["Tyrion",34],"type":"data","depth":2,"row":16},{"value":["Tywin",67],"type":"data","depth":2,"row":17}]"

testPivot.filter("name", ["Arya"], 'exclude')
JSON.stringify(testPivot.data.table)
"[{"value":["sum age","sum age"],"depth":0,"type":"colHeader","row":0},{"value":["Stark",34],"depth":0,"type":"rowHeader","row":1},{"value":["m",22],"depth":1,"type":"rowHeader","row":2},{"value":["Bran",8],"type":"data","depth":2,"row":3},{"value":["Jon",14],"type":"data","depth":2,"row":4},{"value":["f",12],"depth":1,"type":"rowHeader","row":5},{"value":["Sansa",12],"type":"data","depth":2,"row":6},{"value":["Baratheon",56],"depth":0,"type":"rowHeader","row":7},{"value":["f",38],"depth":1,"type":"rowHeader","row":8},{"value":["Cersei",38],"type":"data","depth":2,"row":9},{"value":["m",18],"depth":1,"type":"rowHeader","row":10},{"value":["Joffrey",18],"type":"data","depth":2,"row":11},{"value":["Lannister",133],"depth":0,"type":"rowHeader","row":12},{"value":["m",133],"depth":1,"type":"rowHeader","row":13},{"value":["Jaime",32],"type":"data","depth":2,"row":14},{"value":["Tyrion",34],"type":"data","depth":2,"row":15},{"value":["Tywin",67],"type":"data","depth":2,"row":16}]"

See how the gender under Stark is reordered from 'f' to 'm' after Arya is removed?

from quick-pivot.

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.