Skip to content

Commit

Permalink
v1.21 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
asjadnaqvi committed Nov 22, 2022
1 parent 853a219 commit 747595e
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 21 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
![StataMin](https://img.shields.io/badge/stata-2015-blue) ![issues](https://img.shields.io/github/issues/asjadnaqvi/stata-treemap) ![license](https://img.shields.io/github/license/asjadnaqvi/stata-treemap) ![Stars](https://img.shields.io/github/stars/asjadnaqvi/stata-treemap) ![version](https://img.shields.io/github/v/release/asjadnaqvi/stata-treemap) ![release](https://img.shields.io/github/release-date/asjadnaqvi/stata-treemap)


# treemap v1.2
# treemap v1.21


This package provides the ability to draw treemaps Stata.
Expand Down Expand Up @@ -271,6 +271,10 @@ Please open an [issue](https://github.com/asjadnaqvi/stata-treemap/issues) to re

## Versions

**v1.21 (22 Nov 2022)**
- Removed error where duplicate values were causing categories to be dropped.
- Stablized the sort order to prevent random trees across different runs.

**v1.2 (25 Sep 2022)**
- Fill intensity control added.
- Error checks for negative values.
Expand Down
4 changes: 2 additions & 2 deletions installation/stata.toc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
v 1.2
v 1.21
d 'TREEMAP': A Stata package for treemaps
d
d Distribution-Date: 20220925
d Distribution-Date: 20221122
d
d Asjad Naqvi,
d [email protected]
Expand Down
29 changes: 16 additions & 13 deletions installation/treemap.ado
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
*! Treemap v1.2 (22 Sep 2022)
*! Treemap v1.21 (22 Nov 2022)
*! Asjad Naqvi ([email protected])

* v1.2 (22 Sep 2022): Negative values check. Control over fill intensity.
* v1.1 (13 Sep 2022): Label, color, title scaling. More options for controls. More checks. Better defaults.
* v1.0 (08 Sep 2022): First release
* v1.21 (22 Nov 2022): fixed a bug where duplicate values were causing categories to be dropped.
* v1.2 (22 Sep 2022): Negative values check. Control over fill intensity.
* v1.1 (13 Sep 2022): Label, color, title scaling. More options for controls. More checks. Better defaults.
* v1.0 (08 Sep 2022): First release

cap prog drop treemap

Expand Down Expand Up @@ -34,9 +35,11 @@ prog def treemap, sortpreserve


qui {
preserve
preserve
keep if `touse'



local length : word count `by'

if `length' == 1 {
Expand All @@ -50,8 +53,8 @@ qui {

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

gen var0_v = `varlist'
gsort -var0_v
gen double var0_v = `varlist'
gsort -var0_v `var0' // stabilize the sort
}

if `length' == 2 {
Expand All @@ -75,7 +78,7 @@ qui {
collapse (sum) `varlist', by(`var0' `var1')

bysort `var0': egen var0_v = sum(`varlist')
gen var1_v = `varlist'
gen double var1_v = `varlist'

gsort -var0_v -var1_v
}
Expand Down Expand Up @@ -109,7 +112,7 @@ qui {

bysort `var0': egen var0_v = sum(`varlist')
bysort `var1': egen var1_v = sum(`varlist')
gen var2_v = `varlist'
gen double var2_v = `varlist'

gsort -var0_v -var1_v -var2_v
}
Expand All @@ -118,10 +121,9 @@ qui {
gen id = _n

egen var0_t = tag(`var0')
egen var0_o = group(var0_v)
levelsof var0_o
replace var0_o = r(r) - var0_o + 1

gen double var0_o = sum(`var0' != `var0'[_n-1])


if `length' > 1 {
cap drop var1_t
egen var1_t = tag(`var0' `var1')
Expand Down Expand Up @@ -565,6 +567,7 @@ qui {
xsize(`xsize') ysize(`ysize') ///
`title' `subtitle' `note' `scheme' `name'


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.2
v 1.21
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: 20220922
d Distribution-Date: 20221122
d
d This version: 25 Sep 2022
d This version: 22 Nov 2022
d First version: 08 Sep 2022
d License: MIT
d
Expand Down
4 changes: 2 additions & 2 deletions installation/treemap.sthlp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{smcl}
{* 22Sep2022}{...}
{* 22Nov2022}{...}
{hi:help treemap}{...}
{right:{browse "https://github.com/asjadnaqvi/stata-treemap":treemap v1.2 (GitHub)}}
{right:{browse "https://github.com/asjadnaqvi/stata-treemap":treemap v1.21 (GitHub)}}

{hline}

Expand Down

0 comments on commit 747595e

Please sign in to comment.