Skip to content

Commit ab1f25f

Browse files
authored
Merge pull request #1729 from aestoltm/job_viewer_plotly
Integrate Plotly JavaScript for Job Viewer Tab
2 parents f40b817 + 2e6b0ed commit ab1f25f

File tree

16 files changed

+657
-614
lines changed

16 files changed

+657
-614
lines changed

background_scripts/chrome-helper/chrome-helper.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,23 @@ const args = require('yargs').argv;
2020

2121
await page.goto('file://' + args['input-file']);
2222

23-
const innerHtml = await page.evaluate(() => document.querySelector('.highcharts-container').innerHTML);
23+
let svgInnerHtml;
2424

25-
console.log(JSON.stringify(innerHtml));
25+
if (args.plotly) {
26+
// Chart traces and axis values svg
27+
let plotlyChart = await page.evaluate(() => document.querySelector('.user-select-none.svg-container').children[0].outerHTML);
28+
// Chart title and axis titles svg
29+
const plotlyLabels = await page.evaluate(() => document.querySelector('.user-select-none.svg-container').children[2].innerHTML);
30+
31+
plotlyChart = plotlyChart.substring(0, plotlyChart.length - 6);
32+
const plotlyImage = plotlyChart + '' + plotlyLabels + '</svg>';
33+
// HTML tags in titles thorw xml not well-formed error
34+
svgInnerHtml = plotlyImage.replace(/<br>|<b>|<\/b>/gm, '');
35+
} else {
36+
svgInnerHtml = await page.evaluate(() => document.querySelector('.highcharts-container').innerHTML);
37+
}
38+
39+
console.log(JSON.stringify(svgInnerHtml));
2640

2741
await browser.close();
2842
})();

classes/Rest/Controllers/WarehouseControllerProvider.php

