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

Unable to get only Bar Chart and Sum in RpivotTable #94

Open
SaadAmin5 opened this issue Nov 11, 2018 · 13 comments
Open

Unable to get only Bar Chart and Sum in RpivotTable #94

SaadAmin5 opened this issue Nov 11, 2018 · 13 comments

Comments

@SaadAmin5
Copy link

SaadAmin5 commented Nov 11, 2018

I only want to have Table, Bar chart as RendererName and Sum coming up in AggregatorName. It is currently not working.
I shall be extremely grateful for the help. Thanks

Codes:

library(rpivotTable)
rpivotTable(data =  mtcars, subtotal = FALSE,  rows = c( "cyl"),cols=c("carb"),
vals =  "mpg", 
aggregatorName = "Sum",
rendererName =  "Table",
renderers = list(Table=  htmlwidgets::JS('$.pivotUtilities.renderers["Table"]'),
                         Bar_Chart = htmlwidgets::JS('$.pivotUtilities.renderers["Bar Chart"]')),
aggregators = list(Sum = htmlwidgets::JS('$.pivotUtilities.aggregators["Sum"]')),
width="50%", height="550px")
@SaadAmin5
Copy link
Author

Any brilliant mind with an idea?

@avsdev-cw
Copy link

After looking at this, the only solution I can find involves a modification to the source code of rpivotTable. It is in fact a bug in the way the 2 parameters are handled and passed into the pivotUI() call.

I can provide a patch if needed.

@SaadAmin5
Copy link
Author

That would be great if you could provide the patch or update the codes. Bundle of thanks mate :)

@avsdev-cw
Copy link

avsdev-cw commented Nov 14, 2018

https://github.com/avsdev-cw/rpivotTable/tree/patch-002 - you can use devtools::install_github() to install

Usage would be something like:

library(rpivotTable)
rpivotTable(
    data = mtcars,
    rows = c("cyl"),
    cols = c("carb"),
    aggregatorName = "Sum",
    vals = "mpg", 
    rendererName = "Table",
    renderers = '{"Table": $.pivotUtilities.renderers["Table"], "Bar Chart": $.pivotUtilities.c3_renderers["Bar Chart"]}',
    aggregators = '{"Sum": $.pivotUtilities.aggregators["Sum"]}',
    width = "50%",
    height = "550px")

@SaadAmin5
Copy link
Author

SaadAmin5 commented Nov 14, 2018

Thanks a lot, but the output is showing '0' as rendererName and aggregatorName.
No options are displayed with empty table.
Can you please have a look?

@avsdev-cw
Copy link

avsdev-cw commented Nov 14, 2018

I've bumped the version number in that branch to 0.3.1002

Install the branch from within R/RStudio with: devtools::install_github("avsdev-cw/rpivotTable", "patch-002")

Restart R and then use library(rpivotTable) to load the new library. Use sessionInfo() to check that the version that is loaded is 0.3.1002

NOTE: this is a development build of the package and as such you should treat it with caution, especially when deploying your application. If one of the maintainers of rpivotTable would like to include the modification in the origin repository, I am happy to create a PR for them to do so.

@SaadAmin5
Copy link
Author

SaadAmin5 commented Nov 14, 2018

Many thanks mate :) its working perfectly now.
Just one last question, is it possible to remove 'Totals' coming up in column and rows?

@avsdev-cw
Copy link

You can add a stylesheet with a couple of rules in it:

.pvtTotal, .pvtGrandTotal, .pvtTotalLabel {
  display: none
}
.pvtGrandTotal {
  display: none;
}

You do lose the right hand table border though...

@smartinsightsfromdata
Copy link
Owner

@avsdev-cw Great stuff. Would you like to submit a PR for the patch?

@avsdev-cw avsdev-cw mentioned this issue Nov 15, 2018
@SaadAmin5
Copy link
Author

Thanks a lot mate, is it possible for you to update the codes with stylesheet having those rules. I tried but didn't work. Regards

@avsdev-cw
Copy link

The CSS change would need to be done on your app. This link should help you with how to do it: https://shiny.rstudio.com/articles/css.html

@AndreasPhilippi
Copy link

Somehow i did not get the Version 0.3.1002. When I install the package with devtools::install_github("avsdev-cw/rpivotTable", "patch-002") and check the version by sessionInfo() i still have 0.3.0. Is there any solution for that

@avsdev-cw
Copy link

@AndreasPhilippi did you restart your R session before loading the library?

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

4 participants