fix errors in new charts pandora_enterprise#9554

This commit is contained in:
daniel 2022-12-21 10:07:18 +01:00
parent ae88c33aad
commit 36eda00ae6
4 changed files with 86 additions and 44 deletions

View File

@ -4241,8 +4241,19 @@ function generator_chart_to_pdf(
];
}
// If not install chromium avoid 500 convert tu images no data to show.
$chromium_dir = io_safe_output($config['chromium_path']);
$result_ejecution = exec($chromium_dir.' --version');
if (empty($result_ejecution) === true) {
if ($params['return_img_base_64']) {
$params['base64'] = true;
}
return graph_nodata_image($params);
}
try {
$browserFactory = new BrowserFactory($config['chromium_path']);
$browserFactory = new BrowserFactory($chromium_dir);
// Starts headless chrome.
$browser = $browserFactory->createBrowser(['noSandbox' => true]);

View File

@ -2260,14 +2260,13 @@ function graphic_combined_module(
}
$options = [
'width' => $width,
'height' => $height,
'waterMark' => $water_mark,
'ttl' => $ttl,
'background' => $background_color,
'pdf' => $params['pdf'],
'legend' => ['display' => false],
'scales' => [
'width' => $width,
'height' => $height,
'waterMark' => $water_mark,
'ttl' => $ttl,
'pdf' => $params['pdf'],
'legend' => ['display' => false],
'scales' => [
'x' => [
'bounds' => 'data',
'grid' => ['display' => false],
@ -2296,7 +2295,7 @@ function graphic_combined_module(
}
$output = '<div style="display: flex; flex-direction:row; justify-content: center; align-items: center; align-content: center; width:100%; height:100%;">';
$output .= '<div style="flex: 0 0 auto; width:99%; height:100%;">';
$output .= '<div style="flex: 0 0 auto; width:99%; height:100%; background-color:'.$background_color.'">';
$output .= vbar_graph($graph_values, $options);
$output .= '</div>';
$output .= '</div>';
@ -2383,13 +2382,12 @@ function graphic_combined_module(
$height = null;
$options = [
'width' => $width,
'height' => $height,
'waterMark' => $water_mark,
'ttl' => $ttl,
'background' => $background_color,
'pdf' => $params['pdf'],
'legend' => [
'width' => $width,
'height' => $height,
'waterMark' => $water_mark,
'ttl' => $ttl,
'pdf' => $params['pdf'],
'legend' => [
'display' => (bool) $params['show_legend'],
'position' => 'right',
'align' => 'center',
@ -2407,7 +2405,7 @@ function graphic_combined_module(
}
$output = '<div style="display: flex; flex-direction:row; justify-content: center; align-items: center; align-content: center; width:100%; height:100%;">';
$output .= '<div style="flex: 0 0 auto; width:99%; height:100%;">';
$output .= '<div style="flex: 0 0 auto; width:99%; height:100%; background-color:'.$background_color.'">';
$output .= ring_graph($graph_values, $options);
$output .= '</div>';
$output .= '</div>';

View File

@ -2228,7 +2228,6 @@ function reporting_event_report_group(
$options_charts = [
'width' => 500,
'height' => 150,
'radius' => null,
'viewport' => [
'width' => 500,
'height' => 0,

View File

@ -658,34 +658,68 @@ function get_build_setup_charts($type, $options, $data)
$chart->options()->setResponsive($responsive);
// LEGEND.
// Set Display legends.
$legendDisplay = true;
if (isset($options['legend']['display']) === true) {
$legendDisplay = $options['legend']['display'];
}
$chart->options()->getPlugins()->getLegend()->setDisplay($legendDisplay);
// Set Position legends.
$legendPosition = 'top';
if (isset($options['legend']['position']) === true
&& empty($options['legend']['position']) === false
if (isset($options['legend']) === true
&& empty($options['legend']) === false
&& is_array($options['legend']) === true
) {
$legendPosition = $options['legend']['position'];
$legend = $chart->options()->getPlugins()->getLegend();
// Set Display legends.
$legendDisplay = true;
if (isset($options['legend']['display']) === true) {
$legendDisplay = $options['legend']['display'];
}
$legend->setDisplay($legendDisplay);
// Set Position legends.
$legendPosition = 'top';
if (isset($options['legend']['position']) === true
&& empty($options['legend']['position']) === false
) {
$legendPosition = $options['legend']['position'];
}
$legend->setPosition($legendPosition);
// Set Align legends.
$legendAlign = 'center';
if (isset($options['legend']['align']) === true
&& empty($options['legend']['align']) === false
) {
$legendAlign = $options['legend']['align'];
}
$legend->setAlign($legendAlign);
// Defaults fonts legends.
$legend->labels()->getFonts()->setFamily((empty($config['fontpath']) === true) ? 'Lato' : $config['fontpath']);
$legend->labels()->getFonts()->setStyle('normal');
$legend->labels()->getFonts()->setWeight(600);
$legend->labels()->getFonts()->setSize(((int) $config['font_size'] + 2));
if (isset($options['legend']['fonts']) === true
&& empty($options['legend']['fonts']) === false
&& is_array($options['legend']['fonts']) === true
) {
if (isset($options['legend']['fonts']['size']) === true) {
$legend->labels()->getFonts()->setSize($options['legend']['fonts']['size']);
}
if (isset($options['legend']['fonts']['style']) === true) {
$legend->labels()->getFonts()->setStyle($options['legend']['fonts']['style']);
}
if (isset($options['legend']['fonts']['weight']) === true) {
$legend->labels()->getFonts()->setWeight($options['legend']['fonts']['weight']);
}
if (isset($options['legend']['fonts']['family']) === true) {
$legend->labels()->getFonts()->setFamily($options['legend']['fonts']['family']);
}
}
}
$chart->options()->getPlugins()->getLegend()->setPosition($legendPosition);
// Set Align legends.
$legendAlign = 'center';
if (isset($options['legend']['align']) === true
&& empty($options['legend']['align']) === false
) {
$legendAlign = $options['legend']['align'];
}
$chart->options()->getPlugins()->getLegend()->setAlign($legendAlign);
if (isset($options['layout']) === true
&& empty($options['layout']) === false
&& is_array($options['layout']) === true