Esempio n. 1
0
    def _createChart(self):
        # create the plot
        rtimeDataset = self.dataSets[0]
        rtimeRenderer = StackedXYAreaRenderer2()
        rtimeRangeAxis = NumberAxis(self.getYAxisLabel())
        rtimeRangeAxis.setAutoRangeIncludesZero(False)
        rtimeDomainAxis = NumberAxis(self.getXAxisLabel())
        #rtimePlot = XYPlot(rtimeDataset, None, rtimeRangeAxis, rtimeRenderer)
        rtimePlot = XYPlot(rtimeDataset, rtimeDomainAxis, rtimeRangeAxis, rtimeRenderer)
        rtimePlot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT)

        # response time
        rtimeRenderer.setSeriesPaint(0, COLOR_RTIME_RESOLVE)
        rtimeRenderer.setSeriesPaint(1, COLOR_RTIME_CONNECT)
        rtimeRenderer.setSeriesPaint(2, COLOR_RTIME_FIRSTBYTE)
        rtimeRenderer.setSeriesPaint(3, COLOR_RTIME_FINAL)

        #rtimeRenderer.setBaseShapesVisible(False)
        #rtimePlot.setRenderer(0, rtimeRenderer)
        rtimePlot.setRenderer(rtimeRenderer)

        # create a new chart containing the plot...
        self.chart = JFreeChart(self.getTitle(),
                                JFreeChart.DEFAULT_TITLE_FONT,
                                rtimePlot,
                                True)
Esempio n. 2
0
    def _createChart(self):

        # create subplot 1...
        tpsDataset = self.dataSets[0]
        passPerSecRenderer = StandardXYItemRenderer()
        tpsRangeAxis = NumberAxis("Transactions per second")
        tpsSubplot = XYPlot(tpsDataset, None, tpsRangeAxis, passPerSecRenderer);
        tpsSubplot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT)
        
        # create subplot 2...
        rtimeDataset = self.dataSets[1]
        rtimeRenderer = StandardXYItemRenderer()
        rtimeRangeAxis = NumberAxis("Seconds")
        rtimeRangeAxis.setAutoRangeIncludesZero(False)
        rtimeSubplot = XYPlot(rtimeDataset, None, rtimeRangeAxis, rtimeRenderer)
        rtimeSubplot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT)

        # parent plot...
        plot = CombinedDomainXYPlot(NumberAxis(self.getXAxisLabel()))
        plot.setGap(10.0)

        # passed per sec
        # RGB for dark green
        passPerSecRenderer.setSeriesPaint(0, COLOR_TXSEC_PASS)
        passPerSecRenderer.setSeriesPaint(1, COLOR_TXSEC_FAIL)
        passPerSecRenderer.setBaseShapesVisible(False)

        # response time
        rtimeRenderer.setSeriesPaint(0, COLOR_RTIME)
        rtimeRenderer.setBaseShapesVisible(False)
        # failed per sec
        failPerSecRenderer = StandardXYItemRenderer()
        failPerSecRenderer.setSeriesPaint(0, javaColor.red)
        failPerSecRenderer.setBaseShapesVisible(False)
        tpsSubplot.setRenderer(0, passPerSecRenderer)
        tpsSubplot.setRenderer(1, failPerSecRenderer)
        rtimeSubplot.setRenderer(0, rtimeRenderer)

        # add the subplots.  TPS plot gets more weight,
        # making it proportionally larger.
        plot.add(tpsSubplot, CONFIG.tpsWeight)
        plot.add(rtimeSubplot, CONFIG.responseTimeWeight)
        plot.setOrientation(PlotOrientation.VERTICAL)

        # create a new chart containing the overlaid plot...
        self.chart = JFreeChart(self.getTitle(), JFreeChart.DEFAULT_TITLE_FONT, plot, True)
Esempio n. 3
0
def regression(data, regtype=0):
  xAxis = NumberAxis("x")   
  xAxis.setAutoRangeIncludesZero(False)   
  yAxis = NumberAxis("y")   
  yAxis.setAutoRangeIncludesZero(False)   
   
  series = XYSeries("values"); 
  xmax = xmin = None       
  for (x,y) in data:
    series.add(x, y);
    if xmax is None:
      xmax = xmin = x
    else:
      xmax = max(xmax, x)
      xmin = min(xmin, x)
            
  dataset = XYSeriesCollection()
  dataset.addSeries(series);

  renderer1 = XYDotRenderer()
  plot = XYPlot(dataset, xAxis, yAxis, renderer1)   
      
  if regtype == 1:
    coefficients = Regression.getPowerRegression(dataset, 0)
    curve = PowerFunction2D(coefficients[0], coefficients[1])
    regdesc = "Power Regression"    
  else:
    coefficients = Regression.getOLSRegression(dataset, 0)   
    curve = LineFunction2D(coefficients[0], coefficients[1])
    regdesc = "Linear Regression"   
    
  regressionData = DatasetUtilities.sampleFunction2D(curve, xmin, xmax, 100, 
    "Fitted Regression Line")   
           
  plot.setDataset(1, regressionData)   
  renderer2 = XYLineAndShapeRenderer(True, False)   
  renderer2.setSeriesPaint(0, Color.blue)   
  plot.setRenderer(1, renderer2)
           
  jfchart = JFreeChart(regdesc, JFreeChart.DEFAULT_TITLE_FONT, plot, True);
    
  chart = Chart(jfchart)          
  chart.coeffs = coefficients
    
  return chart
Esempio n. 4
0
def regression(data, regtype=0):
    xAxis = NumberAxis("x")
    xAxis.setAutoRangeIncludesZero(False)
    yAxis = NumberAxis("y")
    yAxis.setAutoRangeIncludesZero(False)

    series = XYSeries("values")
    xmax = xmin = None
    for (x, y) in data:
        series.add(x, y)
        if xmax is None:
            xmax = xmin = x
        else:
            xmax = max(xmax, x)
            xmin = min(xmin, x)

    dataset = XYSeriesCollection()
    dataset.addSeries(series)

    renderer1 = XYDotRenderer()
    plot = XYPlot(dataset, xAxis, yAxis, renderer1)

    if regtype == 1:
        coefficients = Regression.getPowerRegression(dataset, 0)
        curve = PowerFunction2D(coefficients[0], coefficients[1])
        regdesc = "Power Regression"
    else:
        coefficients = Regression.getOLSRegression(dataset, 0)
        curve = LineFunction2D(coefficients[0], coefficients[1])
        regdesc = "Linear Regression"

    regressionData = DatasetUtilities.sampleFunction2D(
        curve, xmin, xmax, 100, "Fitted Regression Line")

    plot.setDataset(1, regressionData)
    renderer2 = XYLineAndShapeRenderer(True, False)
    renderer2.setSeriesPaint(0, Color.blue)
    plot.setRenderer(1, renderer2)

    jfchart = JFreeChart(regdesc, JFreeChart.DEFAULT_TITLE_FONT, plot, True)

    chart = Chart(jfchart)
    chart.coeffs = coefficients

    return chart
Esempio n. 5
0
def plot(geoms, size=(500,500)):
  """
  Plots a set of geometry objects into a xy grid.

  *geom* is a `list` of geometry objects to plot. *size* is the resulting
  size of the rendered plot.
  """

  if not isinstance(geoms, list):
    geoms = [geoms]

  data = GeometryDataset(geoms)
  r = GeometryRenderer()
  #r.setFillPolygons(True)

  plot = XYPlot(data, data.getDomain(), data.getRange(), r);
  chart = JFreeChart(plot)
  panel = ChartPanel(chart)
  
  frame = swing.JFrame()
  frame.setContentPane(panel)
  frame.size = size
  frame.visible = True