in src/components/src/main/java/org/apache/jmeter/visualizers/RespTimeGraphChart.java [280:370]
private void drawSample(String _title, String[] _xAxisLabels,
String _yAxisTitle, String[] _legendLabels,
double[][] _data, int _width, int _height, int _incrScaleYAxis,
Color[] _color, Font legendFont, Graphics g) {
double max = maxYAxisScale > 0 ? maxYAxisScale : getTopValue(findMax(_data), RoundingMode.UP); // define max scale y axis
try {
// if the title graph is empty, we can assume some default
if (_title.length() == 0 ) {
_title = JMeterUtils.getResString("graph_resp_time_title"); //$NON-NLS-1$
}
this.setPreferredSize(new Dimension(_width,_height));
DataSeries dataSeries = new DataSeries( _xAxisLabels, null, _yAxisTitle, _title ); // replace _xAxisTitle to null (don't display x axis title)
// Stroke and shape line settings
Stroke[] strokes = new Stroke[_legendLabels.length];
for (int i = 0; i < _legendLabels.length; i++) {
strokes[i] = new BasicStroke(strokeWidth, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 5f);
}
Shape[] shapes = new Shape[_legendLabels.length];
for (int i = 0; i < _legendLabels.length; i++) {
shapes[i] = pointShape;
}
LineChartProperties lineChartProperties= new LineChartProperties(strokes, shapes);
// Lines colors
Paint[] paints = new Paint[_color.length];
System.arraycopy(_color, 0, paints, 0, _color.length);
// Define chart type (line)
AxisChartDataSet axisChartDataSet =
new AxisChartDataSet( _data, _legendLabels, paints, ChartType.LINE, lineChartProperties );
dataSeries.addIAxisPlotDataSet(axisChartDataSet);
ChartProperties chartProperties= new ChartProperties();
LabelAxisProperties xaxis = new LabelAxisProperties();
DataAxisProperties yaxis = new DataAxisProperties();
yaxis.setUseCommas(showGrouping);
if (legendFont != null) {
yaxis.setAxisTitleChartFont(new ChartFont(legendFont, new Color(20)));
yaxis.setScaleChartFont(new ChartFont(legendFont, new Color(20)));
xaxis.setAxisTitleChartFont(new ChartFont(legendFont, new Color(20)));
xaxis.setScaleChartFont(new ChartFont(legendFont, new Color(20)));
}
if (titleFont != null) {
chartProperties.setTitleFont(new ChartFont(titleFont, new Color(0)));
}
// Y Axis ruler
try {
double numInterval = _height / 50d; // ~a tic every 50 px
double incrYAxis = max / numInterval;
double incrTopValue = _incrScaleYAxis;
if (_incrScaleYAxis == 0) {
incrTopValue = getTopValue(incrYAxis, RoundingMode.HALF_UP);
}
if (incrTopValue < 1) {
incrTopValue = 1.0d; // Increment cannot be < 1
}
yaxis.setUserDefinedScale(0, incrTopValue);
yaxis.setNumItems((int)(max / incrTopValue) + 1);
yaxis.setShowGridLines(1);
} catch (PropertyException e) {
log.warn("Exception while setting Y axis properties.", e);
}
AxisProperties axisProperties= new AxisProperties(xaxis, yaxis);
axisProperties.setXAxisLabelsAreVertical(true);
LegendProperties legendProperties= new LegendProperties();
legendProperties.setBorderStroke(null);
legendProperties.setPlacement(legendPlacement);
legendProperties.setIconBorderPaint(Color.WHITE);
legendProperties.setIconBorderStroke(new BasicStroke(0f, BasicStroke.CAP_SQUARE, BasicStroke.CAP_SQUARE));
// Manage legend placement
legendProperties.setNumColumns(LegendAreaProperties.COLUMNS_FIT_TO_IMAGE);
if (legendPlacement == LegendAreaProperties.RIGHT || legendPlacement == LegendAreaProperties.LEFT) {
legendProperties.setNumColumns(1);
}
if (legendFont != null) {
legendProperties.setFont(legendFont);
}
AxisChart axisChart = new AxisChart(
dataSeries, chartProperties, axisProperties,
legendProperties, _width, _height );
axisChart.setGraphics2D((Graphics2D) g);
axisChart.render();
} catch (ChartDataException | PropertyException e) {
log.warn("Exception while rendering axis chart.", e);
}
}