Refine search
PiePlot plot = (PiePlot) someChart.getPlot(); plot.setSectionPaint(KEY1, Color.green); plot.setSectionPaint(KEY2, Color.red); plot.setLabelGenerator(gen); JFrame f = new JFrame("Test"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(new ChartPanel(someChart) { @Override public Dimension getPreferredSize() { return new Dimension(400, 300);
private GUIUtils(String title, DataSequence orig, DataSequence predicted, ArrayList<Anomaly> anomalyList, Properties config) { super(title); this.config = config; final JFreeChart chart = createCombinedChart(orig, predicted, anomalyList); final ChartPanel panel = new ChartPanel(chart, true, true, true, false, true); panel.setPreferredSize(new java.awt.Dimension(1440, 900)); setContentPane(panel); }
JFrame f = new JFrame(title); f.setTitle(title); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setLayout(new BorderLayout(0, 5)); f.add(chartPanel, BorderLayout.CENTER); chartPanel.setMouseWheelEnabled(true); chartPanel.setHorizontalAxisTrace(true); chartPanel.setVerticalAxisTrace(true); public void actionPerformed(ActionEvent e) { if (traceCmds[0].equals(trace.getSelectedItem())) { chartPanel.setHorizontalAxisTrace(true); chartPanel.setVerticalAxisTrace(true); chartPanel.repaint(); } else { chartPanel.setHorizontalAxisTrace(false); chartPanel.setVerticalAxisTrace(false); chartPanel.repaint(); JFreeChart chart = chartPanel.getChart(); XYPlot plot = (XYPlot) chart.getPlot(); DateAxis domain = (DateAxis) plot.getDomainAxis(); chartPanel.restoreAutoBounds(); EventQueue.invokeLater(new Runnable() {
JFrame f = new JFrame("BoxPlot"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); DefaultBoxAndWhiskerCategoryDataset data = new DefaultBoxAndWhiskerCategoryDataset(); data.add(Arrays.asList(30, 36, 46, 55, 65, 76, 81, 80, 71, 59, 44, 34), "Planet", "Endor"); JFreeChart chart = ChartFactory.createBoxAndWhiskerChart( "Box and Whisker Chart", "Planet", "Temperature", data, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setOrientation(PlotOrientation.HORIZONTAL); f.add(new ChartPanel(chart) { return new Dimension(500, 300); f.pack(); f.setLocationRelativeTo(null); f.setVisible(true); EventQueue.invokeLater(new BoxPlot()::display);
/** * Displays chart on the screen using Swing. * This method creates an application containing a chart panel displaying * the chart. The created frame is positioned on-screen, and displayed before * it is returned. The <TT>width</TT> and the <TT>height</TT> * of the chart are measured in pixels. * * @param width frame width in pixels. * * @param height frame height in pixels. * * */ public JFrame view (int width, int height) { JFrame myFrame; if (chart.getTitle() != null) myFrame = new JFrame("MultipleDatasetChart from SSJ: " + chart.getTitle().getText()); else myFrame = new JFrame("MultipleDatasetChart from SSJ"); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(width, height)); myFrame.setContentPane(chartPanel); myFrame.pack(); myFrame.setDefaultCloseOperation (JFrame.DISPOSE_ON_CLOSE); myFrame.setLocationRelativeTo (null); myFrame.setVisible(true); return myFrame; }
private static void displayTimeSeries(TSCollection dataset, String name, String xname, String yname) { final JFreeChart chart = ChartFactory.createTimeSeriesChart(name, xname, yname, dataset, true, false, false); final ChartPanel panel = new ChartPanel(chart); panel.setFillZoomRectangle(true); final JFrame j = new JFrame(); j.setContentPane(panel); j.pack(); j.setVisible(true); j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
frame = new JFrame("Test"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); aPanel.setPreferredSize(new Dimension(600, 300)); chartPanel.setPreferredSize(new Dimension(600, 300)); frame.getContentPane().add(chartPanel); frame.pack(); frame.setVisible(true);
"BarChart using JFreeChart", "Student sample", "Marks sample", dataset, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.yellow); chart.getTitle().setPaint(Color.blue); CategoryPlot plot = chart.getCategoryPlot(); BarRenderer br = (BarRenderer) plot.getRenderer(); br.setItemMargin(0); domain.setUpperMargin(0.25); JFrame f = new JFrame("TreeEditorDemo"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ChartPanel cp = new ChartPanel(chart){ return new Dimension(300, 300); f.add(cp); f.pack(); f.setLocationRelativeTo(null); f.setVisible(true);
ChartPanel chartPanelCSR = new ChartPanel(chartCSR); chartPanelCSR.setPreferredSize(new java.awt.Dimension(chartWidth, chartHeight)); plotContainer.add(chartPanelCSR, c); this.updateGBConstraint(c, columns); ((XYPlot)chartCSRAvg.getPlot()).setRenderer(this.createDeviationRenderer()); ChartPanel chartPanelCSRAvg = new ChartPanel(chartCSRAvg); chartPanelCSRAvg.setPreferredSize(new java.awt.Dimension(chartWidth, chartHeight)); plotContainer.add(chartPanelCSRAvg, c); this.updateGBConstraint(c, columns);
"Goals Scored Over Time", "Fixture Number", "Goals", xyDataset, PlotOrientation.VERTICAL, true, true, false); ChartPanel cp = new ChartPanel(chart) { return new Dimension(320, 240); cp.setMouseWheelEnabled(true); add(cp); setDefaultCloseOperation(EXIT_ON_CLOSE); pack(); java.awt.EventQueue.invokeLater(new Runnable() { @Override public void run() { new ChartTest().setVisible(true);
void saveToSVG(File svgFileName) throws IOException { DOMImplementation domImpl = GenericDOMImplementation.getDOMImplementation(); Document document = domImpl.createDocument(null, "svg", null); // Create an instance of the SVG Generator SVGGraphics2D svgGenerator = new SVGGraphics2D(document); ChartPanel chartpanel = new ChartPanel(graph, true, true, true, false, true); JFrame tmpFrame = new JFrame(); tmpFrame.getContentPane().add(chartpanel); tmpFrame.setSize(1024, 768); tmpFrame.setVisible(true); // draw the chart in the SVG generator graph.draw(svgGenerator, tmpFrame.getContentPane().getBounds()); // Write svg file OutputStream outputStream = new FileOutputStream(svgFileName); Writer out = new OutputStreamWriter(outputStream, "UTF-8"); svgGenerator.stream(out, true); outputStream.flush(); outputStream.close(); try { Thread.sleep(3000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } tmpFrame.dispose(); }
/** Return the JFreeChart with this histogram, and as a side effect, show it in a JFrame * that provides the means to edit the dimensions and also the plot properties via a popup menu. */ public JFreeChart asChart(final boolean show) { double[] d = new double[this.size()]; int i = 0; for (Number num : this.values()) d[i++] = num.doubleValue(); HistogramDataset hd = new HistogramDataset(); hd.setType(HistogramType.RELATIVE_FREQUENCY); String title = "Histogram"; hd.addSeries(title, d, d.length); JFreeChart chart = ChartFactory.createHistogram(title, "", "", hd, PlotOrientation.VERTICAL, false, false, false); setTheme(chart); if (show) { JFrame frame = new JFrame(title); frame.getContentPane().add(new ChartPanel(chart)); frame.pack(); frame.setVisible(true); } return chart; }
/**Plot the training data. Assume 2d input, classification output * @param features Training data features * @param labels Training data labels (one-hot representation) * @param backgroundIn sets of x,y points in input space, plotted in the background * @param backgroundOut results of network evaluation at points in x,y points in space * @param nDivisions Number of points (per axis, for the backgroundIn/backgroundOut arrays) */ public static void plotTrainingData(INDArray features, INDArray labels, INDArray backgroundIn, INDArray backgroundOut, int nDivisions){ double[] mins = backgroundIn.min(0).data().asDouble(); double[] maxs = backgroundIn.max(0).data().asDouble(); XYZDataset backgroundData = createBackgroundData(backgroundIn, backgroundOut); JPanel panel = new ChartPanel(createChart(backgroundData, mins, maxs, nDivisions, createDataSetTrain(features, labels))); JFrame f = new JFrame(); f.add(panel); f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); f.pack(); f.setTitle("Training Data"); f.setVisible(true); }
private static CategoryPlot createChartFrame(CategoryDataset dataSet) { JFreeChart chart = ChartFactory.createBarChart( "Trading Volume", "Stock", "Volume, USD", dataSet, PlotOrientation.HORIZONTAL, true, true, false); CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.DARK_GRAY); plot.setRangeGridlinePaint(Color.DARK_GRAY); plot.getRenderer().setSeriesPaint(0, Color.BLUE); final JFrame frame = new JFrame(); frame.setBackground(Color.WHITE); frame.setDefaultCloseOperation(EXIT_ON_CLOSE); frame.setTitle("Hazelcast Jet Source Builder Sample"); frame.setBounds(WINDOW_X, WINDOW_Y, WINDOW_WIDTH, WINDOW_HEIGHT); frame.setLayout(new BorderLayout()); frame.add(new ChartPanel(chart)); frame.setVisible(true); return plot; } }
/** * A demonstration application showing how to create a simple time series * chart. This example uses monthly data. * * @param title the frame title. */ public TimeCategoryPlot(String title) { super(title); ChartPanel chartPanel = (ChartPanel) createDemoPanel(); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); chartPanel.setMouseZoomable(true, false); setContentPane(chartPanel); }
private void applyZoom(float multiplier) { int width = (int) (chartPanel.getSize().width * multiplier); int heigth = (int) (chartPanel.getSize().height * multiplier); width= width > MAX_DIMENSION ? MAX_DIMENSION : width; heigth= heigth > MAX_DIMENSION ? MAX_DIMENSION : heigth; chartPanel.setPreferredSize(new Dimension(width,heigth)); chartPanel.revalidate(); chartPanel.repaint(); }
/** * Create a chart with the underlying dataset. * @return The chart. */ protected JFreeChart createChart() { XYDataset dataset = new TimeSeriesCollection(); JFreeChart chart = ChartFactory.createTimeSeriesChart("Service Quality", "ms", "score", dataset, true, true, true); chart.setNotify(true); ChartPanel panel = new ChartPanel(chart); panel.setFillZoomRectangle(true); frame = new JFrame(); JPanel content = new JPanel(new BorderLayout()); content.add(panel, BorderLayout.CENTER); frame.setContentPane(panel); frame.pack(); frame.setVisible(true); return chart; }
chartPanel.setPreferredSize( new java.awt.Dimension( 500 , 500 ) ); final XYPlot plot = xylineChart.getXYPlot( ); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer( ); renderer.setSeriesPaint( 0 , Color.RED ); renderer.setSeriesStroke( 0 , new BasicStroke( 4.0f ) ); plot.setRenderer( renderer ); setContentPane( chartPanel );
this.setSize(new Dimension(frameWidth, frameHeight)); softeningSlider.setPreferredSize(new Dimension(200, 30)); sliderPanel.add(sliderMin); sliderPanel.add(sliderMax); sliderPanel.setPreferredSize(new Dimension(60, 600)); sliderMin.setPreferredSize(new Dimension(30, 600)); sliderMax.setPreferredSize(new Dimension(30, 600)); lineChart.getTitle().setFont(new Font("Ubuntu", Font.PLAIN, 20)); lineChart.getPlot().setOutlineStroke(new BasicStroke(3)); lineChart.getCategoryPlot().getRenderer().setSeriesStroke(0, new BasicStroke(3)); lineChart.getCategoryPlot().getRenderer().setSeriesStroke(1, new BasicStroke(3)); ChartPanel chartPanel = new ChartPanel(lineChart); analysisPanel.add(chartPanel, BorderLayout.CENTER);
public static ApplicationFrame createChartFrame(String title, JFreeChart... charts) { ApplicationFrame chartFrame = new ApplicationFrame(title); final JPanel panel = new JPanel(); panel.setLayout(new GridLayout(0, 1)); for (JFreeChart chart : charts) { final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new Dimension(800, 300)); chartPanel.setMouseZoomable(true, false); panel.add(chartPanel); } chartFrame.setContentPane(panel); return chartFrame; }