Skip to content

Commit

Permalink
Merge pull request #1035 from jpwhite4/chart_timezone
Browse files Browse the repository at this point in the history
Fix chart time display when the system timezone has a positive offset from UTC
  • Loading branch information
jpwhite4 authored Dec 10, 2019
2 parents 88d8a02 + 8f0ac04 commit 085fc5d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
3 changes: 3 additions & 0 deletions html/gui/js/HighChartPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ Highcharts.setOptions ({
lang: {
// commas for thousands separators
thousandsSep: '\u002c' // the humble comma
},
global: {
timezone: CCR.xdmod.timezone
}
});

Expand Down
7 changes: 3 additions & 4 deletions html/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ function ($item) {
});

print "CCR.xdmod.features = " . json_encode($features) . ";\n";
print "CCR.xdmod.timezone = " . json_encode(date_default_timezone_get()) . ";\n";
?>

</script>
Expand Down Expand Up @@ -383,10 +384,8 @@ function ($item) {
<script type="text/javascript" src="gui/js/report_builder/ReportPreview.js"></script>
<?php endif; ?>

<?php if ($userLoggedIn): ?>
<script type="text/javascript" src="gui/lib/moment/moment.min.js"></script>
<script type="text/javascript" src="gui/lib/moment-timezone/moment-timezone-with-data.min.js"></script>
<?php endif; ?>
<script type="text/javascript" src="gui/lib/moment/moment.min.js"></script>
<script type="text/javascript" src="gui/lib/moment-timezone/moment-timezone-with-data.min.js"></script>

<script type="text/javascript" src="gui/lib/highcharts/js/highcharts.src.js"></script>
<script type="text/javascript" src="gui/lib/highcharts/js/highcharts-more.js"></script>
Expand Down
7 changes: 4 additions & 3 deletions libraries/charting.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,12 @@ function exportHighchart($chartConfig, $width, $height, $scale, $format, $global

$template = str_replace('_html_dir_', $html_dir, $template);
$template = str_replace('_chartOptions_', json_encode($chartConfig), $template);

$globalChartOptions = array('timezone' => date_default_timezone_get());
if ($globalChartConfig !== null) {
$template = str_replace('_globalChartOptions_', json_encode($globalChartConfig), $template);
} else {
$template = str_replace('_globalChartOptions_', 'null', $template);
$globalChartOptions = array_merge($globalChartOptions, $globalChartConfig);
}
$template = str_replace('_globalChartOptions_', json_encode($globalChartOptions), $template);
$template = str_replace('_width_',$effectiveWidth, $template);
$template = str_replace('_height_',$effectiveHeight, $template);
file_put_contents($tmp_html_filename,$template);
Expand Down

0 comments on commit 085fc5d

Please sign in to comment.