Exemple #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)
Exemple #2
0
def scatterplot(data, name="", xlabel="", ylabel="", size= 3):
  """
  Creates a scatter plot from x,y data.

  *data* is a list of (x,y) tuples.
  """
    
  xAxis = NumberAxis(xlabel)   
  xAxis.setAutoRangeIncludesZero(False)   
  yAxis = NumberAxis(ylabel)   
  yAxis.setAutoRangeIncludesZero(False)   
   
  series = XYSeries("Values");     
  for (i,j) in data:         
    series.add(i, j)

  dataset = XYSeriesCollection()
  dataset.addSeries(series);
  chart = ChartFactory.createScatterPlot(name, xlabel, ylabel, dataset, 
    PlotOrientation.VERTICAL, True, True, False)    
  plot = chart.getPlot()
  plot.getRenderer().setSeriesShape(0, 
    ShapeUtilities.createRegularCross(size,size));                  
    
  return Chart(chart)
    
Exemple #3
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("Response Time")
        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)
Exemple #4
0
    def _overlay(self, chart):
        plot = self.chart.getPlot()
        plot.setDataset(self.datasets, chart.chart.getPlot().getDataset())
        plot.setRenderer(self.datasets, chart.chart.getPlot().getRenderer())
        plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD)

        yAxis = NumberAxis("")
        plot.setRangeAxis(self.datasets, yAxis)
        plot.mapDatasetToRangeAxis(self.datasets, self.datasets)
        self.datasets += 1
Exemple #5
0
def scatterplot(data, name="", xlabel="", ylabel="", size= 3):
  """
  Creates a scatter plot from x,y data.

  *data* is a list of (x,y) tuples.
  """
    
  xAxis = NumberAxis(xlabel)   
  xAxis.setAutoRangeIncludesZero(False)   
  yAxis = NumberAxis(ylabel)   
  yAxis.setAutoRangeIncludesZero(False)   
   
  series = XYSeries("Values");     
  for (i,j) in data:         
    series.add(i, j)

  dataset = XYSeriesCollection()
  dataset.addSeries(series);
  chart = ChartFactory.createScatterPlot(name, xlabel, ylabel, dataset, 
    PlotOrientation.VERTICAL, True, True, False)    
  plot = chart.getPlot()
  plot.getRenderer().setSeriesShape(0, 
    ShapeUtilities.createRegularCross(size,size));                  
    
  return Chart(chart)
Exemple #6
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
Exemple #7
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
##############
# Plot Chart #
##############
#chart = ChartFactory.createLineChart(None,'Slide','% Brown Area',dataset,PlotOrientation.VERTICAL,False,True,False)
chart = ChartFactory.createBarChart("% Brown Area per Slide", 'Slide', '% Brown Area', dataset, PlotOrientation.VERTICAL, False,True,False)
# set the background color for the chart...
chart.setBackgroundPaint(Color.WHITE)

plot = chart.getPlot()
plot.setBackgroundPaint(Color.WHITE)
plot.setRangeGridlinesVisible(False)
plot.setAxisOffset(RectangleInsets.ZERO_INSETS)

#customise the range axis...
rangeAxis = plot.getRangeAxis()
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits())
rangeAxis.setAutoRangeIncludesZero(True)
#Set the Min Max value of the y axis
rangeAxis.setRange(0, 100)
#Create a custom BarRenderer
barRenderer = BarRenderer()
#Add a label in the middle of the histogram bar showing the % value
barRenderer.setBaseItemLabelGenerator(StandardCategoryItemLabelGenerator())
barRenderer.setBaseItemLabelsVisible(True)
#For parameters
#See http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/labels/ItemLabelAnchor.html
#See http://www.jfree.org/jcommon/api/org/jfree/ui/TextAnchor.html and 
itemlabelposition = ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER, TextAnchor.BOTTOM_CENTER, 0.00)
barRenderer.setBasePositiveItemLabelPosition(itemlabelposition)
#Customize the bar's color so they will be gray with a black outline and no shadow
barRenderer.setBarPainter(StandardBarPainter())#Use StandardBarPainter to avoid the color gradient inside the bar