Lines changed: 6 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1964,106 +1964,25 @@ private function chartDataResponse($data)
19641964
*/
19651965
private function chartImageResponse($data, $type, $settings)
19661966
{
1967-
// Enable plot marker only if a single point is present in the data series' plot data.
1968-
// Otherwise plot the data with a line.
1969-
1970-
$markerEnabled = false;
1971-
1972-
// check the series array passed in from the overall data array:
1973-
foreach ($data['series'] as $series) {
1974-
// if the series array contains any data array with exactly one element, enable markers
1975-
// (a dot for each series' element) so that the plotted data can be seen:
1976-
if (isset($series['data']) && count($series['data']) == 1) {
1977-
$markerEnabled = true;
1978-
break;
1979-
}
1980-
}
1981-
19821967
$axisTitleFontSize = ($settings['font_size'] + 12) . 'px';
19831968
$axisLabelFontSize = ($settings['font_size'] + 11) . 'px';
19841969
$mainTitleFontSize = ($settings['font_size'] + 16) . 'px';
19851970

19861971
$lineWidth = 1 + $settings['scale'];
19871972

19881973
$chartConfig = array(
1989-
'colors' => array( '#2f7ed8', '#0d233a', '#8bbc21', '#910000', '#1aadce', '#492970',
1990-
'#f28f43', '#77a1e5', '#c42525', '#a6c96a'
1991-
),
1992-
'series' => $data['series'],
1993-
'xAxis' => array(
1994-
'type' => 'datetime',
1995-
'minTickInterval' => 1000,
1996-
'labels' => array(
1997-
'style' => array(
1998-
'fontWeight'=> 'normal',
1999-
'fontSize' => $axisLabelFontSize
2000-
),
2001-
),
2002-
'lineWidth' => $lineWidth,
2003-
'title' => array(
2004-
'style' => array(
2005-
'fontWeight' => 'bold',
2006-
'fontSize' => $axisTitleFontSize,
2007-
'color' => '#5078a0'
2008-
),
2009-
'text' => 'Time (' . $data['schema']['timezone'] . ')'
2010-
)
2011-
),
2012-
'yAxis' => array(
2013-
'title' => array(
2014-
'style' => array(
2015-
'fontWeight' => 'bold',
2016-
'fontSize' => $axisTitleFontSize,
2017-
'color' => '#5078a0'
2018-
),
2019-
'text' => $data['schema']['units']
2020-
),
2021-
'lineWidth' => $lineWidth,
2022-
'labels' => array(
2023-
'style' => array(
2024-
'fontWeight'=> 'normal',
2025-
'fontSize' => $axisLabelFontSize
2026-
),
2027-
),
2028-
'min' => 0.0
2029-
),
2030-
'legend' => array(
2031-
'enabled' => false
2032-
),
2033-
'plotOptions' => array(
2034-
'line' => array(
2035-
'lineWidth' => $lineWidth,
2036-
'marker' => array(
2037-
'enabled' => $markerEnabled
2038-
)
2039-
)
2040-
),
2041-
'credits' => array(
2042-
'text' => $data['schema']['source'] . '. Powered by XDMoD/Highcharts',
2043-
'href' => ''
2044-
),
2045-
'exporting' => array(
2046-
'enabled' => false
2047-
),
2048-
'title' => array(
2049-
'style' => array(
2050-
'color' => '#444b6e',
2051-
'fontSize' => $mainTitleFontSize
2052-
),
2053-
2054-
'text' => $settings['show_title'] ? $data['schema']['description'] : null
2055-
)
1974+
'data' => $data,
1975+
'axisTickSize' => $axisLabelFontSize,
1976+
'axisTitleSize' => $axisTitleFontSize,
1977+
'lineWidth' => $lineWidth,
1978+
'chartTitleSize' => $mainTitleFontSize
20561979
);
20571980

2058-
if (strpos($data['schema']['units'], '%') !== false) {
2059-
$chartConfig['yAxis']['max'] = 100.0;
2060-
}
2061-
20621981
$globalConfig = array(
20631982
'timezone' => $data['schema']['timezone']
20641983
);
20651984

2066-
$chartImage = \xd_charting\exportHighchart($chartConfig, $settings['width'], $settings['height'], $settings['scale'], $type, $globalConfig, $settings['fileMetadata']);
1985+
$chartImage = \xd_charting\exportHighchart($chartConfig, $settings['width'], $settings['height'], $settings['scale'], $type, $globalConfig, $settings['fileMetadata'], true);
20671986
$chartFilename = $settings['fileMetadata']['title'] . '.' . $type;
20681987
$mimeOverride = $type == 'svg' ? 'image/svg+xml' : null;
20691988

composer-el7.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"ubccr/simplesamlphp-module-authoidcoauth2": "^1.1",
2525
"phpoffice/phpword": "^0.17.0",
2626
"monolog/monolog": "^1.25",
27-
"plotly/plotly": "^1.57.1",
27+
"plotly/plotly": "^2.24.2",
2828
"kassner/log-parser": "~1.5",
2929
"geoip2/geoip2": "~2.0",
3030
"ua-parser/uap-php": "^3.9"
@@ -211,13 +211,13 @@
211211
"package": {
212212
"name": "plotly/plotly",
213213
"type": "vanilla-plugin",
214-
"version": "1.57.1",
214+
"version": "2.24.2",
215215
"license": "MIT",
216216
"homepage": "https://github.com/plotly/plotly.js",
217217
"dist": {
218-
"url": "https://cdn.plot.ly/plotly-1.57.1.min.js",
218+
"url": "https://cdn.plot.ly/plotly-2.24.2.min.js",
219219
"type": "file",
220-
"shasum": "ccf99902ea104599c3b5b4811e83b8ee8118aad3"
220+
"shasum": "18d8802e7767617cfc23b6008a56581a567c1015"
221221
},
222222
"require": {
223223
"composer/installers": "~1.0"

composer-el7.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1587,11 +1587,11 @@
15871587
},
15881588
{
15891589
"name": "plotly/plotly",
1590-
"version": "1.57.1",
1590+
"version": "2.24.2",
15911591
"dist": {
15921592
"type": "file",
1593-
"url": "https://cdn.plot.ly/plotly-1.57.1.min.js",
1594-
"shasum": "ccf99902ea104599c3b5b4811e83b8ee8118aad3"
1593+
"url": "https://cdn.plot.ly/plotly-2.24.2.min.js",
1594+
"shasum": "18d8802e7767617cfc23b6008a56581a567c1015"
15951595
},
15961596
"require": {
15971597
"composer/installers": "~1.0"

composer-el8.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"ubccr/simplesamlphp-module-authoidcoauth2": "^1.1",
2626
"phpoffice/phpword": "^0.17.0",
2727
"monolog/monolog": "^1.25",
28-
"plotly/plotly": "^1.57.1",
28+
"plotly/plotly": "^2.24.2",
2929
"kassner/log-parser": "~1.5",
3030
"geoip2/geoip2": "~2.0",
3131
"ua-parser/uap-php": "^3.9",
@@ -213,13 +213,13 @@
213213
"package": {
214214
"name": "plotly/plotly",
215215
"type": "vanilla-plugin",
216-
"version": "1.57.1",
216+
"version": "2.24.2",
217217
"license": "MIT",
218218
"homepage": "https://github.com/plotly/plotly.js",
219219
"dist": {
220-
"url": "https://cdn.plot.ly/plotly-1.57.1.min.js",
220+
"url": "https://cdn.plot.ly/plotly-2.24.2.min.js",
221221
"type": "file",
222-
"shasum": "ccf99902ea104599c3b5b4811e83b8ee8118aad3"
222+
"shasum": "18d8802e7767617cfc23b6008a56581a567c1015"
223223
},
224224
"require": {
225225
"composer/installers": "~1.0"

composer-el8.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1737,11 +1737,11 @@
17371737
},
17381738
{
17391739
"name": "plotly/plotly",
1740-
"version": "1.57.1",
1740+
"version": "2.24.2",
17411741
"dist": {
17421742
"type": "file",
1743-
"url": "https://cdn.plot.ly/plotly-1.57.1.min.js",
1744-
"shasum": "ccf99902ea104599c3b5b4811e83b8ee8118aad3"
1743+
"url": "https://cdn.plot.ly/plotly-2.24.2.min.js",
1744+
"shasum": "18d8802e7767617cfc23b6008a56581a567c1015"
17451745
},
17461746
"require": {
17471747
"composer/installers": "~1.0"

html/.eslintrc.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
"Dashboard": false,
1818
"DashboardStore": false,
1919
"grecaptcha": false,
20-
"StringUtilities": false
20+
"StringUtilities": false,
21+
"Plotly": false,
22+
"generateChartOptions": false
2123
}
2224
}

0 commit comments

Comments
 (0)