Skip to content

Commit 45c61fb

Browse files
committedMar 26, 2025·
Graph type 28: implement first scenario
1 parent 7dc7941 commit 45c61fb

File tree

4 files changed

+98
-10
lines changed

4 files changed

+98
-10
lines changed
 

‎econplayground/main/views.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def get_context_data(self, *args, **kwargs):
155155
},
156156
{
157157
'graph_type': 28,
158-
'image': None,
158+
'image': 'graph_types/graph_28.png',
159159
},
160160
]
161161
})

‎media/img/graph_types/graph_28.png

26.6 KB
Loading

‎media/js/src/editors/PositiveExternalityIndustryEditor.jsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@ export default class PositiveExternalityIndustryEditor extends React.Component {
1010
const modesLeft = [
1111
'Positive Industry Externality',
1212
'Unregulated',
13-
'Welfare',
1413
];
1514
const modesRight = [
16-
'Pigouvian Tax',
17-
'Pigouvian Tax (Welfare)',
15+
'Welfare distribution',
1816
];
1917

2018
const radioButtons1 = modesLeft.map((optionTitle, idx) =>

‎media/js/src/graphs/PositiveExternalityIndustryGraph.js

+96-6
Original file line numberDiff line numberDiff line change
@@ -71,30 +71,70 @@ const ep3 = function(a, b, c, d) {
7171
7272
const eq3 = function(a, b, c, d) {
7373
return (a - c) / (b + d);
74-
};*/
74+
};*/
75+
76+
const sq3 = function(a, b, c, d, f, g) {
77+
return (a - c + f) / (b + d + g);
78+
};
79+
80+
const sp3 = function(a, b, c, d, f, g) {
81+
return smb3(a, b, f, g, sq3(a, b, c, d, f, g));
82+
};
83+
84+
const spoint3 = function(a, b, c, d, f, g) {
85+
return [sq3(a, b, c, d, f, g), sp3(a, b, c, d, f, g)];
86+
};
87+
88+
const shint3 = function(a, b, c, d, f, g) {
89+
return [0, sp3(a, b, c, d, f, g)];
90+
};
91+
92+
const svint3 = function(a, b, c, d, f, g) {
93+
return [sq3(a, b, c, d, f, g), 0];
94+
};
95+
96+
const ep3 = function(a, b, c, d) {
97+
return (b * c + a * d) / (b + d);
98+
};
99+
100+
const eq3 = function(a, b, c, d) {
101+
return (a - c) / (b + d);
102+
};
103+
104+
const epoint3 = function(a, b, c, d) {
105+
return [eq3(a, b, c, d), ep3(a, b, c, d)];
106+
};
107+
108+
const ehint3 = function(a, b, c, d) {
109+
return [0, ep3(a, b, c, d)];
110+
};
111+
112+
const evint3 = function(a, b, c, d) {
113+
return [eq3(a, b, c, d), 0];
114+
};
75115

76116
export class PositiveExternalityIndustryGraph extends Graph {
77-
static getGraphPane(gFunctionChoice) {
117+
static getGraphPane(gFunctionChoice, gA1, gA2, gA3, gA4, gA5, gA6) {
78118
return [
79119
{
80120
label: 'Unregulated Output Q*',
81121
color: 'red',
82-
value: 240
122+
value: eq3(gA1, gA2, gA3, gA4).toFixed(2)
83123
},
84124
{
85125
label: 'Unregulated Price P*',
86126
color: 'red',
87-
value: 120
127+
value: ep3(gA1, gA2, gA3, gA4).toFixed(2)
88128
},
89129
{
90130
label: 'Socially Desirable Output q<sup>soc</sup>',
91131
color: 'orange',
92-
value: 266.667
132+
value: sq3(gA1, gA2, gA3, gA4, gA5, gA6).toFixed(2)
93133
},
94134
{
95135
label: 'Socially Desirable Price P<sup>soc</sup>',
96136
color: 'orange',
97-
value: 133.333
137+
value: sp3(gA1, gA2, gA3, gA4, gA5, gA6).toFixed(2)
98138
},
99139
];
100140
}
@@ -179,6 +219,56 @@ export class PositiveExternalityIndustryGraph extends Graph {
179219
highlight: false
180220
}
181221
);
222+
223+
if (this.options.gShowIntersection) {
224+
const spointEvaluated = spoint3(
225+
this.options.gA1, this.options.gA2, this.options.gA3,
226+
this.options.gA4, this.options.gA5, this.options.gA6);
227+
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);
247+
248+
const epointEvaluated = epoint3(
249+
this.options.gA1, this.options.gA2, this.options.gA3,
250+
this.options.gA4);
251+
252+
this.showIntersection(
253+
this.board.create('line', [
254+
ehint3(
255+
this.options.gA1, this.options.gA2, this.options.gA3,
256+
this.options.gA4),
257+
epointEvaluated
258+
], {
259+
visible: false
260+
}),
261+
this.board.create('line', [
262+
evint3(
263+
this.options.gA1, this.options.gA2, this.options.gA3,
264+
this.options.gA4),
265+
epointEvaluated
266+
], {
267+
visible: false
268+
}),
269+
false, 'Market', null, 'Q',
270+
false, false, this.l4Color);
271+
}
182272
}
183273
}
184274

0 commit comments

Comments
 (0)
Please sign in to comment.