def __init__(self, automations):

        # Create the frame
        frame = JFrame("Automation Viewer")
        frame.setSize(500, 300)
        frame.setLayout(BorderLayout())

        series = AutomationSeries
        # Finalize the window
        frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE)
        frame.setVisible(True)

        # Create an XY dataset
        dataset = XYSeriesCollection()

        for autoname in automations:

            automation = ModbusPal.getAutomation(autoname)
            series = AutomationSeries(automation)
            dataset.addSeries(series)
            frame.addWindowListener(series)

        # Create chart
        chart = ChartFactory.createXYLineChart("Automation Viewer",
                                               "Time (seconds)", "Value",
                                               dataset,
                                               PlotOrientation.VERTICAL,
                                               Boolean.TRUE, Boolean.TRUE,
                                               Boolean.FALSE)
        panel = ChartPanel(chart)

        # Add chart to panel
        frame.add(panel, BorderLayout.CENTER)
Esempio n. 2
0
def curve(data, name="", smooth=True, trid=True):
    """
  Creates a curve based on a list of (x,y) tuples.
    
  Setting *smooth* to ``True`` results in a spline renderer renderer is used.

  Setting *trid* to ``True`` results in a 3D plot. In this case the ``smooth``
  argument is ignored.
  """

    dataset = XYSeriesCollection()
    xy = XYSeries(name)
    for d in data:
        xy.add(d[0], d[1])
    dataset.addSeries(xy)
    chart = ChartFactory.createXYLineChart(None, None, None, dataset,
                                           PlotOrientation.VERTICAL, True,
                                           True, False)

    if smooth:
        chart.getXYPlot().setRenderer(XYSplineRenderer())
    if trid:
        chart.getXYPlot().setRenderer(XYLine3DRenderer())

    return Chart(chart)
Esempio n. 3
0
 def createChart(self):
     dataset = XYSeriesCollection()
     for s in self.allSeries:
         dataset.addSeries(s)
     # title is None
     chart = ChartFactory.createXYLineChart( \
                 None, xlabel(), ylabel(), \
                 dataset, PlotOrientation.VERTICAL, \
                 True, True, False)
     return chart
Esempio n. 4
0
 def createChart(self):
     dataset = XYSeriesCollection()
     for s in self.allSeries:
         dataset.addSeries(s)
     # title is None
     chart = ChartFactory.createXYLineChart( \
                 None, xlabel(), ylabel(), \
                 dataset, PlotOrientation.VERTICAL, \
                 True, True, False)
     return chart
Esempio n. 5
0
 def _createChart(self):
     self.chart = ChartFactory.createXYLineChart(
         self.getTitle(),          # chart title
         self.getXAxisLabel(),     # x axis label
         self.getYAxisLabel(),     # y axis label
         self.dataSets[0],         # data (primary)
         PlotOrientation.VERTICAL,
         True,                     # include legend
         False,                    # tooltips
         False                     # urls
     )
Esempio n. 6
0
def plot(title, x_label, y_label, *curves):
    dataset = XYSeriesCollection()
    for legend, curve in curves:
        series = XYSeries(legend)
        for x, y in curve:
            series.add(x, y)
        dataset.addSeries(series)
    chart = ChartFactory.createXYLineChart(title, x_label, y_label, dataset,
                                           PlotOrientation.VERTICAL, True,
                                           True, False)
    frame = ChartFrame(title, chart)
    frame.setVisible(True)
    frame.setSize(400, 300)
Esempio n. 7
0
 def _createEmptyChart(self, dataset = None):
     chart = ChartFactory.createXYLineChart(
         self.title,               # chart title
         "He",                     # x axis label
         "Fst",                    # y axis label
         dataset,                  # data
         PlotOrientation.VERTICAL,
         True,                     # include legend
         True,                     # tooltips
         False                     # urls
     )
     chart.setBackgroundPaint(Color.white)
     # get a reference to the plot for further customisation...
     # change the auto tick unit selection to integer units only...
     #rangeAxis = plot.getRangeAxis()
     #rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits())
     self.confArea = None
     return chart
Esempio n. 8
0
def graphArbitraryData(data,title=""):
    ''' Creates a line graph of arbitrary data (as opposed to the rather specific format used by graph()). Pass in a 
        list of datapoints, each consisting of a 3-part tuple: (x,y,category). If you're only graphing one sort of
        data (ie you want a graph with one line), you can pass in any constant for category.
        
        Example (one category):
            data = []
            for i in range(10):
                data.append((i,i*i,0))
            graphArbitraryData(data)
        
        Example (multiple categories):
            data = []
            for i in range(30):
                data.append((i,i*i,"squared"))
                data.append((i,i*i*i,"cubed"))
            graphArbitraryData(data)

    '''
    from org.jfree.data.category import DefaultCategoryDataset
    from org.jfree.chart import ChartFactory, ChartFrame, ChartPanel
    from org.jfree.chart.plot import PlotOrientation
    from org.jfree.data.xy import XYSeriesCollection, XYSeries

    datasets = {} # dict of all series

    # First, create the individual series from the data
    for item in data:
        seriesname = str(item[2])
        if seriesname not in datasets:
            datasets[seriesname] = XYSeries(seriesname)
        datasets[seriesname].add(float(item[0]), float(item[1]));

    # Second, add those series to a collection
    datasetcollection = XYSeriesCollection()    
    for key in datasets:
        datasetcollection.addSeries(datasets[key])
        
    chart = ChartFactory.createXYLineChart("","","",datasetcollection,PlotOrientation.VERTICAL,True,True,False) 
    frame = ChartFrame(title, chart);
    frame.pack();
    frame.setVisible(True);
    panel = ChartPanel(chart)
    return chart.getPlot()
Esempio n. 9
0
 def _createEmptyChart(self, dataset=None):
     if self.isTemporal:
         hText = "Hs"
         fText = "Fgt"
     else:
         hText = "He"
         fText = "Fst"
     chart = ChartFactory.createXYLineChart(
         self.title,  # chart title
         hText,  # x axis label
         fText,  # y axis label
         dataset,  # data
         PlotOrientation.VERTICAL,
         True,  # include legend
         True,  # tooltips
         False  # urls
     )
     chart.setBackgroundPaint(Color.white)
     # get a reference to the plot for further customisation...
     # change the auto tick unit selection to integer units only...
     #rangeAxis = plot.getRangeAxis()
     #rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits())
     self.confArea = None
     return chart
Esempio n. 10
0
def curve(data, name="", smooth=True, trid=True):
  """
  Creates a curve based on a list of (x,y) tuples.
    
  Setting *smooth* to ``True`` results in a spline renderer renderer is used.

  Setting *trid* to ``True`` results in a 3D plot. In this case the ``smooth``
  argument is ignored.
  """
    
  dataset = XYSeriesCollection()
  xy = XYSeries(name);        
  for d in data:
    xy.add(d[0], d[1])
  dataset.addSeries(xy);
  chart = ChartFactory.createXYLineChart(None, None, None, dataset, 
    PlotOrientation.VERTICAL, True, True, False)

  if smooth:
      chart.getXYPlot().setRenderer(XYSplineRenderer())
  if trid:
      chart.getXYPlot().setRenderer(XYLine3DRenderer())        
    
  return Chart(chart)