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

New treemap dialog #5540

Merged
merged 5 commits into from
Nov 29, 2019
Merged

Conversation

dannyparsons
Copy link
Contributor

@africanmathsinitiative/developers this is ready for review.
Implements the treemap graph from the treemapify package, see details here https://cran.r-project.org/web/packages/treemapify/vignettes/introduction-to-treemapify.html

An interesting test is to use the WorldBank97 data from the Procurement library and use country as the identifier. You could also weight by the contract value. This will test the "Primary data" option. Use the "country" sheet to test the "Summary data" option.

  • Install the treemapify package to test as it's not yet included in R-Instat
  • I have excluded the dialog from the project so that there are no vbproj changes. To test, include in the project and add the dialog somewhere in frmMain. Eventually this will be a graph under the describe menu, and on the procurement menu
  • The geom only works with summarised data so the dialog has "Primary data" and "Summary data" options at the top. If "Primary data" then the data is summarised in the code to use the geom. In this case, facets are disabled.
  • For now I haven't added a "Treemap Options" button to get to layer options, like on most dialog, as this could add bugs due to the summarising in the code. I think its not essential.
  • Layers tab is disabled on Plot Options dialog since the geom have not yet been added. This can be enabled once geoms are defined.

' You should have received a copy of the GNU General Public License
' along with this program. If not, see <http://www.gnu.org/licenses/>.

Imports instat
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not needed.

Comment on lines +437 to +438
sdgPlots.tbpFacet.Enabled = True
sdgPlots.tbpLayers.Enabled = True
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think these two can go into the else of the rdoPrimary.checked then the sdgplots.showdialog remains outside the if statement.

@maxwellfundi
Copy link
Contributor

@rdstern A quick one here- if you could install - treemapify package and have a look at this dialog. @dannyparsons where on the menu is this supposed to be in?

@rdstern
Copy link
Collaborator

rdstern commented Nov 29, 2019

@maxwell ok will do

@rdstern
Copy link
Collaborator

rdstern commented Nov 29, 2019

@maxwellfundi could you quickly add the dialogue to the project. If we remain cautious then let's start by calling it Treemap and putting it at the bottom of Procurement > Describe > Categorical.

I am happy to test then or for you to merge first - it can't do much harm sitting there!

@maxwellfundi
Copy link
Contributor

@rdstern Okay am adding it there. Thanks.

@maxwellfundi maxwellfundi merged commit dc50f84 into IDEMSInternational:master Nov 29, 2019
@maxwellfundi
Copy link
Contributor

@dannyparsons there seems not to have had vbproj file on this dialog?

@rdstern
Copy link
Collaborator

rdstern commented Dec 3, 2019

@dannyparsons I have followed your suggestions and - so far so good.
image

On the individual data it seems to work ok, with and without a filter. The example above is for just the smallest contracts - using the forcats::lump faility to set up the data for the filter!

Aha, my first problem:
image
Can the weights be done better than this. These are the summary data so I could round myself - but that isn't possible with the raw data.

Then I tried the different colours - seems ok

I wasn't sure what to expect from Fill, so I tried with a variable and got an error. (I was on summary)
image

I tried again with a numeric variable and the fill worked:
image

I wonder how to change the colour scales - do we have that yet in the Plot options? We do have it with the wind roses!

Two minor points are:
a) Change Options to Plot Options to be consistent with the other plotting dialogues
b) Shorten the Save label to Save Graph or Save Map so it does not overlap with the text field. Or move them to the right.
More serious is that the saving option doesn't work.

A more major point is that the treemaps are designed for hierarchical (factor) data. So, for example, having continent and country within continent. Or region and country. I tried to do this through the Plot sub-dialogue. I notice that facets and editing of layers is only possible from the summary data. Then I could add subgroups. Is that intentional, i.e. we can't edit the facets or layers with the primary data?

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

Successfully merging this pull request may close these issues.

3 participants