Skip to content

Commit 2100453

Browse files
committed
Build out graph type 28
1 parent 0dfa67d commit 2100453

File tree

2 files changed

+130
-47
lines changed

2 files changed

+130
-47
lines changed

media/js/src/editors/PositiveExternalityIndustryEditor.jsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export default class PositiveExternalityIndustryEditor extends React.Component {
7272
id="gA1"
7373
value={this.props.gA1}
7474
min={0}
75-
max={350}
75+
max={this.props.gFunctionChoice === 1 ? 10000 : 350}
7676
handler={handleFormUpdate.bind(this)} />
7777

7878
<RangeEditor
@@ -81,7 +81,7 @@ export default class PositiveExternalityIndustryEditor extends React.Component {
8181
id="gA2"
8282
value={this.props.gA2}
8383
min={0.01}
84-
max={10}
84+
max={this.props.gFunctionChoice === 1 ? 35 : 10}
8585
handler={handleFormUpdate.bind(this)} />
8686

8787
<RangeEditor
@@ -90,7 +90,7 @@ export default class PositiveExternalityIndustryEditor extends React.Component {
9090
id="gA3"
9191
value={this.props.gA3}
9292
min={0}
93-
max={350}
93+
max={this.props.gFunctionChoice === 1 ? 10000 : 350}
9494
handler={handleFormUpdate.bind(this)} />
9595

9696
<RangeEditor
@@ -99,7 +99,7 @@ export default class PositiveExternalityIndustryEditor extends React.Component {
9999
id="gA4"
100100
value={this.props.gA4}
101101
min={0.01}
102-
max={10}
102+
max={this.props.gFunctionChoice === 1 ? 35 : 10}
103103
handler={handleFormUpdate.bind(this)} />
104104

105105
<RangeEditor
@@ -108,7 +108,7 @@ export default class PositiveExternalityIndustryEditor extends React.Component {
108108
id="gA5"
109109
value={this.props.gA5}
110110
min={0}
111-
max={350}
111+
max={this.props.gFunctionChoice === 1 ? 10000 : 350}
112112
handler={handleFormUpdate.bind(this)} />
113113

114114
<RangeEditor
@@ -117,7 +117,7 @@ export default class PositiveExternalityIndustryEditor extends React.Component {
117117
id="gA6"
118118
value={this.props.gA6}
119119
min={0.01}
120-
max={10}
120+
max={this.props.gFunctionChoice === 1 ? 35 : 10}
121121
handler={handleFormUpdate.bind(this)} />
122122
</>
123123
)}

media/js/src/graphs/PositiveExternalityIndustryGraph.js

+124-41
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Graph, positiveRange } from './Graph.js';
2+
import { drawPolygon } from '../jsxgraphUtils.js';
23

34
export const defaults = [
45
{
@@ -101,6 +102,10 @@ const eq3 = function(a, b, c, d) {
101102
return (a - c) / (b + d);
102103
};
103104

105+
const embmarket3 = function(a, b, c, d, f, g) {
106+
return f - g * eq3(a, b, c, d);
107+
};
108+
104109
const epoint3 = function(a, b, c, d) {
105110
return [eq3(a, b, c, d), ep3(a, b, c, d)];
106111
};
@@ -115,28 +120,86 @@ const evint3 = function(a, b, c, d) {
115120

116121
export class PositiveExternalityIndustryGraph extends Graph {
117122
static getGraphPane(gFunctionChoice, gA1, gA2, gA3, gA4, gA5, gA6) {
118-
return [
119-
{
120-
label: 'Unregulated Output Q*',
121-
color: 'red',
122-
value: eq3(gA1, gA2, gA3, gA4).toFixed(2)
123-
},
124-
{
125-
label: 'Unregulated Price P*',
126-
color: 'red',
127-
value: ep3(gA1, gA2, gA3, gA4).toFixed(2)
128-
},
129-
{
130-
label: 'Socially Desirable Output q<sup>soc</sup>',
131-
color: 'orange',
132-
value: sq3(gA1, gA2, gA3, gA4, gA5, gA6).toFixed(2)
133-
},
134-
{
135-
label: 'Socially Desirable Price P<sup>soc</sup>',
136-
color: 'orange',
137-
value: sp3(gA1, gA2, gA3, gA4, gA5, gA6).toFixed(2)
138-
},
139-
];
123+
if (gFunctionChoice === 0) {
124+
return [
125+
{
126+
label: 'Unregulated Output Q*',
127+
color: 'red',
128+
value: eq3(gA1, gA2, gA3, gA4).toFixed(2)
129+
},
130+
{
131+
label: 'Unregulated Price P*',
132+
color: 'red',
133+
value: ep3(gA1, gA2, gA3, gA4).toFixed(2)
134+
},
135+
{
136+
label: 'Socially Desirable Output q<sup>soc</sup>',
137+
color: 'orange',
138+
value: sq3(gA1, gA2, gA3, gA4, gA5, gA6).toFixed(2)
139+
},
140+
{
141+
label: 'Socially Desirable Price P<sup>soc</sup>',
142+
color: 'orange',
143+
value: sp3(gA1, gA2, gA3, gA4, gA5, gA6).toFixed(2)
144+
},
145+
];
146+
} else if (gFunctionChoice === 1) {
147+
return [
148+
{
149+
label: 'Unregulated Output Q*',
150+
color: 'red',
151+
value: eq3(gA1, gA2, gA3, gA4).toFixed(2)
152+
},
153+
{
154+
label: 'P*',
155+
color: 'red',
156+
value: eq3(gA1, gA2, gA3, gA4).toFixed(2)
157+
},
158+
{
159+
label: 'External Total Benefit',
160+
color: 'green',
161+
value: ep3(gA1, gA2, gA3, gA4).toFixed(2)
162+
}
163+
];
164+
} else if (gFunctionChoice === 2) {
165+
return [
166+
{
167+
label: 'Unregulated Output Q*',
168+
color: 'red',
169+
value: eq3(gA1, gA2, gA3, gA4).toFixed(2)
170+
},
171+
{
172+
label: 'Unregulated Price P*',
173+
color: 'red',
174+
value: eq3(gA1, gA2, gA3, gA4).toFixed(2)
175+
},
176+
{
177+
label: 'Socially Desirable Output Q<sup>soc</sup>',
178+
color: 'orange',
179+
value: eq3(gA1, gA2, gA3, gA4).toFixed(2)
180+
},
181+
{
182+
label: 'Socially Desirable Price P<sup>soc</sup>',
183+
color: 'orange',
184+
value: eq3(gA1, gA2, gA3, gA4).toFixed(2)
185+
},
186+
{
187+
label: 'External Total Benefit',
188+
color: 'green',
189+
value: ep3(gA1, gA2, gA3, gA4).toFixed(2)
190+
},
191+
{
192+
label: 'External Gain',
193+
color: 'green',
194+
value: ep3(gA1, gA2, gA3, gA4).toFixed(2)
195+
},
196+
{
197+
label: 'Market Loss',
198+
color: 'red',
199+
value: ep3(gA1, gA2, gA3, gA4).toFixed(2)
200+
}
201+
];
202+
}
140203
}
141204

142205
make() {
@@ -225,25 +288,27 @@ export class PositiveExternalityIndustryGraph extends Graph {
225288
this.options.gA1, this.options.gA2, this.options.gA3,
226289
this.options.gA4, this.options.gA5, this.options.gA6);
227290

228-
this.showIntersection(
229-
this.board.create('line', [
230-
shint3(
231-
this.options.gA1, this.options.gA2, this.options.gA3,
232-
this.options.gA4, this.options.gA5, this.options.gA6),
233-
spointEvaluated
234-
], {
235-
visible: false
236-
}),
237-
this.board.create('line', [
238-
svint3(
239-
this.options.gA1, this.options.gA2, this.options.gA3,
240-
this.options.gA4, this.options.gA5, this.options.gA6),
241-
spointEvaluated
242-
], {
243-
visible: false
244-
}),
245-
false, 'Social', null, 'Q<sup>soc</sup>',
246-
false, false, this.l1Color);
291+
if (this.options.gFunctionChoice !== 1) {
292+
this.showIntersection(
293+
this.board.create('line', [
294+
shint3(
295+
this.options.gA1, this.options.gA2, this.options.gA3,
296+
this.options.gA4, this.options.gA5, this.options.gA6),
297+
spointEvaluated
298+
], {
299+
visible: false
300+
}),
301+
this.board.create('line', [
302+
svint3(
303+
this.options.gA1, this.options.gA2, this.options.gA3,
304+
this.options.gA4, this.options.gA5, this.options.gA6),
305+
spointEvaluated
306+
], {
307+
visible: false
308+
}),
309+
false, 'Social', null, 'Q<sup>soc</sup>',
310+
false, false, this.l1Color);
311+
}
247312

248313
const epointEvaluated = epoint3(
249314
this.options.gA1, this.options.gA2, this.options.gA3,
@@ -269,6 +334,24 @@ export class PositiveExternalityIndustryGraph extends Graph {
269334
false, 'Market', null, 'Q',
270335
false, false, this.l4Color);
271336
}
337+
338+
if (this.options.gFunctionChoice >= 1) {
339+
const eq3Evaluated = eq3(
340+
this.options.gA1, this.options.gA2,
341+
this.options.gA3, this.options.gA4);
342+
drawPolygon(
343+
this.board, [
344+
[eq3Evaluated, embmarket3(
345+
this.options.gA1, this.options.gA2,
346+
this.options.gA3, this.options.gA4,
347+
this.options.gA5, this.options.gA6
348+
)],
349+
[eq3Evaluated, 0],
350+
[0, 0],
351+
[0, this.options.gA5]
352+
], null, 'green'
353+
);
354+
}
272355
}
273356
}
274357

0 commit comments

Comments
 (0)