Stack Overflowing

Pyth, 4341 40 bytes

<" \|/"g#0hK-QJEVJs[$$?<N_Kd\-$$*<N-K3\-


Try it online. Test suite.

First pass, quick and dirty. Input to STDIN as N\nH.

Explanation

1. Save the second input (height) to J (JE), and subtract it from the first input (the number of items). (-QJE)
2. Save the difference (number of overflowing items) to K. (K-QJE)
3. Add 1 to the number. (hK-QJE)
4. Take max(0, previous). This is required as negative numbers would break the next step. (g#0hK-QJE)
5. Take at most that many letters from the string " \|/" to get the first line and print. (<" \|/"g#0hK-QJE)
6. Loop N over range(0, J). (VJ) For each N print the concatenation of the following: (s[)
• "(" ($$) • " " if there are at least N+1 free spaces in the stack (<N_K), "-" otherwise. (?<N_Kd\-) • ")" ($$)
• "-" if there are at least N+4 overflowing pieces in the stack (<N-K3), "" otherwise. (*<N-K3\-)

JavaScript (ES6), 105 102 bytes

@Edit: Saved 3 bytes thanks to @PatrickRoberts.

f=
(n,h)=> \\|/.substr(0,n+1-h)+[...Array(h)].map((_,i)=>
(${i+n<h? :-})${i+h+3<n?-:}).join
;
<div oninput=o.textContent=f(+n.value,+h.value)>n<input id=n type=number min=0 value=0>h<input id=h type=number min=0 value=0><pre id=o>

JavaScript (ES6), 126122 112 bytes

h=>n=>' \\|/'.substr(0,(o=n-h)+1)+
( )[r='repeat'](0>-o?0:-o)+
(-)-[r](o=0>o-3?0:o-3)+
(-)[r](n<h-o?n:h-o)


Test

f=h=>n=>' \\|/'.substr(0,(o=n-h)+1)+
( )[r='repeat'](0>-o?0:-o)+
(-)-[r](o=0>o-3?0:o-3)+
(-)[r](n<h-o?n:h-o)
document.write(<pre>${[[2,0],[2,1],[2,2],[2,3],[2,4],[2,5],[2,6],[2,7],[1,1],[1,5],[4,7],[5,0]].map(a=>f(a.shift())(a.shift())).join }</pre>) Alternate Test (if your browser does not support ES6) See the test on Babeljs.io and check "evaluate". Interesting alternate approach at 136 bytes h=>n=>' \\|/'.substr(0,(o=n-h)+1)+ ( )${0>-o?0:-o}
(-)-${o=0>o-3?0:o-3} (-)${n<h-o?n:h-o}.replace(/(\n.*)(\d+)/g,(_,s,r)=>s.repeat(r))


This moves the repeat amounts into the template string and uses a regexp and replace to inject the repeating groups. Unfortunately the signature for .replace() is just too long.