Blame view

app/main/static/js/charges.js 16.3 KB
5e6f4e07   hitier   Set Rokotyan Solu...
1
/* Round float to two decimals only */
966f9b78   hitier   Js Round float be...
2
3
4
5
function roundToTwo(num) {
    return +(Math.round(num + "e+2")  + "e-2");
}

90c7b0e4   hitier   Small comments an...
6
7
function build_chart(div_selector, data_url, entity_name, category_type) {

5f89fdc7   hitier   Fix color scale: ...
8
    const main_elt = document.getElementById("main")
7c1b38be   hitier   Draw charts to fi...
9

13c144c8   Anais Amato   Add horizontal le...
10
    const margin = {top: 60, right: 150, bottom: 200, left: 90},
5f89fdc7   hitier   Fix color scale: ...
11
        width = main_elt.offsetWidth * 0.95 - margin.left - margin.right,
13c144c8   Anais Amato   Add horizontal le...
12
        height = 600 - margin.top - margin.bottom;
54e2baa6   hitier   Add charge charts...
13

90c7b0e4   hitier   Small comments an...
14
    const height_ratio = 1.2;    // how murch room to give above chart for lisibility
ff5fd5bf   hitier   Less and Longer ...
15

5f89fdc7   hitier   Fix color scale: ...
16
17
    const tooltip_offset = {dx: 0, dy: 100}
    const tooltip_offset_dot = {dx: 20, dy: 60}
f9fef9d0   hitier   Add tooltip
18

90c7b0e4   hitier   Small comments an...
19
    const y_ticks_num = 5        // dont show to many y ticks for lisibility
f0706d95   hitier   Add color legend
20

13c144c8   Anais Amato   Add horizontal le...
21
22
23
24
25
    const legendRectSize = 15; // size of rectangle in legend

    // const legend_cell_size = 15; // size of legend colored scare
    // const legend_x = width + 20; // begin legend a bit after the end of the chart
    // const legend_y = 600 - margin.bottom + 20; // begin legend a bit after the end of the chart
54e2baa6   hitier   Add charge charts...
26

90c7b0e4   hitier   Small comments an...
27
    const dot_radius = 6;        // size of total line dot
f9c1f568   hitier   Add dot on total ...
28

5f89fdc7   hitier   Fix color scale: ...
29
30
    const xScale = d3.scaleBand()
        .range([0, width])
67ab2300   hitier   Fix appearance de...
31
        .padding(0.4);
6b44860d   hitier   Make a draw_line ...
32

5f89fdc7   hitier   Fix color scale: ...
33
    const yScale = d3.scaleLinear()
90c7b0e4   hitier   Small comments an...
34
        .range([height, 0]);
54e2baa6   hitier   Add charge charts...
35

90c7b0e4   hitier   Small comments an...
36
    var colorScale = d3.scaleOrdinal([]); //  Will be really set later by category type
de63cb72   hitier   Add title to proj...
37

90c7b0e4   hitier   Small comments an...
38
39
40
41

    //
    // Configure chart by the category given as arg
    //
83d933c9   hitier   New draw_categori...
42
43
    var chart_title = ""
    var category_title = ""
90c7b0e4   hitier   Small comments an...
44
45
    var draw_total_line = () => void 0;
    var draw_categories_bars = () => void 0;
7d095c38   hitier   One color scale b...
46

90c7b0e4   hitier   Small comments an...
47
    if (category_type == 'capacity') {
83d933c9   hitier   New draw_categori...
48
49
50
51
        chart_title = "Charges par fonction"
        category_title = "Fonction"
        //draw_total_line
        draw_categories_bars = draw_categories_grouped
7d095c38   hitier   One color scale b...
52
        colorScale = d3.scaleOrdinal(d3.schemeSet3);
90c7b0e4   hitier   Small comments an...
53
    } else if (category_type == 'service') {
83d933c9   hitier   New draw_categori...
54
55
56
57
        chart_title = "Charges par service"
        category_title = "Service"
        draw_total_line = draw_totalcharge_line
        draw_categories_bars = draw_categories_stacked
7d095c38   hitier   One color scale b...
58
        colorScale = d3.scaleOrdinal(d3.schemeTableau10);
90c7b0e4   hitier   Small comments an...
59
    } else if (category_type == 'project') {
c8b7caf5   hitier   Agent now uses co...
60
61
62
63
        chart_title = "Charges par projet"
        category_title = "Projet"
        draw_categories_bars = draw_categories_stacked
        colorScale = d3.scaleOrdinal(d3.schemeTableau10);
6b44860d   hitier   Make a draw_line ...
64
65
    } else {
        alert("ALERT ! Every body shall quit the boat, we are sinking ! ALERT !")
de63cb72   hitier   Add title to proj...
66
    }
54e2baa6   hitier   Add charge charts...
67

a30b11ff   Anais Amato   Add an 'export me...
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
    // Configure the tooltip to export svg to png or csv
    var update_export_menu = function (e, d) {

        const tooltip_test = document.getElementsByClassName('tooltip_hamburger');

        if (tooltip_test.length == 0) {
            d3.select(".tooltip_hamburger").remove();

            const tooltip_hamburger = hamburger.append("div")
                .style("opacity", 0)
                .attr("class", "tooltip tooltip_hamburger");

            d3.select(this).transition()
                .duration(1)
            tooltip_hamburger
                .transition()
                .duration(200)
                .style("opacity", 1)
            tooltip_hamburger
                .html("<span>Export </span>" +
7d42e277   hitier   Download chart csv
88
                    "<li id='to_csv'>To CSV</li>" +
a30b11ff   Anais Amato   Add an 'export me...
89
90
                    "<li id='to_png'>To PNG</li>")
            d3.select("#to_png").on("click", download_png);
7d42e277   hitier   Download chart csv
91
            d3.select("#to_csv").on("click", function(){download_csv(this, data_url);})
a30b11ff   Anais Amato   Add an 'export me...
92
93
94
95
96
        } else {
            d3.select(".tooltip_hamburger").remove();
        }

    }
cfc5bded   hitier   More chart classe...
97
    // Create a download button inside the div contaning svg chart
a30b11ff   Anais Amato   Add an 'export me...
98
99
100
101
    const hamburger = d3.select(div_selector).append('i')
        .attr('class', 'fas fa-bars fa-lg export')
        .on("click", update_export_menu);

cfc5bded   hitier   More chart classe...
102

54e2baa6   hitier   Add charge charts...
103
    const svg = d3.select(div_selector).append("svg")
cfc5bded   hitier   More chart classe...
104
        .attr("class", "svg_chart")
54e2baa6   hitier   Add charge charts...
105
106
107
108
109
        .attr("width", width + margin.left + margin.right)
        .attr("height", height + margin.top + margin.bottom)
        .append("g")
        .attr("transform", "translate(" + margin.left + "," + margin.top + ")");

069a5102   hitier   Fixed tooltip
110
    const tooltip = d3.select('html')
f9fef9d0   hitier   Add tooltip
111
112
113
114
115
116
117
118
119
120
121
122
123
        .append("div")
        .style("opacity", 0)
        .attr("class", "tooltip")

    var mousemove = function (e, d) {
        tooltip
            .style("left", (e.pageX - tooltip_offset.dx) + "px")
            .style("top", (e.pageY - tooltip_offset.dy) + "px")
    }

    var mouseleave = function (d) {
        tooltip
            .transition()
67ab2300   hitier   Fix appearance de...
124
            .duration(900)
f9fef9d0   hitier   Add tooltip
125
126
127
128
129
130
            .style("opacity", 0)
    }

    var mouseover = function (e, d) {
        var category_name = d3.select(this.parentNode).datum().key
        var category_charge = d.data[category_name]
22397f43   hitier   Show tooltip on g...
131
132
133
134
135
136
137
138
139
        show_tooltip(e, category_name, category_charge)
    }

    var mouseovergrouped = function (e, d) {
        var category_name = d.key
        var category_charge = d.value
        show_tooltip(e, category_name, category_charge)
    }
    var show_tooltip = function (e, category_name, category_charge) {
f9fef9d0   hitier   Add tooltip
140
141
142
143
144
        tooltip
            .transition()
            .duration(200)
            .style("opacity", 1);
        tooltip
582e1ee2   hitier   Change charts leg...
145
            .html("<b>" + category_title + ":</b> " + category_name + "<br>" + "<b>Charge:</b> " + category_charge + " ETP")
f9fef9d0   hitier   Add tooltip
146
147
148
149
            .style("left", (e.pageX - tooltip_offset.dx) + "px")
            .style("top", (e.pageY - tooltip_offset.dy) + "px")
    }

f9c1f568   hitier   Add dot on total ...
150
151
152
153
154
155
    var mouseleavedot = function (e, d) {
        d3.select(this).transition()
            .duration(1)
            .attr("r", dot_radius);
        mouseleave(d);
    }
6b44860d   hitier   Make a draw_line ...
156

f9c1f568   hitier   Add dot on total ...
157
158
159
160
161
162
163
164
165
    var mouseoverdot = function (e, d) {
        d3.select(this).transition()
            .duration(1)
            .attr("r", dot_radius * 1.5);
        tooltip
            .transition()
            .duration(200)
            .style("opacity", 1)
        tooltip
582e1ee2   hitier   Change charts leg...
166
            .html("<b>" + d.period + ": </b>" + d.total + " ETP")
f9c1f568   hitier   Add dot on total ...
167
168
169
170
            .style("left", (e.pageX - tooltip_offset_dot.dx) + "px")
            .style("top", (e.pageY - tooltip_offset_dot.dy) + "px")
    }

f0706d95   hitier   Add color legend
171
172
    var addlegend = function (color_scale) {

13c144c8   Anais Amato   Add horizontal le...
173
        // add horizontal legend
48613832   hitier   Fix legend keys o...
174
        let legend_keys = color_scale.domain();
13c144c8   Anais Amato   Add horizontal le...
175
        var legendSpacing = 5;
f0706d95   hitier   Add color legend
176

13c144c8   Anais Amato   Add horizontal le...
177
178
179
        var legendWrap = svg.append('g')
            .attr('width', '100%')
            .attr('class', 'legendwrap');
f0706d95   hitier   Add color legend
180

13c144c8   Anais Amato   Add horizontal le...
181
        var legend = svg.select('.legendwrap').selectAll('.legend')
48613832   hitier   Fix legend keys o...
182
            .data(legend_keys)
13c144c8   Anais Amato   Add horizontal le...
183
184
185
            .enter()
            .append('g')
            .attr('class', 'legend');
f0706d95   hitier   Add color legend
186

13c144c8   Anais Amato   Add horizontal le...
187
188
189
190
        legend.append('rect')
            .attr('width', legendRectSize)
            .attr('height', legendRectSize)
            .style('fill', color_scale)
cfc5bded   hitier   More chart classe...
191
            .attr('class', 'legend');
13c144c8   Anais Amato   Add horizontal le...
192
193

        legend.append('text')
f0706d95   hitier   Add color legend
194
            .attr('class', 'legend')
13c144c8   Anais Amato   Add horizontal le...
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
            .attr('x', legendRectSize + legendSpacing * 1.5)
            .attr('y', 13)
            .text(function(d) {
                return d;
            });

        var ypos = 0,
            newxpos = 0,
            maxwidth = 0,
            xpos;

        legend
            .attr("transform", function(d, i) {
                var length = d3.select(this).select("text").node().getComputedTextLength() + 40;
                xpos = newxpos;
                if (width < xpos + length) {
                    newxpos = xpos = 0;
                    ypos += 30;
                }
                newxpos += length;
                if (newxpos > maxwidth) maxwidth = newxpos;

                return 'translate(' + xpos + ',' + ypos + ')';

            });


        legendWrap
            .attr("transform", function(d, i) {
                return "translate(0 ," + (height + 100) + ")";
            });

f0706d95   hitier   Add color legend
227
228
    }

83d933c9   hitier   New draw_categori...
229
230
    function draw_categories_grouped(data, categories) {

a07df204   hitier   Compute for group...
231
232
        var y_max = d3.max(data, function (d) {
            return d3.max(categories, function (c) {
a5294567   hitier   Rewrite anonymous...
233
                return +d[c]
a07df204   hitier   Compute for group...
234
235
236
237
            })
        });
        y_max = y_max * height_ratio
        yScale.domain([0, y_max])
83d933c9   hitier   New draw_categori...
238
239
240
241
        // Another scale for subgroup position
        var xCategories = d3.scaleBand()
            .domain(categories)
            .range([0, xScale.bandwidth()])
67ab2300   hitier   Fix appearance de...
242
            .padding([0.2])
83d933c9   hitier   New draw_categori...
243
244
245
246
247
248
249

        svg.append("g")
            .selectAll("g")
            // Enter in data = loop group per group
            .data(data)
            .enter()
            .append("g")
a5294567   hitier   Rewrite anonymous...
250
            .attr("transform", d => "translate(" + xScale(d.period) + ",0)")
83d933c9   hitier   New draw_categori...
251
252
253
254
255
256
257
            .selectAll("rect")
            .data(function (d) {
                return categories.map(function (key) {
                    return {key: key, value: d[key]};
                });
            })
            .enter().append("rect")
a5294567   hitier   Rewrite anonymous...
258
            .attr("x", d => xCategories(d.key))
83d933c9   hitier   New draw_categori...
259
            .attr("width", xCategories.bandwidth())
8dad7ce7   Anais Amato   Add animations to...
260
261
262
263
264
265
266
267
268
                /* Transition part */
                .attr("y",  d => { return height; })
                .attr("height", 0)
                    .transition()
                    .duration(750)
                    .delay(function (d, i) {
                        return i * 150;
                    })
            .attr("y", d => yScale(d.value))
a5294567   hitier   Rewrite anonymous...
269
            .attr("height", d => height - yScale(d.value))
22397f43   hitier   Show tooltip on g...
270
            .attr("fill", d => colorScale(d.key))
8dad7ce7   Anais Amato   Add animations to...
271
272
273
            .attr("class", "bar");

        svg.selectAll("rect")
22397f43   hitier   Show tooltip on g...
274
275
276
            .on("mouseover", mouseovergrouped)
            .on("mousemove", mousemove)
            .on("mouseleave", mouseleave);
83d933c9   hitier   New draw_categori...
277

8dad7ce7   Anais Amato   Add animations to...
278

a48677c4   hitier   Make a draw_categ...
279
280
    }

83d933c9   hitier   New draw_categori...
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
    function draw_categories_stacked(data, categories) {

        // Now build the stacked data for stacked bars
        //
        var stack = d3.stack()
            .keys(categories)
        // .order(d3.stackOrderNone)
        // .offset(d3.stackOffsetNone);
        var stacked_data = stack(data)

        // Get the max y to plot
        var y_max = d3.max(stacked_data[stacked_data.length - 1], d => d[1]);
        if (y_max == 0) {
            y_max = 100
        }
        // Enhance it by %ratio to leave room on the top of the graph
        y_max = y_max * height_ratio

        yScale.domain([0, y_max]);

90c7b0e4   hitier   Small comments an...
301
        // first draw one group for one category containing all bars over periods
a48677c4   hitier   Make a draw_categ...
302
303
304
305
        let groups = svg.selectAll("g.category")
            .data(stacked_data)
            .enter()
            .append("g")
83d933c9   hitier   New draw_categori...
306
            .style("fill", (d) => colorScale(d.key));
a48677c4   hitier   Make a draw_categ...
307

90c7b0e4   hitier   Small comments an...
308
        // then draw each period/category bar
a48677c4   hitier   Make a draw_categ...
309
310
311
312
313
314
315
        let rect = groups.selectAll("rect")
            .data(d => d)
            .enter()
            .append("rect")
            .attr("class", "bar")
            .attr("x", d => xScale(d.data.period))
            .attr("width", xScale.bandwidth())
8dad7ce7   Anais Amato   Add animations to...
316
317
318
319
320
321
322
323
                /* transition part */
                .attr("y",  d => { return height; })
                .attr("height", 0)
                    .transition()
                    .duration(750)
                    .delay(function (d, i) {
                        return i * 150;
                    })
a48677c4   hitier   Make a draw_categ...
324
325
            .attr("y", d => yScale(d[1]))
            .attr("height", d => height - yScale(d[1] - d[0]))
8dad7ce7   Anais Amato   Add animations to...
326
327

        groups.selectAll("rect")
a48677c4   hitier   Make a draw_categ...
328
329
330
331
332
333
            .on("mouseover", mouseover)
            .on("mousemove", mousemove)
            .on("mouseleave", mouseleave);

    }

6b44860d   hitier   Make a draw_line ...
334
335
    function draw_totalcharge_line(data) {
        // Build the total charge by period;
518c7cc5   hitier   Draw the total ca...
336
337
        // it will be used for the line drawing above bars.
        //
6b44860d   hitier   Make a draw_line ...
338
339
        var periods_total_charge = []

518c7cc5   hitier   Draw the total ca...
340
341
342
343
344
        data.forEach(function (d) {
            // get the list of values for all columns except the first one which is the period name
            var period_values = Object.values(d).slice(1)
            var row = {}
            row['period'] = d.period
966f9b78   hitier   Js Round float be...
345
            row['total'] = roundToTwo(d3.sum(period_values))
518c7cc5   hitier   Draw the total ca...
346
347
348
            periods_total_charge.push(row)
        });

6b44860d   hitier   Make a draw_line ...
349
350
351
352
353
354
355
356
357
358
        // the line itselet
        //
        const line = d3.line()
            .x(d => (xScale.bandwidth() / 2) + xScale(d.period)) // décalage pour centrer au milieu des barres
            .y(d => yScale(d.total))
            .curve(d3.curveMonotoneX); // Fonction de courbe permettant de l'adoucir

        svg.append("path")
            .datum(periods_total_charge)
            .attr("class", "total-line")
83d933c9   hitier   New draw_categori...
359
360
            .attr("d", line)
            .lower();// set it below bars if called after
6b44860d   hitier   Make a draw_line ...
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375

        // data dots at each point
        //
        svg.selectAll("line-circle")
            .data(periods_total_charge)
            .enter().append("circle")
            .attr("class", "total-circle")
            .attr("r", dot_radius)
            .attr("cx", function (d) {
                return (xScale.bandwidth() / 2) + xScale(d.period)
            })
            .attr("cy", function (d) {
                return yScale(d.total);
            })
            .on("mouseover", mouseoverdot)
83d933c9   hitier   New draw_categori...
376
377
            .on("mouseleave", mouseleavedot)
            .lower();// set it below bars if called after
6b44860d   hitier   Make a draw_line ...
378
379
380
381

    }

    d3.csv(data_url).then(data => {
a07df204   hitier   Compute for group...
382
        // we could get categories that way,
90c7b0e4   hitier   Small comments an...
383
        // but instead we want to filter by non zero, see later
6b44860d   hitier   Make a draw_line ...
384
        // var categories = data.columns.slice(1)
90c7b0e4   hitier   Small comments an...
385

6b44860d   hitier   Make a draw_line ...
386
387
388
        var periods = d3.map(data, d => d.period)
        xScale.domain(periods)

90c7b0e4   hitier   Small comments an...
389
390
        // Filter datas to only keep non zero categories
        // TODO: should be done on server (python/flask) side
518c7cc5   hitier   Draw the total ca...
391
        //
90c7b0e4   hitier   Small comments an...
392
        // 1- Get the charge sum for each category over periods
f0706d95   hitier   Add color legend
393
        // That will leave '0' to categories with no charge at all
a07df204   hitier   Compute for group...
394
        // TODO: to be done with Object.keys, Object.values and d3 filtering methods
ce5f45ea   hitier   Fix data bug
395
        //
6b44860d   hitier   Make a draw_line ...
396
        var categories_total_charge = {}
f0706d95   hitier   Add color legend
397
398
        data.forEach(function (d) {
            Object.keys(d).forEach(function (k) {
04f2b6e8   hitier   Fix period as cat...
399
400
401
                    if (k === 'period') {
                        return;
                    }
f0706d95   hitier   Add color legend
402
403
404
                    if (categories_total_charge.hasOwnProperty(k)) {
                        categories_total_charge[k] += +d[k]
                    } else {
582e1ee2   hitier   Change charts leg...
405
                        categories_total_charge[k] = +d[k]
f0706d95   hitier   Add color legend
406
                    }
966f9b78   hitier   Js Round float be...
407
                    categories_total_charge[k] = roundToTwo(categories_total_charge[k])
f0706d95   hitier   Add color legend
408
409
410
411
                }
            )
        })

518c7cc5   hitier   Draw the total ca...
412
        // 2- Now, filter only categories that have a non-zero charge
a07df204   hitier   Compute for group...
413
        // TODO: to be done with Object.keys, Object.values and d3 filtering methods
90c7b0e4   hitier   Small comments an...
414
        //
f0706d95   hitier   Add color legend
415
416
417
418
419
420
421
        var categories = []
        for (var key in categories_total_charge) {
            if (categories_total_charge[key] > 0) {
                categories.push(key)
            }
        }

518c7cc5   hitier   Draw the total ca...
422
        //
90c7b0e4   hitier   Small comments an...
423
        // Draw the  bars, stacked or grouped
83d933c9   hitier   New draw_categori...
424
425
        //
        draw_categories_bars(data, categories)
54e2baa6   hitier   Add charge charts...
426

518c7cc5   hitier   Draw the total ca...
427
        //
83d933c9   hitier   New draw_categori...
428
429
430
431
432
433
434
435
436
437
        //  Draw the total charge line ( may be)
        //
        draw_total_line(data, categories)

        //
        // This former list we use as color_scale domain.
        // And that allows us to build the legend
        //
        colorScale.domain(categories)
        addlegend(colorScale)
54e2baa6   hitier   Add charge charts...
438

f0706d95   hitier   Add color legend
439
440
        // Xaxis
        //
518c7cc5   hitier   Draw the total ca...
441
        const xAxis = d3.axisBottom(xScale)
f0706d95   hitier   Add color legend
442

f0706d95   hitier   Add color legend
443
        // Draw Xaxis
68fd83a8   hitier   Add axis
444
        svg.append("g")
cfc5bded   hitier   More chart classe...
445
            .attr("class", "x_axis")
68fd83a8   hitier   Add axis
446
447
448
449
450
451
452
453
            .attr("transform", "translate(0," + height + ")")
            .call(xAxis)
            .selectAll("text")
            .style("text-anchor", "end")
            .attr("dx", "-.9em")
            .attr("dy", ".15em")
            .attr("transform", "rotate(-65)");

90c7b0e4   hitier   Small comments an...
454
455
456
457
458
        // Yaxis
        //
        const yAxis = d3.axisLeft(yScale)
            .ticks(y_ticks_num)

f0706d95   hitier   Add color legend
459
        // Draw Yaxis
68fd83a8   hitier   Add axis
460
        svg.append("g")
cfc5bded   hitier   More chart classe...
461
            .attr("class", "y_axis")
68fd83a8   hitier   Add axis
462
            .call(yAxis)
68fd83a8   hitier   Add axis
463

ff5fd5bf   hitier   Less and Longer ...
464
465
466
467
468
469
470
471
472
473
        // Draw horizontal lines
        svg.selectAll("y axis")
            .data(yScale.ticks(y_ticks_num))
            .enter()
            .append("line")
            .attr("class", d => (d == 0 ? "horizontalY0" : "horizontalY"))
            .attr("x1", 0)
            .attr("x2", width)
            .attr("y1", d => yScale(d))
            .attr("y2", d => yScale(d))
83d933c9   hitier   New draw_categori...
474
            .lower();// set it below bars if called after
ff5fd5bf   hitier   Less and Longer ...
475

f0706d95   hitier   Add color legend
476
        // Write Y axis title
68fd83a8   hitier   Add axis
477
478
479
480
481
        svg.append("text")
            .attr("text-anchor", "end")
            .attr("transform", "rotate(-90)")
            .attr("y", -margin.left + 40)
            .attr("x", -margin.top - 70)
582e1ee2   hitier   Change charts leg...
482
            .text("Charge en ETP");
54e2baa6   hitier   Add charge charts...
483

6b44860d   hitier   Make a draw_line ...
484
        //
f0706d95   hitier   Add color legend
485
        // Write chart Title
6b44860d   hitier   Make a draw_line ...
486
487
        //

f0706d95   hitier   Add color legend
488
        // part 1
de63cb72   hitier   Add title to proj...
489
        svg.append("text")
3c21ae9f   hitier   Change bar colors
490
491
492
493
            .attr("x", (width / 2))
            .attr("y", 0 - (margin.top / 2) - 10)
            .attr("text-anchor", "middle")
            .style("font-size", "16px")
c8b7caf5   hitier   Agent now uses co...
494
            .text(entity_name);
f0706d95   hitier   Add color legend
495
        // part 2
de63cb72   hitier   Add title to proj...
496
        svg.append("text")
3c21ae9f   hitier   Change bar colors
497
498
499
500
501
            .attr("x", (width / 2))
            .attr("y", 0 - (margin.top / 2) + 10)
            .attr("text-anchor", "middle")
            .style("font-size", "12px")
            .text(chart_title);
54e2baa6   hitier   Add charge charts...
502

518c7cc5   hitier   Draw the total ca...
503

6b44860d   hitier   Make a draw_line ...
504
    }); // end of d3.csv().then({})
54e2baa6   hitier   Add charge charts...
505
506

}