Skip to content

Commit

Permalink
v1.51 fix #8
Browse files Browse the repository at this point in the history
  • Loading branch information
asjadnaqvi committed Oct 24, 2023
1 parent 21e64ee commit 388ef86
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 28 deletions.
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ authors:
- family-names: "Naqvi"
given-names: "Asjad"
title: "Stata package ``treemap''"
version: 1.5
date-released: 2023-07-22
version: 1.51
date-released: 2023-10-24
url: "https://github.com/asjadnaqvi/stata-treemap"
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

---

# treemap v1.5
# treemap v1.51

This package provides the ability to draw treemaps Stata.

Expand All @@ -28,7 +28,7 @@ The SSC version (**v1.41**):
ssc install treemap, replace
```

Or it can be installed from GitHub (**v1.5**):
Or it can be installed from GitHub (**v1.51**):

```stata
net install treemap, from("https://raw.githubusercontent.com/asjadnaqvi/stata-treemap/main/installation/") replace
Expand Down Expand Up @@ -61,7 +61,7 @@ graph set window fontface "Arial Narrow"

## Syntax

The syntax for **v1.5** is as follows:
The syntax for the latest version is as follows:

```stata
Expand Down Expand Up @@ -372,6 +372,10 @@ Please open an [issue](https://github.com/asjadnaqvi/stata-treemap/issues) to re

## Change log

**v1.51 (24 Oct 2023)**
- Further stabilized the sort. Categories with same totals were ending up in a random order (reported by Cesar Lopez). This has been fixed.
- Minor code cleanups.

**v1.5 (22 Jul 2023)**
- Added ability to plot both values and shares.
- `sformat()` option added to format shares.
Expand Down
8 changes: 3 additions & 5 deletions installation/stata.toc
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
v 1.5
v 1.51
d 'TREEMAP': A Stata package for tree maps.
d
d Distribution-Date: 20230722
d Distribution-Date: 20231024
d
d Asjad Naqvi
d asjadnaqvi@gmail.com
d
d https://medium.com/the-stata-guide
d https://github.com/asjadnaqvi/Stata-schemes


24 changes: 17 additions & 7 deletions installation/treemap.ado
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*! treemap v1.5 (22 Jul 2023)
*! treemap v1.51 (24 Oct 2023)
*! Asjad Naqvi (asjadnaqvi@gmail.com)

* v1.51 (24 Oct 2023): further stabilized the sort for categories with same totals that was causing a crash.
* v1.5 (22 Jul 2023): saving() added. Option to specify both values and shares. performat() added. noval + share defaults labcond to percent values only.
* v1.42 (15 May 2023): Help file fix. Minor corrections.
* v1.41 (15 Feb 2023): "Rest of ..." fix.
Expand Down Expand Up @@ -68,7 +69,6 @@ preserve
if `length' == 1 {
local var0 `by'

*collapse (sum) `varlist', by(`var0')

if "`threshold'"!="" {
replace `var0' = "Rest of `var0'" if `varlist' <= `threshold'
Expand Down Expand Up @@ -102,7 +102,7 @@ preserve
bysort `var0': egen var0_v = sum(`varlist')
gen double var1_v = `varlist'

gsort -var0_v -var1_v
gsort -var0_v `var0' -var1_v `var1'
}

if `length' == 3 {
Expand All @@ -125,10 +125,11 @@ preserve
bysort `var1': egen var1_v = sum(`varlist')
gen double var2_v = `varlist'

gsort -var0_v -var1_v -var2_v
gsort -var0_v `var0' -var1_v `var1' -var2_v `var2'
}




gen id = _n

egen var0_t = tag(`var0')
Expand All @@ -152,6 +153,9 @@ preserve
sort id
carryforward var1_o, replace
}




if `length' > 2 {
sort `var1' id
Expand All @@ -160,7 +164,8 @@ preserve
}

sort id




// set up the base values

Expand Down Expand Up @@ -294,6 +299,8 @@ preserve
}




local ratio = (1 + sqrt(5)) / 2


Expand Down Expand Up @@ -361,6 +368,8 @@ preserve
replace _l0_lab0 = "{it:" + _l0_lab1 + "}" if _l0_val >= `labcond'
}



**************
** layer1 **
**************
Expand Down Expand Up @@ -669,7 +678,8 @@ preserve
xlabel(, nogrid) ylabel(, nogrid) ///
xsize(`xsize') ysize(`ysize') ///
`title' `subtitle' `note' `scheme' `name' `saving'


*/
restore
}

Expand Down
6 changes: 3 additions & 3 deletions installation/treemap.pkg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
v 1.5
v 1.51
d {bf:TREEMAP}: A Stata package for treemaps
d
d Requires: Stata version 15 or higher.
Expand All @@ -8,9 +8,9 @@ d KW: graphs
d KW: treemap
d KW: squarify
d
d Distribution-Date: 20230722
d Distribution-Date: 20231024
d
d This version: 23 Jul 2023
d This version: 24 Oct 2023
d First version: 08 Sep 2022
d License: MIT
d
Expand Down
12 changes: 4 additions & 8 deletions installation/treemap.sthlp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{smcl}
{* 22Jul2023}{...}
{* 24Oct2023}{...}
{hi:help treemap}{...}
{right:{browse "https://github.com/asjadnaqvi/stata-treemap":treemap v1.5 (GitHub)}}
{right:{browse "https://github.com/asjadnaqvi/stata-treemap":treemap v1.51 (GitHub)}}

{hline}

Expand Down Expand Up @@ -137,18 +137,14 @@ See {browse "https://github.com/asjadnaqvi/treemap":GitHub} for a comprehensive

{hline}

{title:Acknowledgements}

Fayssal Ayad found errors with duplicate and zero values that was causing the layers to be drawn improperly (v1.21). Marc Kaulisch suggested adding the {opt colorby()} category.

{title:Feedback}

Please submit bugs, errors, feature requests on {browse "https://github.com/asjadnaqvi/stata-treemap/issues":GitHub} by opening a new issue.

{title:Package details}

Version : {bf:treemap} v1.5
This release : 22 Jul 2023
Version : {bf:treemap} v1.51
This release : 24 Oct 2023
First release: 08 Sep 2022
Repository : {browse "https://github.com/asjadnaqvi/treemap":GitHub}
Keywords : Stata, graph, treemap, squarify
Expand Down

0 comments on commit 388ef86

Please sign in to comment.