Code Monkey home page Code Monkey logo

subtotal's Introduction

npm tests license

Subtotal.js

Subtotal.js is a JavaScript plugin for PivotTable.js. It renders rows and columns of a pivot table with subtotals and lets the user expand or collapse rows and columns.

Subtotal.js is available under an MIT license from NPM and Bower under the name subtotal. On packagist.org, it is nagarajanchinnasamy/subtotal.

image

Where can I see the demo?

You can see the live demo at examples page.

How can I get started?

To know how to load and use this library, please refer to Getting Started Wiki Page

API Documentation?

Please refer to Wiki Pages

How can I build the code and run the tests?

To install the development dependencies, just run npm install, which will create a node_modules directory with the files required to run the Gulp build system.

After modifying any of the .coffee files at the top of the repo, you can compile/minify the files into the dist directory by running npm run build

Once that's done, you can point your browser to tests/index.html to run the Jasmine test suite. You can view the current test results here.

The easiest way to modify the code and work with the examples is to leave a node_modules/gulp/bin/gulp.js watch serve command running, which will automatically compile the CoffeeScript files when they are modified and will also run a local web server you can connect to to run the tests and examples.

How can I contribute?

Pull requests are welcome! Here are some Contribution Guidelines.

I have a question, how can I get in touch?

Please first check the issues that are already raised and if you can't find what you're looking for there, then please create a GitHub Issue. When creating an issue, please try to provide a replicable test case so that others can more easily help you.

Copyright & Licence (MIT License)

Subtotal.js is © 2016 Nagarajan Chinnasamy, Mindtree, other contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

subtotal's People

Contributors

fabiomontefuscolo avatar kjeldahl avatar lramelot avatar nagarajanchinnasamy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

subtotal's Issues

Default collapse behaviour

At first, thank you for the plugin.

Then question: could you suggest how I can change default collapse behaviour?

I want to collapse all rows without describing attributes in rendererOptions { collapseRowsAt: [] }.

Aggregator on the subtotal only

I'm looking to see if it's possible to have a different aggregator on the subtotal (but only the subtotal).

You can do this in Excel by choosing "summarize values by".

An example might be "Average of Child Row" - where the subtotal would display an average of the aggregated child rows - so for example I'd use a sum aggreator (and when expanded you'd see the sum values), then an average aggreator for the subtotal which would show an average the child rows..

is this possible somehow?

Thanks,

Tom.

Can I save state on what item is expanded ?

Can I save state on which row is expanded ?
I am using this to save config

onRefresh: function (config) {
var config_copy = JSON.parse(JSON.stringify(config));
$("#output2").text(JSON.stringify(config_copy, undefined, 2)); }

it works to save other items but it does not output which row is expanded...
is there something similar on subtotal js/renderer ?

Thanks

RangeError: Maximum call stack size exceeded when using 'Table With Subtotal Heatmap' renderer

I have a data set with approx 14,000 rows (array of arrays), each row with 5 items.

the usage is straight forward, but if I use heatmap renderer it crashes:

$("#pivot1").pivot(data, {
    dataClass: $.pivotUtilities.SubtotalPivotData, 
    rows: ['Source', 'Order Type', 'Order Date', 'Customer & Order Description'],
    cols: ['Order Status'],
    aggregator: count()(['Order Date']),
    renderer: renderers['Table With Subtotal Heatmap'], // crashes
    //renderer: renderers['Table With Subtotal'],       // works
    rendererOptions: {
        collapseRowsAt: 'Order Date'
    }
});

Here is the error:

pivot.coffee:551 RangeError: Maximum call stack size exceeded
    at Function.ga [as find] (jquery.min.js:2)
    at r.fn.init.find (jquery.min.js:2)
    at forEachCell (pivot.coffee:898)
    at pivot.coffee:903
    at r.fn.init.$.fn.heatmap (pivot.coffee:908)
    at Object.Table With Subtotal Heatmap [as renderer] (subtotal.coffee:630)
    at r.fn.init.$.fn.pivot (pivot.coffee:549)
    at HTMLDocument.<anonymous> (report:176)
    at j (jquery.min.js:2)
    at k (jquery.min.js:2)
$.fn.pivot @ pivot.coffee:551
(anonymous) @ report:176
j @ jquery.min.js:2
k @ jquery.min.js:2

Can I expand one row to Level2 but not another

In my data source there are 2 columns. I drag them both to left panel as row fields. Say Level1 and Level2 are headers of these 2 columns.

In Level1...items are A, B, C. etc
Level 2 are details. Eg product details...

how to set the code so that for items A and D only, their Level2 product details are expanded ...
others (eg B, C) are collapsed ie Level2 is not expanded for B, C by default?

Thanks

Auto-derive: change rowAttrs duplicate first row.

Hi.

I'm working on auto deriving date attributes.

I've changed SubtotalPivotData.processKeys to replace attribute name to list, if derivedAttributes returns array instead of string.

But I have an issue there: first row of result set is duplicated.

Link to example: http://pivot.src.ilyaguy.me/examples/subtotal_pivotui_autodate.html
Link to source code: https://github.com/ilyaguy/pivottable-subtotal-renderer/blob/master/subtotal.coffee#L20

Could you take a look on this?

sorters option

When I enable subtotal.js, the sorters option in pivot doesn't work.

Do this option not exist when using subtotal.js? Or is there an equivalent?

Jasmine tests

Provide similar fix to subtotal.js tests as per the issue reported at: #597

Subtotal on Column

First of all thank you for "subtotal.js". I have a question about subtotal on column.
I want to display "Totals" under the "NAK_YEM_KILO". How can i do this?

2017-03-29_13h45_10

Empty filter lead to JS error.

If you clear any filter, renderer lead to JS error:

pivot.coffee:551 TypeError: Cannot read property 'length' of undefined
    at processKeys (subtotal.coffee:84)
    at main (subtotal.coffee:591)
    at SubtotalRenderer (subtotal.coffee:638)
    at Object.Table With Subtotal [as renderer] (subtotal.coffee:641)
    at m.t.fn.pivot (pivot.coffee:549)
    at pivot.coffee:838

Subtotal heatmap colors

Hi. I managed to provide my own color scale to PivotTable.js with the following code:

rendererOptions: {
heatmap: {
colorScaleGenerator: function(values) {
return d3.scale.linear()
.domain([0, 50, 100, 101])
.range(["#83d0c9", "#65c3ba", "#009688", "#d9534f"])
}
}
},

However, the values in my subtotal rows are not coloured. Is the any solution for this?

Row Sub-Total DIsplay On Top Problem.

Dear Sir
@nagarajanchinnasamy

I have tested your updated version of subtotal.js for displaying row subtotal in below portion of row.
Its working but now my subtotal for column is not working properly after this update.

Please check attached files as error in my case.
columnsubtotalerror
subtotalerror

Waiting for positive reply.

Subtotal Aggregators with pivot()

How can I use the Subtotal Aggregators with pivot instead of pivotUI()?

Your example only shows a pivotUI example, which has "vals" attribute which pivot() doesn't support..

Thanks,

Tom.

Disable subtotals on column

Hey,

I'm working on a small project where showing a total for columns doesn't really make sense.
Would it be possible to disable this feature on columns (only)

Thank u
Seb

Subtotal values filter

Let's say I have a table with some numeric values which are possible to filter out in the top panel of Pivot Table. I also have values in subtotal rows. Is it possible to do some filtering according to those subtotals?

Heatmap not using colorScaleGenerator

When I'm using the Standard Heatmap the colorScale I declared in the options for pivotUI is used. If I'm using your Heatmap it's the standard blue-to-white-to-red color scale.

Initial Expand/Collapse Behavior

Hi Nagarajan , first of all many thanks for your great work on pivot table. I found it very useful but there is something I wish to achieve which is not yet supported currently, correct me if I am wrong. I wonder if we can set the default expand/collapse behavior in the first place. Right now when I expand a parent element, all levels of child elements will be expanded by default, making the tree unnecessarily long when one does not need to see all child elements. I would like to have this manually expanded.

Thanks.
Pang

how to remove rows and columnTotals and freeze column

Hallo Mr Nagarajan
let me introduce myself, my name leo from indonesia, and may i take your code for my job, so great code and i'm learn pivottabel from you and nichloas kructen github, and i want to ask how about to remove rows, column totals and freeze so export excel? may you help me step by step, so below attach the screen shoot picture. Thanks Mr Nagarajan
remove total

subtotal prototype undefined

Gettig an error while using subtotal.js in pivot() function.
Can not read property 'prototype' as undefined.

Please provide support for this.

error

Multiple values/aggregator

Hi there,

Thanks for the amazing work you've added on top of pivottable.
I really like the ability to expand/collapse this awesome.

One of the thing I'm trying to add to your extension is the ability to have multiple values/aggregator.
I was using the method described there:
nicolaskruchten/pivottable#30

Full like to fork:
https://github.com/unk1911/pivottable-multi-field-aggregator/tree/master

Here's also a fiddle that show multiple values in action
https://jsfiddle.net/dL86h8xr/

They added their own renderer which I changed a little bit to fit my needs.
But now I'm having a tough time to implement this in your renderer.

Have you ever thought of adding this features ? Any idea how I can implement it quickly ?

Thanks,
Damien

styling collapsable labels

I would like to add cursor: pointer to row and column labels that are collapsible.
But classes alone do not differentiate between collapsible vs non-collapsible columns and rows.
At least not that I can see (e.g. classes pvtRowLabel and pvtAxisLabel)

Is there a way to accomplish this?

does't work build with webpack

Hi, @nagarajanchinnasamy , I had a problem when using it in webpack + vue + es6. This my code:

As a module:

function init ( selector ) {
	var dataClass = $.pivotUtilities.SubtotalPivotData;
        var renderers = $.pivotUtilities.subtotal_renderers;
	$.getJSON("../data/mps.json", function ( mps ){
		$( selector ).pivotUI( mps, {
			dataClass: dataClass,
            rows: ["Gender", "Province"],
            cols: ["Party", "Age"],
            renderer: renderers,
            rendererName: "Table With Subtotal"
		})
	})
}

module.exports = {
	init
}

Use in Vue components

<script>
	import { init } from "./utils/utils.js"

	export default {
		created () {
			// init pivottable data
			init(".render-pivottable")
		}
	}
</script>

When the page is rendered, there are no icons(▶) ,i don't know what's wrong. Help!

Way to have collapsed as the default?

*I closed this because i realized this was already asked

@nagarajanchinnasamy I would like to thank you for subotal.js. I do have a requirement where I need to either collapse multiple rows or just have them all collapsed by default. Currently, I am able to collapse one row, but when we expand that row, the rows inside are automatically expanded as well. I was hoping there was a way to have the user expand it manually instead of it defaulting to expanded.

Thank you,

Derrick

Sorting

The ability to sort in subtotal by clicking on headers would be very useful. Some of the headers would need to be able to expand and sort concurrently. I know this wouldn't be trivial, but it would be a great feature.

Tests don't test new functionality

First of all, very nice job on this packaging! I'm glad the framework from PivotTable.js was helpful :)

I notice that you've reused the test suite, which is great, but I would recommend upgrading the tests so that they actually run with your extended PivotData and Renderer, otherwise they are really just testing the core.

v1.6.0 Tests Broken

Due to change in the order of aggregators in $.pivotUtilities.subtotal_aggregators

Being able to hide subtotals columns when expanding.

Hey @nagarajanchinnasamy

This time I'm trying to find the way to display subtotals columns only when collapsed. Once we expand I want to hide the subtotals column in order to see only the children. In the next example, Australia is expanded I therefore need to hide the subtotals columns (and values) highlighted in yellow.

Thanks !

5060dec2-e19d-11e6-90d6-71d9e2c2aba5

Type Error: Cannot read property '' of undefined

When changing the renderer from one of the standard ones to 'Table with Subtotal' or any other of the subtotal renderers I get an exception.

TypeError: Cannot read property '' of undefined
    at buildValues (subtotal.coffee:262)
    at main (subtotal.coffee:600)
    at SubtotalRenderer (subtotal.coffee:622)
    at Object.Table With Subtotal [as renderer] (subtotal.coffee:625)
    at jQuery.$.fn.pivot (pivot.coffee:549)
    at pivot.coffee:852

at line 262 in subtotal.coffee:
aggregator = tree[flatRowKey][flatColKey] ? {value: (-> null), format: -> ""}
everything after the ? is getting marked red by Chrome DevTools

Not shure what went wrong there.

Drilldown callback

Great job! Nicolas just added drilldown support to his built-in table. Would you be willing to add this feature to subtotal as well? Thanks.

rotated text

Hi,

in case anyone is interested in 90 deg rotated column headers:

change createElement
from
if (textContent != null) { e.textContent = textContent; }

to
if (textContent != null) { if (elementType == 'th') { e.innerHTML = '<div>'+textContent+'</div>'; } else { e.textContent = textContent; } }

and add following styles
`
th.pvtColLabel {
text-align: center;
white-space: nowrap;
vertical-align: middle;
width: 1.5em;
}
th.pvtColLabel div {
-moz-transform: rotate(-90.0deg); /* FF3.5+ /
-o-transform: rotate(-90.0deg); /
Opera 10.5 /
-webkit-transform: rotate(-90.0deg); /
Saf3.1+, Chrome /
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=0.083); /
IE6,IE7 /
-ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=0.083)"; /
IE8 */
margin: 2em -6em 2em -6em;
}

`

sub-total display problem

Respected

I am looking for displaying subtotal of rows below the row.
Currently its showing above the rows but i need to show it below that particular row.

Please support.

Thanks
Kishan Kadam.
demo2

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.