Package com.positive.charts.data.general

Examples of com.positive.charts.data.general.DefaultPieDataset


   */
  public static PieDataset createConsolidatedPieDataset(
      final PieDataset source, final Comparable key,
      final double minimumPercent, final int minItems) {

    final DefaultPieDataset result = new DefaultPieDataset();
    final double total = DatasetUtilities.calculatePieDatasetTotal(source);

    // Iterate and find all keys below threshold percentThreshold
    final List keys = source.getKeys();
    final ArrayList otherKeys = new ArrayList();
    Iterator iterator = keys.iterator();
    while (iterator.hasNext()) {
      final Comparable currentKey = (Comparable) iterator.next();
      final Number dataValue = source.getValue(currentKey);
      if (dataValue != null) {
        final double value = dataValue.doubleValue();
        if (value / total < minimumPercent) {
          otherKeys.add(currentKey);
        }
      }
    }

    // Create new dataset with keys above threshold percentThreshold
    iterator = keys.iterator();
    double otherValue = 0;
    while (iterator.hasNext()) {
      final Comparable currentKey = (Comparable) iterator.next();
      final Number dataValue = source.getValue(currentKey);
      if (dataValue != null) {
        if (otherKeys.contains(currentKey)
            && (otherKeys.size() >= minItems)) {
          // Do not add key to dataset
          otherValue += dataValue.doubleValue();
        } else {
          // Add key to dataset
          result.setValue(currentKey, dataValue);
        }
      }
    }
    // Add other category if applicable
    if (otherKeys.size() >= minItems) {
      result.setValue(key, otherValue);
    }
    return result;
  }
View Full Code Here


   *
   * @return A pie dataset.
   */
  public static PieDataset createPieDatasetForColumn(
      final CategoryDataset dataset, final int column) {
    final DefaultPieDataset result = new DefaultPieDataset();
    final int rowCount = dataset.getRowCount();
    for (int i = 0; i < rowCount; i++) {
      final Comparable rowKey = dataset.getRowKey(i);
      result.setValue(rowKey, dataset.getValue(i, column));
    }
    return result;
  }
View Full Code Here

   *
   * @return A pie dataset.
   */
  public static PieDataset createPieDatasetForRow(
      final CategoryDataset dataset, final int row) {
    final DefaultPieDataset result = new DefaultPieDataset();
    final int columnCount = dataset.getColumnCount();
    for (int current = 0; current < columnCount; current++) {
      final Comparable columnKey = dataset.getColumnKey(current);
      result.setValue(columnKey, dataset.getValue(row, current));
    }
    return result;
  }
View Full Code Here

    chart.setLayout(new GridLayout(3, false));
    CTabItem item = new CTabItem(basicData, SWT.NONE);
    item.setText(title);
    item.setControl(chart);

    DefaultPieDataset dataset = new DefaultPieDataset();
    double rest = 100;
    for (int a = 0; a < hotSpotsByModule.length; a++) {
      double value = getChartValue(calc, hotSpotsByModule[a]);
      rest -= value;
      dataset.setValue(getChartKey(hotSpotsByModule[a], calc), value);
    }
    if (rest > 1) {
      dataset.setValue("Other" + " "
          + StringUtils.getPercentNumberString(rest), rest);
    }
    Chart ch = createChart(dataset, title);

    ChartCanvas chartCanvas = new ChartCanvas(chart, SWT.DOUBLE_BUFFERED,
View Full Code Here

TOP

Related Classes of com.positive.charts.data.general.DefaultPieDataset

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.