anon
anon

Reputation: 21

Creating bar graphs with groups of data

So I'm trying to create a bar graph that features three different bars for each entry, how many people took a test, how many failed, and how many passed, all together for each test. My code looks like this:

for (i = 0; i < evolNumber; i++) {
    if (chosenReports[i] == 1) {
        reportAttemptSummary += '<td class="TableArea" style="width:20px" align="center" valign="bottom">' +
        attemptTotal[i] +
        '<div style="background:black;width:20px;height:' +
        (attemptTotal[i] * 4) +
        'px"> </div>'+
        '</td>' +
        '<td class="TableArea" style="width:20px" align="center" valign="bottom">' +attemptPass[i]+
        '<div style="background:green;width:20px;height:' +
        (attemptPass[i] * 4) +
        'px"> </div>' +
        '</td>' +
        '<td class="TableArea" style="width:20px" align="center" valign="bottom">' +
        attemptFail[i] +
        '<div style="background:red;width:20px;height:' +
        (attemptFail[i] * 4) +
        'px"> </div>' +
        '</td>';
    }
}

How do I get these three bars to have a single title under all three of them:

Upvotes: 1

Views: 119

Answers (1)

Vincent Ramdhanie
Vincent Ramdhanie

Reputation: 103135

Since you seem to be outputing a HTML table then its a matter of creating a row directly after the row with the bars. So If you mean to have a single title that spans across the 3 bars then:

  <tr>
     <td colspan="3">Your single title here</td>
  </tr>

will do the trick if you output it after the row with the bars.

Upvotes: 3

Related Questions