You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by Quasar <qu...@libero.it> on 2006/05/18 15:10:02 UTC
More improvements in AxisGraph.java
Hi everybody :)
I've added some small changes to AxisGraph.java. Here's the list of changes:
- If the titles of x axis are too long, the graph got messed.
- If no Title is provided in, the chart will get a defaulted one.
Attached is the patche file.
Hope it helps :)
Ciao :)
Giuseppe Calignano.
Re: More improvements in AxisGraph.java
Posted by sebb <se...@gmail.com>.
Thanks, but please can you attach the code to the Bugzilla issue?
On 24/05/06, Quasar <qu...@libero.it> wrote:
> sebb wrote:
> > Thanks!
> >
> > However, I'm not sure that it is a good idea to force the labels to 20
> > characters maximum, given that one can change the height of the graph
> > to whatever one likes. But I suppose one could add a new field to
> > specify the maximum label size.
>
> Good point.
>
> I've added a new field in the gui that controls the maximum # of
> characters in the graph.
>
> Pls find attached the AxisGraph, StatGraphVisualizer and
> message.properties patch files.
>
> Thx,
>
> Giuseppe
>
>
>
>
> Index: /workspace/rel-2-1/src/components/org/apache/jmeter/visualizers/StatGraphVisualizer.java
> ===================================================================
> --- /workspace/rel-2-1/src/components/org/apache/jmeter/visualizers/StatGraphVisualizer.java (revision 408847)
> +++ /workspace/rel-2-1/src/components/org/apache/jmeter/visualizers/StatGraphVisualizer.java (working copy)
> @@ -120,6 +120,10 @@
>
> JLabeledTextField graphTitle =
> new JLabeledTextField(JMeterUtils.getResString("aggregate_graph_user_title"));
> +
> + JLabeledTextField maxLengthXAxisLabel =
> + new JLabeledTextField(JMeterUtils.getResString("aggregate_graph_max_length_xaxis_label"));
> +
> JLabeledTextField graphWidth =
> new JLabeledTextField(JMeterUtils.getResString("aggregate_graph_width"));
> JLabeledTextField graphHeight =
> @@ -222,6 +226,7 @@
>
> graph.add(graphLabel);
> graph.add(graphTitle);
> + graph.add(maxLengthXAxisLabel);
> graph.add(graphWidth);
> graph.add(graphHeight);
> graph.add(buttonpanel);
> @@ -246,19 +251,25 @@
> public void makeGraph() {
> String wstr = graphWidth.getText();
> String hstr = graphHeight.getText();
> + String lstr = maxLengthXAxisLabel.getText();
> if (wstr.length() == 0) {
> wstr = "450";
> }
> if (hstr.length() == 0) {
> hstr = "250";
> }
> + if (lstr.length() == 0) {
> + lstr = "20";
> + }
> int width = Integer.parseInt(wstr);
> int height = Integer.parseInt(hstr);
> + int maxLength = Integer.parseInt(lstr);
>
> graphPanel.setData(this.getData());
> graphPanel.setHeight(height);
> graphPanel.setWidth(width);
> graphPanel.setTitle(graphTitle.getText());
> + graphPanel.setMaxLenght(maxLength);
> graphPanel.setXAxisLabels(getAxisLabels());
> graphPanel.setXAxisTitle(columns.getText());
> graphPanel.setYAxisLabels(this.yAxisLabel);
>
>
> Index: /workspace/rel-2-1/src/components/org/apache/jmeter/visualizers/AxisGraph.java
> ===================================================================
> --- /workspace/rel-2-1/src/components/org/apache/jmeter/visualizers/AxisGraph.java (revision 408847)
> +++ /workspace/rel-2-1/src/components/org/apache/jmeter/visualizers/AxisGraph.java (working copy)
> @@ -53,6 +53,7 @@
>
> protected double[][] data = null;
> protected String title, xAxisTitle, yAxisTitle, yAxisLabel;
> + protected int maxLenght;
> protected String[] xAxisLabels;
> protected int width, height;
>
> @@ -85,6 +86,10 @@
> public void setTitle(String title) {
> this.title = title;
> }
> +
> + public void setMaxLenght(int maxLength) {
> + this.maxLenght = maxLength;
> + }
>
> public void setXAxisTitle(String title) {
> this.xAxisTitle = title;
> @@ -114,7 +119,7 @@
> if (data != null && this.title != null && this.xAxisLabels != null &&
> this.xAxisTitle != null && this.yAxisLabel != null &&
> this.yAxisTitle != null) {
> - drawSample(this.title,this.xAxisLabels,this.xAxisTitle,
> + drawSample(this.title,this.maxLenght,this.xAxisLabels,this.xAxisTitle,
> this.yAxisTitle,this.data,this.width,this.height,g);
> }
> }
> @@ -132,16 +137,39 @@
> return max;
> }
>
> - private void drawSample(String _title, String[] _xAxisLabels, String _xAxisTitle,
> + private String squeeze (String input, int maxLength){
> + if (input.length()>maxLength){
> + String output="";
> + output = input.substring(0,maxLength-3)+"...";
> + return output;
> + }
> + else return input;
> + }
> +
> + private void drawSample(String _title, int _maxLength, String[] _xAxisLabels, String _xAxisTitle,
> String _yAxisTitle, double[][] _data, int _width, int _height, Graphics g) {
> double max = findMax(_data);
> try {
> + /** These controls are already done in StatGraphVisualizer
> if (_width == 0) {
> _width = 450;
> }
> if (_height == 0) {
> _height = 250;
> }
> + **/
> + if (_maxLength < 3) {
> + _maxLength = 3;
> + }
> + // if the "Title of Graph" is empty, we can assume some default
> + if (_title.equals("") ) {
> + _title = "Graph";
> + }
> + // if the labels are too long, they'll be "squeezed" to make the chart viewable.
> + for (int i = 0; i < _xAxisLabels.length; i++) {
> + String label = _xAxisLabels[i];
> + _xAxisLabels[i]=squeeze(label, _maxLength);
> + }
> this.setPreferredSize(new Dimension(_width,_height));
> DataSeries dataSeries = new DataSeries( _xAxisLabels, _xAxisTitle, _yAxisTitle, _title );
>
>
>
> Index: /workspace/rel-2-1/src/core/org/apache/jmeter/resources/messages.properties
> ===================================================================
> --- /workspace/rel-2-1/src/core/org/apache/jmeter/resources/messages.properties (revision 408847)
> +++ /workspace/rel-2-1/src/core/org/apache/jmeter/resources/messages.properties (working copy)
> @@ -21,6 +21,7 @@
> aggregate_graph_save_table=Save Table Data
> aggregate_graph_title=Aggregate Graph
> aggregate_graph_user_title=Title for Graph
> +aggregate_graph_max_length_xaxis_label=Max length of x-axis label
> aggregate_graph_width=Width
> aggregate_report=Aggregate Report
> aggregate_report_90%_line=90% Line
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org
Re: More improvements in AxisGraph.java
Posted by Quasar <qu...@libero.it>.
sebb wrote:
> Thanks!
>
> However, I'm not sure that it is a good idea to force the labels to 20
> characters maximum, given that one can change the height of the graph
> to whatever one likes. But I suppose one could add a new field to
> specify the maximum label size.
Good point.
I've added a new field in the gui that controls the maximum # of
characters in the graph.
Pls find attached the AxisGraph, StatGraphVisualizer and
message.properties patch files.
Thx,
Giuseppe
Re: More improvements in AxisGraph.java
Posted by sebb <se...@gmail.com>.
Thanks!
However, I'm not sure that it is a good idea to force the labels to 20
characters maximum, given that one can change the height of the graph
to whatever one likes. But I suppose one could add a new field to
specify the maximum label size.
S.
On 18/05/06, Quasar <qu...@libero.it> wrote:
> Hi everybody :)
>
> I've added some small changes to AxisGraph.java. Here's the list of changes:
> - If the titles of x axis are too long, the graph got messed.
> - If no Title is provided in, the chart will get a defaulted one.
>
> Attached is the patche file.
>
> Hope it helps :)
>
> Ciao :)
>
> Giuseppe Calignano.
>
>
> Index: C:/Program Files/FinantixStudio/workspace/rel-2-1/src/components/org/apache/jmeter/visualizers/AxisGraph.java
> ===================================================================
> --- C:/Program Files/FinantixStudio/workspace/rel-2-1/src/components/org/apache/jmeter/visualizers/AxisGraph.java (revision 407467)
> +++ C:/Program Files/FinantixStudio/workspace/rel-2-1/src/components/org/apache/jmeter/visualizers/AxisGraph.java (working copy)
> @@ -132,6 +132,15 @@
> return max;
> }
>
> + private String squeeze (String input, int maxLength){
> + if (input.length()>maxLength){
> + String output="";
> + output = input.substring(0,maxLength-3)+"...";
> + return output;
> + }
> + else return input;
> + }
> +
> private void drawSample(String _title, String[] _xAxisLabels, String _xAxisTitle,
> String _yAxisTitle, double[][] _data, int _width, int _height, Graphics g) {
> double max = findMax(_data);
> @@ -142,6 +151,15 @@
> if (_height == 0) {
> _height = 250;
> }
> + // if the "Title of Graph" is empty, we can assume some default
> + if (_title.equals("") ) {
> + _title = "Graph";
> + }
> + // if the labels are too long, they'll be "squeezed" to make the chart viewable.
> + for (int i = 0; i < _xAxisLabels.length; i++) {
> + String label = _xAxisLabels[i];
> + _xAxisLabels[i]=squeeze(label,20);
> + }
> this.setPreferredSize(new Dimension(_width,_height));
> DataSeries dataSeries = new DataSeries( _xAxisLabels, _xAxisTitle, _yAxisTitle, _title );
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org