/** * Get the chart for displaying the previous version being upgrade from. * * @since 1.0 * * @param Release $release * * @return Chart\Base */ private function get_version_chart(Release $release) { if ($release->get_status() == Release::STATUS_DRAFT) { return null; } $results = $release->get_top_5_previous_versions(); $chart = new Chart\Pie(698, 200, array('ibdLoadOn' => 'loadVersionsChart', 'ibdShowLegend' => '#pie-chart-legend', 'tooltipTemplate' => '<%= value %> install<%if (value != 1){%>s<%}%>', 'responsive' => true)); $colors = array(array('color' => '#E94F37', 'highlight' => '#FF6951'), array('color' => '#393E41', 'highlight' => '#53585B'), array('color' => '#3F88C5', 'highlight' => '#59A2DF'), array('color' => '#44BBA4', 'highlight' => '#5ED5BE'), array('color' => '#EDDDD4', 'highlight' => '#D4C4BB')); $i = 0; foreach ($results as $version => $count) { $label = empty($version) ? __("Unknown", Plugin::SLUG) : "v{$version}"; $chart->add_data_set($count, $label, $colors[$i]); $i++; } return $chart; }