Search in sources :

Example 6 with TimeTableXYDataset

use of org.jfree.data.time.TimeTableXYDataset in project cubrid-manager by CUBRID.

the class CombinedBarTimeSeriesChart method updateValueMapIfArea.

/**
	 * Update the value based on the new value if series chart uses the area
	 * renderer
	 * 
	 * @param valueMap the valueMap to set
	 * @param barLabel the label text in the bar chart
	 */
private void updateValueMapIfArea(TreeMap<String, String> valueMap, String barLabel) {
    this.valueMap = valueMap;
    bardataset.clear();
    double allValue = 0;
    for (Map.Entry<String, String> entry : valueMap.entrySet()) {
        String value = entry.getValue();
        String key = entry.getKey();
        if (value != null) {
            double newValue = Double.parseDouble(value);
            bardataset.addValue(newValue, key, "");
            ((TimeTableXYDataset) seriesdataset).add(new Second(), newValue, key);
            allValue += newValue;
        }
    }
    if (allValue > barMax) {
        barMax = allValue;
    }
    bardataset.addValue(barMax - allValue, "100", "");
    numberaxis.setRange(0 - 1, barMax + barMax / 100);
    String label = barLabel;
    if ("%".equals(label)) {
        label = Integer.toString((int) (allValue + 0.5)) + label;
    }
    categoryAxis.setLabel(label);
}
Also used : TimeTableXYDataset(org.jfree.data.time.TimeTableXYDataset) Second(org.jfree.data.time.Second) Map(java.util.Map) TreeMap(java.util.TreeMap)

Aggregations

TimeTableXYDataset (org.jfree.data.time.TimeTableXYDataset)6 Map (java.util.Map)3 TreeMap (java.util.TreeMap)3 DateAxis (org.jfree.chart.axis.DateAxis)2 ValueAxis (org.jfree.chart.axis.ValueAxis)2 Second (org.jfree.data.time.Second)2 Test (org.junit.Test)2 ChartModel (org.xwiki.chart.model.ChartModel)2 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 Locale (java.util.Locale)1 TimeSeries (org.jfree.data.time.TimeSeries)1 TimeSeriesCollection (org.jfree.data.time.TimeSeriesCollection)1 MacroExecutionException (org.xwiki.rendering.macro.MacroExecutionException)1