Search in sources :

Example 1 with XChartPanel

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);
}
Also used : XYSeries(org.knowm.xchart.XYSeries) XChartPanel(org.knowm.xchart.XChartPanel) XYChartBuilder(org.knowm.xchart.XYChartBuilder)

Example 2 with XChartPanel

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);
}
Also used : XYSeries(org.knowm.xchart.XYSeries) BitcoiniumTickerHistory(org.knowm.xchange.bitcoinium.dto.marketdata.BitcoiniumTickerHistory) BitcoiniumTicker(org.knowm.xchange.bitcoinium.dto.marketdata.BitcoiniumTicker) XChartPanel(org.knowm.xchart.XChartPanel) XYChartBuilder(org.knowm.xchart.XYChartBuilder) Date(java.util.Date)

Example 3 with XChartPanel

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();
    });
}
Also used : XYChart(org.knowm.xchart.XYChart) AxesChartStyler(org.knowm.xchart.style.AxesChartStyler) XChartPanel(org.knowm.xchart.XChartPanel)

Example 4 with XChartPanel

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);
}
Also used : ArrayList(java.util.ArrayList) XYChart(org.knowm.xchart.XYChart) XChartPanel(org.knowm.xchart.XChartPanel)

Aggregations

XChartPanel (org.knowm.xchart.XChartPanel)4 XYChart (org.knowm.xchart.XYChart)2 XYChartBuilder (org.knowm.xchart.XYChartBuilder)2 XYSeries (org.knowm.xchart.XYSeries)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 BitcoiniumTicker (org.knowm.xchange.bitcoinium.dto.marketdata.BitcoiniumTicker)1 BitcoiniumTickerHistory (org.knowm.xchange.bitcoinium.dto.marketdata.BitcoiniumTickerHistory)1 AxesChartStyler (org.knowm.xchart.style.AxesChartStyler)1