82 : void {
83 $votes_label = $this->
lng->txt(
'poll_chart_votes');
84 $c_dimension = $this->data_factory->dimension()->cardinal();
85
86 $dimensions = [];
87 $data_values = [];
88 $bar_configs = [];
89 $tooltips = [];
90 $color_index = 0;
94 $tooltip = $total_votes .
' (' . round(
$results->getAnswerPercentage(
$id)) .
'%)';
96
97 $dimensions[$label] = $c_dimension;
98 $data_values[$label] = $total_votes;
99 $bar_configs[$label] = $bar_config->withColor(
100 $this->data_factory->color(self::STACKED_BAR_COLORS[$color_index])
101 )->withRelativeWidth(self::STACKED_BAR_WIDTH);
102 $tooltips[$label] = $tooltip;
103
104 $color_index = ($color_index + 1) >= count(self::STACKED_BAR_COLORS) ? 0 : ($color_index + 1);
105 }
106
107 $dimension_group = $this->data_factory->dimension()->group();
108 $dataset = $this->data_factory->dataset(
109 $dimensions,
110 ['stacked' => $this->data_factory->dimension()->group(...array_keys($dimensions))]
111 )->withPoint(
112 $votes_label,
113 $data_values
114 )->withAlternativeInformation(
115 $votes_label,
116 $tooltips
117 );
118
120 $group_config = $group_config->withStacked(true);
121 $chart = $this->ui_factory->chart()->bar()->horizontal('', $dataset)
122 ->withTitleVisible(false)
123 ->withLegendVisible(true)
124 ->withBarConfigs($bar_configs)
125 ->withGroupConfigs(['stacked' => $group_config]);
126 $tpl->
setVariable(
'CHART', $this->ui_renderer->render($chart));
127 }