use of org.knowm.xchart.XChartPanel in project XChange by knowm.
the class BitcoiniumRealtimeOrderbookDemo method buildPanel.
public XChartPanel<XYChart> buildPanel() throws IOException {
System.out.println("fetching data...");
updateData();
// create chart
chart = new XYChartBuilder().width(800).height(400).title("Real-time Bitcoinium Order Book - BITSTAMP_BTC_USD").xAxisTitle("BTC").yAxisTitle("USD").build();
// Customize Chart
chart.getStyler().setLegendPosition(LegendPosition.InsideNE);
chart.getStyler().setDefaultSeriesRenderStyle(XYSeriesRenderStyle.Area);
// add series
XYSeries series = chart.addSeries(BIDS_SERIES_NAME, xAxisBidData, yAxisBidData);
series.setMarker(SeriesMarkers.NONE);
series = chart.addSeries(ASKS_SERIES_NAME, xAxisAskData, yAxisAskData);
series.setMarker(SeriesMarkers.NONE);
return new XChartPanel<>(chart);
}
use of org.knowm.xchart.XChartPanel in project XChange by knowm.
the class BitcoiniumRealtimeTickerDemo method buildPanel.
public XChartPanel<XYChart> buildPanel() throws IOException {
System.out.println("fetching data...");
// Get the latest order book data for BTC/USD - BITSTAMP
BitcoiniumTickerHistory bitcoiniumTickerHistory = bitcoiniumMarketDataService.getBitcoiniumTickerHistory("BTC", "BITSTAMP_USD", "THREE_HOURS");
System.out.println(bitcoiniumTickerHistory.toString());
// build ticker history chart series data
xAxisData = new ArrayList<>();
yAxisData = new ArrayList<>();
for (int i = 0; i < bitcoiniumTickerHistory.getCondensedTickers().length; i++) {
BitcoiniumTicker bitcoiniumTicker = bitcoiniumTickerHistory.getCondensedTickers()[i];
Date timestamp = new Date(bitcoiniumTicker.getTimestamp());
float price = bitcoiniumTicker.getLast().floatValue();
System.out.println(timestamp + ": " + price);
xAxisData.add(timestamp);
yAxisData.add(price);
}
// Create Chart
chart = new XYChartBuilder().width(800).height(600).title("Real-time Bitstamp Price vs. Time").xAxisTitle("Time").yAxisTitle("Price").build();
// Customize Chart
chart.getStyler().setDefaultSeriesRenderStyle(XYSeriesRenderStyle.Area);
chart.getStyler().setLegendPosition(LegendPosition.InsideNE);
// add series
XYSeries series = chart.addSeries(SERIES_NAME, xAxisData, yAxisData);
series.setMarker(SeriesMarkers.NONE);
return new XChartPanel(chart);
}
use of org.knowm.xchart.XChartPanel in project skeleton-sp18 by Berkeley-CS61B.
the class GeneratorAudioAnimator method drawAndPlay.
public void drawAndPlay(int numSamplesDraw, int numSamplesPlay) {
chart = QuickChart.getChart("Wave Animator", "Time", "Value", "wave", new double[] { 0 }, new double[] { 0 });
AxesChartStyler chartStyler = chart.getStyler();
chartStyler.setYAxisMin(-1.0);
chartStyler.setYAxisMax(1.0);
chartStyler.setXAxisTicksVisible(false);
frame = new JFrame("XChart");
XChartPanel<XYChart> panel = new XChartPanel<>(chart);
frame.add(panel);
frame.pack();
frame.setVisible(true);
javax.swing.SwingUtilities.invokeLater(() -> {
Animator animator = new Animator(numSamplesDraw, numSamplesPlay);
animator.execute();
});
}
use of org.knowm.xchart.XChartPanel in project triplea by triplea-game.
the class StatisticsDialog method createChart.
private JPanel createChart(final OverTimeChart chartData) {
final XYChart chart = xyChartDefaults.title(chartData.getTitle()).yAxisTitle(chartData.getAxisTitle()).build();
chartData.getData().rowMap().forEach((key, value) -> chart.addSeries(key, new ArrayList<>(value.values())));
return new XChartPanel<>(chart);
}
Aggregations