Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate Plotly JavaScript for Job Viewer Tab #1729

Merged
merged 52 commits into from
Jul 5, 2023

Conversation

aestoltm
Copy link
Contributor

@aestoltm aestoltm commented May 19, 2023

Description

Timeseries Charts:

  • Timeseries charts are now rendered Plotly js charts instead of HighCharts

Analytic Charts:

  • Analytic charts are now rendered with Plotly js instead of Highcharts
  • Color brightness is slightly different than Highcharts.

Peer Charts (Gantt Charts):

  • No official support for gantt charts in Plotly js therefore rendered charts with Plotly shapes and added an underlying scatter plot due to shapes not supporting Plotly events and tooltips. Two other implementations I explored where using horizontal bar charts and box plot charts however the current implementation matches the highcharts version the best.

Timeseries Drilldown:

  • Adjusted plotly_click in ChartPanel.js to grab the nodeid of the trace's data point selected for drilldown redirect.
  • Adjusted how drilldown works in GanttChart.js to include the click event information in each data point and then when plotly_click fires action: 'show' is added to the click event info and is encoded for the drilldown redirect.

Export:

  • Updated selector in chrome-helper.js to the div in plotly_template.html
  • Updated layout for export chart to Plotly equivalent in chartImageResponse() in classes/Rest/Controller/WarehouseControllerProvider.php
  • Updated charting.php to grab file content from plotly_template.html
  • Created plotly_template.html. Uses layout and data given from charting.php to draw chart a div.

Known Issues/TODO

  • Fix text cutoff on error text for when there are more than four analytic charts. Plotly does not support any word wrapping, therefore, we can add a wordwrap library as this most likely will be needed for when updating other modules with Plotly js.
  • Optimize plotly_hover and plotly_unhover that mimics highcharts point hover events. Currently, not included with the PR but during testing the events crashed the webpage if hovering over charts with many overlapping traces. Note: this issue may be included in a future PR as it does not impact functionality

Motivation and Context

Currently, Highcharts requires a license to be purchased which is solved by using Plotly js an open-source library.

Tests performed

  • Added test cases in xdmod-supremm for changes made to Job Viewer
  • Performed GUI testing by visually comparing production and dev environment charts.

TODO

  • Add test cases for exporting Plotly charts
  • Add a button on Job Viewer Tab to redirect the reviewer to a random job with timeseries data.

Checklist:

  • The pull request description is suitable for a Changelog entry
  • The milestone is set correctly on the pull request
  • The appropriate labels have been added to the pull request

jpwhite4 and others added 21 commits February 2, 2023 16:37
…peers and fixes rendering of envelope plots.
…also fixed some tooltip inconsistencies with Gantt Chart and Timeseries charts compared to production.
…peers and fixes rendering of envelope plots.
…also fixed some tooltip inconsistencies with Gantt Chart and Timeseries charts compared to production.
@@ -20,7 +20,7 @@ const args = require('yargs').argv;

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

const innerHtml = await page.evaluate(() => document.querySelector('.highcharts-container').innerHTML);
const innerHtml = await page.evaluate(() => document.querySelector('.plotly').innerHTML);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't change this - it will break image export for the rest of XDMoD.

),

'text' => $settings['show_title'] ? $data['schema']['description'] : null
)
);

if (strpos($data['schema']['units'], '%') !== false) {
/*if (strpos($data['schema']['units'], '%') !== false) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't add commented code - I'm sure the linter has already complained about this!

"y": 1.2
}
]
console.log("new annontation");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't add console.log() statements (by all means use them when debugging - but not in the final code that gets reviewed).

}, // resize

destroy: function () {
/*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the new object lifecycle? Before we explicitly called destroy on highcharts charts to free up memory when the tab was closed. How does it work now in your code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plotly.purge(graphDiv) is supposed to be called here. I will add that to destroy.

@eiffel777 eiffel777 dismissed their stale review June 23, 2023 13:46

My comments were addressed

Copy link
Contributor

@ryanrath ryanrath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple of questions

html/gui/js/libraries/PlotlyUtilities.js Outdated Show resolved Hide resolved
html/gui/js/libraries/PlotlyUtilities.js Outdated Show resolved Hide resolved
html/gui/js/libraries/PlotlyUtilities.js Show resolved Hide resolved
html/gui/js/libraries/PlotlyUtilities.js Show resolved Hide resolved
html/gui/js/modules/job_viewer/AnalyticChartPanel.js Outdated Show resolved Hide resolved
break;
}
}

$axisTitleFontSize = ($settings['font_size'] + 12) . 'px';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come this code was left in but the rest of the setting transformation code was moved? Is there something different about the axis font sizes?

this.chart = new Highcharts.Chart(this.chartOptions);

render: function () {
this.chart = Plotly.newPlot(this.id, [], this._DEFAULT_CONFIG.layout, this._DEFAULT_CONFIG.config);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it cause problems passing the same configuration objects to multiple plotly instances? I naively would have done a deep copy on the DEFAULT_CONFIG objects and then passed the copy into the plotly instance.

showarrow: false
}
];
this._DEFAULT_CONFIG.layout.annotations = errorText;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it is a good idea to be editing the DEFAULT_CONFIG object. it can hardly be a portal-wide default if it changes accordiong to the state of an individual chart

var trace = {};
if (data.error === '') {
var chartColor = this._getDataColor(data.value);
this._DEFAULT_CONFIG.layout.plot_bgcolor = chartColor.bg_color;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above - not a good idea to edit the default that is shared among all charts.

@aestoltm aestoltm marked this pull request as ready for review July 5, 2023 19:55
Copy link
Contributor

@ryanrath ryanrath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I"m good to merge once Joe has a look.

) {
$effectiveWidth = (int)($width*$scale);
$effectiveHeight = (int)($height*$scale);

$html_dir = __DIR__ . "/../html";
$template = file_get_contents($html_dir . "/highchart_template.html");
if ($isPlotly){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very minor point: if the chart is plotly then the code will open the file called highchart_template.html then allocate memory, then copy the contents of the file into memory, then delete the memory. Needless to say there is no point using cpu cycles to read the highchart_template file when in plotly mode.

Don't need to change this for this pull request. But should address this in the next set of code changes.

@aestoltm aestoltm merged commit ab1f25f into ubccr:xdmod10.5 Jul 5, 2023
@aestoltm aestoltm deleted the job_viewer_plotly branch May 16, 2024 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants