Skip to content

Commit

Permalink
v1.71
Browse files Browse the repository at this point in the history
  • Loading branch information
asjadnaqvi committed Jan 15, 2024
1 parent c6a09ae commit 592f0ab
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 20 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 ``sankey''"
version: 1.7
date-released: 2023-11-06
version: 1.71
date-released: 2024-01-15
url: "https://github.com/asjadnaqvi/stata-sankey"
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Asjad Naqvi
Copyright (c) 2024 Asjad Naqvi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

---

# sankey v1.7
(06 Nov 2023)
# sankey v1.71
(15 Jan 2024)

This package allows users to draw Sankey plots in Stata. It is based on the [Sankey Guide](https://medium.com/the-stata-guide/stata-graphs-sankey-diagram-ecddd112aca1) published on [the Stata Guide](https://medium.com/the-stata-guide) on Medium on October 2021.

Expand All @@ -25,7 +25,7 @@ SSC (**v1.7**):
ssc install sankey, replace
```

GitHub (**v1.7**):
GitHub (**v1.71**):

```
net install sankey, from("https://raw.githubusercontent.com/asjadnaqvi/stata-sankey/main/installation/") replace
Expand Down Expand Up @@ -427,6 +427,9 @@ Please open an [issue](https://github.com/asjadnaqvi/stata-sankey/issues) to rep

## Change log

**v1.71 (15 Jan 2024)**
- Fixed a bug where numerical `from()` and `to()` variables with value labels were messing up the labels in the final figure (reported by Ian White).

**v1.7 (06 Nov 2023)**
- Fixed `valcond()` dropping bar values.
- Fixed `ctitles()` getting random colors. It now defaults to black.
Expand Down
38 changes: 33 additions & 5 deletions installation/sankey.ado
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
*! sankey v1.7 (06 Nov 2023)
*! sankey v1.71 (15 Jan 2024)
*! Asjad Naqvi ([email protected])

*v1.7 (06 Nov 2023): fix valcond() dropping labels in bars, added percent (still in beta), add ctitlepos() option. minor cleanups
*v1.71 (15 Jan 2024): fixed a bug where value labels of to() and from() were overwriting each other.
*v1.7 (06 Nov 2023): fix valcond() dropping labels in bars, added percent (still in beta), added ctpos() option. minor cleanups
*v1.61 (22 Jul 2023): Adding saving() option. minor fixes
*v1.6 (11 Jun 2023): Major rewrite of the core routines. Labels added. twp sorts added. Program is faster.
*v1.52 (29 May 2023): Add option where wwn flows are considered stock
Expand Down Expand Up @@ -43,7 +44,7 @@ version 15
// check dependencies
cap findfile colorpalette.ado
if _rc != 0 {
display as error "The palettes package is missing. Install the {stata ssc install palettes, replace:palettes} and {stata ssc install colrspace, replace:colrspace} packages."
display as error "The {bf:palettes} package is missing. Install the {stata ssc install palettes, replace:palettes} and {stata ssc install colrspace, replace:colrspace} packages."
exit
}

Expand Down Expand Up @@ -122,10 +123,31 @@ preserve

keep `varlist' `from' `to' `by' clrlvl

// convert value labels to strings
cap confirm numeric var `from'
if _rc==0 {
if "`: value label `from''" != "" {
decode `from', gen(temp1)
drop `from'
ren temp1 `from'
}
}

cap confirm numeric var `to'
if _rc==0 {
if "`: value label `to''" != "" {
decode `to', gen(temp2)
drop `to'
ren temp2 `to'
}
}


collapse (sum) `varlist' (mean) clrlvl , by(`from' `to' `by')

gen markme = .


if "`stock'" != "" {
replace markme = `from'== `to'
}
Expand Down Expand Up @@ -165,6 +187,8 @@ preserve

reshape long var val, i(id layer xcut) j(marker)



// variable type check

if substr("`: type var'",1,3) != "str" {
Expand All @@ -181,6 +205,7 @@ preserve
}



gen layer2 = layer
replace layer2 = layer2 + 1 if marker==2

Expand Down Expand Up @@ -258,7 +283,8 @@ preserve
gen double y2 = heightsum





*** add gap

tempvar mygap
Expand Down Expand Up @@ -306,6 +332,8 @@ preserve

}



gsort layer2 marker var markme `ssort2' // this determines the second sort

by layer2 marker var: gen double stack_end = sum(val) if markme!=1
Expand Down Expand Up @@ -359,7 +387,7 @@ preserve
}

}


gen stack_x = layer2

Expand Down
6 changes: 3 additions & 3 deletions installation/sankey.pkg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
v 1.7
v 1.71
d {bf:SANKEY}: A Stata package for sankey plots.
d See {bf:help sankey} after installation.
d
Expand All @@ -8,9 +8,9 @@ d KW: Stata
d KW: graphs
d KW: sankey
d
d Distribution-Date: 20231106
d Distribution-Date: 20240115
d
d This version: 06 Nov 2023
d This version: 15 Jan 2024
d First version: 08 Dec 2022
d License: MIT
d
Expand Down
9 changes: 5 additions & 4 deletions installation/sankey.sthlp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{smcl}
{* 06Nov2023}{...}
{* 15Jan2024}{...}
{hi:help sankey}{...}
{right:{browse "https://github.com/asjadnaqvi/stata-sankey":sankey v1.7 (GitHub)}}
{right:{browse "https://github.com/asjadnaqvi/stata-sankey":sankey v1.71 (GitHub)}}

{hline}

Expand Down Expand Up @@ -168,6 +168,7 @@ See {browse "https://github.com/asjadnaqvi/stata-sankey":GitHub} for examples.

{title:Version history}

- {bf:1.71} : Fixed a bug where from() and to() value labels were overwriting each other.
- {bf:1.7} : Fixed {opt valcond()} dropping bar values, and fixed ctitles color to black. Added {opt percent} (beta), {opt ctpos()}.
- {bf:1.61} : Adding saving() option.
- {bf:1.6} : Rewrite of core routines. {opt sortby()} split into {opt sort1()} and {opt sort2()}. New option {opt stock} added.
Expand All @@ -183,8 +184,8 @@ See {browse "https://github.com/asjadnaqvi/stata-sankey":GitHub} for examples.

{title:Package details}

Version : {bf:sankey} v1.7
This release : 06 Nov 2023
Version : {bf:sankey} v1.71
This release : 15 Jan 2024
First release: 08 Dec 2022
Repository : {browse "https://github.com/asjadnaqvi/stata-sankey":GitHub}
Keywords : Stata, graph, sankey
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.7
v 1.71
d 'SANKEY': A Stata package for Sankey plots
d
d Distribution-Date: 20231106
d Distribution-Date: 20240115
d
d Asjad Naqvi
d [email protected]
Expand Down

0 comments on commit 592f0ab

Please sign in to comment.