Skip to content

Enhance plot plugin with configurable chart options and sequential image loading#196

Open
wwwgmc wants to merge 4 commits intojenkinsci:masterfrom
wwwgmc:dev-alan-plot
Open

Enhance plot plugin with configurable chart options and sequential image loading#196
wwwgmc wants to merge 4 commits intojenkinsci:masterfrom
wwwgmc:dev-alan-plot

Conversation

@wwwgmc
Copy link
Copy Markdown

@wwwgmc wwwgmc commented Mar 2, 2026

Enhance plot plugin with configurable chart options and sequential image loading

Summary

This PR introduces four new user-configurable parameters to the Plot plugin and fixes a reliability issue where plot images fail to load when many charts are rendered on the same page.

New Configuration Parameters

Parameter Type Default Description
chartWidth String (text) 750 (when empty) Custom chart width in pixels
chartHeight String (text) 450 (when empty) Custom chart height in pixels
skipZeroValues Boolean (checkbox) false Skip data points with zero or NaN Y values during data collection
useDecimalFormat Boolean (checkbox) false Display Y-axis labels in decimal format (up to 2 decimal places) instead of scientific notation

Sequential Image Loading

When a plot report page contains many charts, the browser previously fired all image requests in parallel. Since each plot image is dynamically generated on the server side (CPU-intensive), this often caused timeouts and broken images.

This PR replaces the static <img> tags with placeholder <div> elements and introduces a JavaScript sequential loader that:

  • Loads one plot image at a time, waiting for onload/onerror before requesting the next
  • Shows a "Loading plot..." placeholder while each image is pending
  • Provides a click-to-retry mechanism for any image that fails to load
  • Does not block subsequent images when one fails

Files Changed (13 files)

Java backend (4 files):

  • Plot.java — Added 4 new configuration fields, getters, getEffectiveWidth()/getEffectiveHeight() helper methods; setWidth()/setHeight() now use configured values as defaults; addBuild() conditionally skips zero/NaN data points; generatePlot() conditionally applies DecimalFormat to Y-axis
  • PlotBuilder.java — Added 4 new fields with @DataBoundSetter annotations for Pipeline support; updated perform() to pass new parameters to Plot constructor
  • PlotReport.java — Added getPlotWidth()/getPlotHeight() methods for dynamic chart dimensions in Jelly templates
  • MatrixPlotPublisher.java — Updated Plot constructor call to include new parameters

Configuration UI (2 files):

  • PlotBuilder/config.jelly — Added form fields for the 4 new parameters (Pipeline job configuration)
  • AbstractPlotPublisher/config.jelly — Added form fields for the 4 new parameters (Freestyle job configuration)

Front-end rendering (1 file):

  • PlotReport/index.jelly — Replaced static <img> with placeholder <div> + JavaScript sequential loader; chart dimensions are now dynamic via PlotReport.getPlotWidth()/getPlotHeight()

Help files (4 new files):

  • help-chartWidth.html, help-chartHeight.html, help-skipZeroValues.html, help-useDecimalFormat.html

Other (2 files):

  • pom.xml — Appended build date suffix to SNAPSHOT version
  • PlotTest.java — Updated test constructor calls to match new parameter list

Backward Compatibility

  • All 4 new parameters are optional with sensible defaults — existing Pipeline scripts and job configurations continue to work without modification
  • Default chart dimensions remain 750×450 (the original values)
  • skipZeroValues and useDecimalFormat default to false, preserving original behavior

Pipeline Usage Example

plot group: 'Code Coverage', style: 'line',
     chartWidth: '1200', chartHeight: '600',
     skipZeroValues: true,
     useDecimalFormat: true,
     csvSeries: [[file: 'coverage.csv']]

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants