Skip to content
This repository has been archived by the owner on Dec 16, 2020. It is now read-only.

Commit

Permalink
Merge pull request #214 from wmde/fix_color_order
Browse files Browse the repository at this point in the history
Fix color order in pie chart.
  • Loading branch information
Christoph Fischer committed Feb 15, 2016
2 parents 77bc155 + 0b15ea0 commit bc21143
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/Phragile/PieChart.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ private function sortByCssClass(array $data)
{
uasort($data, function($a, $b)
{
return $a < $b ? 1 : -1;
return $a['cssClass'] > $b['cssClass'] ? 1 : -1;
});

return $data;
Expand Down
19 changes: 19 additions & 0 deletions tests/unit/PieChartTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,23 @@ public function testHasCssClassAsKeys()
$this->assertArrayHasKey('closed deployed', $colorMap);
$this->assertArrayHasKey('closed wontfix', $colorMap);
}

public function testOrdersByCssClass()
{
$chart = new PieChart(
[
'Done' => ['points' => 10],
'Doing' => ['points' => 11],
'Blocked By Others' => ['points' => 12],
'Deployed' => ['points' => 13]
],
new StatusCssClassService(true, ['Done', 'Deployed'])
);

$colorMap = array_values($chart->getData());
$this->assertSame($colorMap[0]['cssClass'], 'closed deployed');
$this->assertSame($colorMap[1]['cssClass'], 'closed done');
$this->assertSame($colorMap[2]['cssClass'], 'open blocked-by-others');
$this->assertSame($colorMap[3]['cssClass'], 'open doing');
}
}

0 comments on commit bc21143

Please sign in to comment.