public JFreeChart getChart(JSONObject jsonData, boolean legendBit, boolean tooltipBit) { DefaultPieDataset dataset = new DefaultPieDataset(); Iterator iter = jsonData.keys(); while (iter.hasNext()) { String keyData = (String)iter.next(); Float value = Float.parseFloat(jsonData.getString(keyData)); dataset.setValue(keyData, value); } boolean legend = legendBit; boolean tooltips = tooltipBit; boolean urls = false; JFreeChart chart = ChartFactory.createPieChart("Loklak Visualizes - PieChart", dataset, legend, tooltips, urls); chart.setBorderPaint(Color.BLACK); chart.setBorderStroke(new BasicStroke(5.0f)); chart.setBorderVisible(true); return chart; } }
/** * Sets the value and sends a {@link DatasetChangeEvent} to all registered * listeners. * * @param value the new value ({@code null} permitted). */ public void setValue(Number value) { this.value = value; notifyListeners(new DatasetChangeEvent(this, this)); }
/** * General method for signalling to registered listeners that the series * has been changed. */ public void fireSeriesChanged() { if (this.notify) { notifyListeners(new SeriesChangeEvent(this)); } }
/** * Notifies all registered listeners that the dataset has changed, * provided that the {@code notify} flag has not been set to * {@code false}. * * @see #addChangeListener(DatasetChangeListener) */ protected void fireDatasetChanged() { if (this.notify) { notifyListeners(new DatasetChangeEvent(this, this)); } }
/** * Adds one SeriesDataset to the combination. Listeners are notified of the * change. * * @param data the SeriesDataset to add. */ public void add(SeriesDataset data) { fastAdd(data); DatasetChangeEvent event = new DatasetChangeEvent(this, this); notifyListeners(event); }
/** * Default constructor. */ public CompassPlot() { this(new DefaultValueDataset()); }
/** * Adds one series from a SeriesDataset to the combination. Listeners are * notified of the change. * * @param data the SeriesDataset where series is contained * @param series series to add */ public void add(SeriesDataset data, int series) { add(new SubSeriesDataset(data, series)); }
/** * Returns the key for a series. * * @param series the series (zero-based index). * * @return The key for a series. */ public Comparable getSeriesKey(int series) { DatasetInfo di = getDatasetInfo(series); return di.data.getSeriesKey(di.series); }
/** * Sets a value in the dataset. * * @param value the value. * @param chipx the x-index for the chip. * @param chipy the y-index for the chip. */ public void addValue(Number value, Comparable chipx, Comparable chipy) { setValue(value, chipx, chipy); }
/** * Called when a series belonging to the dataset changes. * * @param event information about the change. */ @Override public void seriesChanged(SeriesChangeEvent event) { fireDatasetChanged(); }
/** * Returns the range of values in the range for the dataset. * * @param dataset the dataset ({@code null} not permitted). * * @return The range (possibly {@code null}). */ public static Range findRangeBounds(CategoryDataset dataset) { return findRangeBounds(dataset, true); }
/** * Returns the minimum and maximum values for the dataset's range, * assuming that the series are stacked. * * @param dataset the dataset ({@code null} not permitted). * * @return The range ([0.0, 0.0] if the dataset contains no values). */ public static Range findStackedRangeBounds(TableXYDataset dataset) { return findStackedRangeBounds(dataset, 0.0); }
/** * Returns the range of values in the domain (x-values) of a dataset. * * @param dataset the dataset ({@code null} not permitted). * * @return The range of values (possibly {@code null}). */ public static Range findDomainBounds(XYDataset dataset) { return findDomainBounds(dataset, true); }
/** * Returns the range of values in the z-dimension for the dataset. This * method is the partner for the {@link #findRangeBounds(XYDataset)} * and {@link #findDomainBounds(XYDataset)} methods. * * @param dataset the dataset ({@code null} not permitted). * * @return The range (possibly {@code null}). */ public static Range findZBounds(XYZDataset dataset) { return findZBounds(dataset, true); }
DefaultPieDataset dataSet = new DefaultPieDataset(); dataSet.setValue("China", 1344.0); dataSet.setValue("India", 1241.0); dataSet.setValue("United States", 310.5);
/** * Sets the value and sends a {@link DatasetChangeEvent} to all registered * listeners. * * @param value the new value (<code>null</code> permitted). */ public void setValue(Number value) { this.value = value; notifyListeners(new DatasetChangeEvent(this, this)); }
/** * Notifies all registered listeners that the dataset has changed. * * @see #addChangeListener(DatasetChangeListener) */ protected void fireDatasetChanged() { notifyListeners(new DatasetChangeEvent(this, this)); }
/** * Adds an array of SeriesDataset's to the combination. Listeners are * notified of the change. * * @param data array of SeriesDataset to add */ public void add(SeriesDataset[] data) { for (int i = 0; i < data.length; i++) { fastAdd(data[i]); } DatasetChangeEvent event = new DatasetChangeEvent(this, this); notifyListeners(event); }
/** * General method for signalling to registered listeners that the series * has been changed. */ public void fireSeriesChanged() { if (this.notify) { notifyListeners(new SeriesChangeEvent(this)); } }
DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue(KEY1, 99); dataset.setValue(KEY2, 77);