Search in sources :

Example 11 with TimeSeries

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

the class ChartCompositePart method updateSettingChart.

/**
	 * Update setting chart
	 *
	 * @param item the selected item
	 * @param checked whether show in the table
	 * @param seriesRgb the background color of the selected item
	 * @param width the width of the selected item
	 */
@SuppressWarnings("unchecked")
private void updateSettingChart(String item, boolean checked, RGB seriesRgb, float width) {
    Color color = new Color(seriesRgb.red, seriesRgb.green, seriesRgb.blue);
    if (checked) {
        if (timeseriescollection.getSeries(item) == null) {
            timeseriescollection.addSeries(seriesMap.get(item));
        }
        List<TimeSeries> list = timeseriescollection.getSeries();
        for (int i = 0; i < list.size(); i++) {
            if (list.get(i).getKey().equals(item)) {
                xylineandshaperenderer.setSeriesPaint(i, color);
                xylineandshaperenderer.setSeriesStroke(i, new BasicStroke(width, 0, 2));
                break;
            }
        }
    } else {
        if (timeseriescollection.getSeries(item) != null) {
            timeseriescollection.removeSeries(seriesMap.get(item));
        }
    }
}
Also used : BasicStroke(java.awt.BasicStroke) TimeSeries(org.jfree.data.time.TimeSeries) Color(java.awt.Color) CommonUITool.trimPaintColor(com.cubrid.common.ui.spi.util.CommonUITool.trimPaintColor)

Example 12 with TimeSeries

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

the class MonitorStatisticChart method buildInvalidData.

/**
	 * Build TimeSeries for StatisticData which has no data. After build, each
	 * TimeSeries accompany with the StatisticData will have the same time
	 * series with ordinary TimeSeries, but all the values will be -1.
	 *
	 * @param dataset
	 * @param timeType
	 * @param dataItemWithoutDataList
	 * @param current
	 * @param interalMillisecs
	 */
private void buildInvalidData(TimeSeriesCollection dataset, TimeType timeType, List<StatisticData> dataItemWithoutDataList, Date current, long interalMillisecs) {
    for (StatisticData statisticData : dataItemWithoutDataList) {
        TimeSeries series = null;
        if (isDetailView) {
            series = new TimeSeries(statisticData.getDescription(isMultiHost));
        } else {
            series = new TimeSeries(statisticData.getSimpleDescription(isMultiHost));
        }
        Date point = (Date) current.clone();
        long curMillisecs = current.getTime();
        for (int i = 0; i < dataSize; i++) {
            point.setTime(curMillisecs - (dataSize - i) * interalMillisecs);
            switch(timeType) {
                case DAILY:
                    series.add(new Second(point), -1);
                    break;
                case WEEKLY:
                    series.add(new Hour(point), -1);
                    break;
                case MONTHLY:
                    series.add(new Hour(point), -1);
                    break;
                case YEARLY:
                    series.add(new Day(point), -1);
                    break;
                default:
                    break;
            }
        }
        maxValueMap.put(statisticData, -1d);
        minValueMap.put(statisticData, -1d);
        dataset.addSeries(series);
    }
}
Also used : TimeSeries(org.jfree.data.time.TimeSeries) Second(org.jfree.data.time.Second) Hour(org.jfree.data.time.Hour) Day(org.jfree.data.time.Day) StatisticData(com.cubrid.cubridmanager.core.monstatistic.model.StatisticData) Date(java.util.Date)

Example 13 with TimeSeries

use of org.jfree.data.time.TimeSeries in project pentaho-platform by pentaho.

the class TimeSeriesCollectionChartDefinition method setDataByColumn.

private void setDataByColumn(final IPentahoResultSet data) {
    // TODO Make this routine MDX friendly
    if (data == null) {
        // $NON-NLS-1$
        noDataMessage = Messages.getInstance().getString("CHART.USER_NO_DATA_AVAILABLE");
        // No data so we've got nothing to set
        return;
    // TODO come up with some sort of error strategy here.
    }
    boolean firstPass = true;
    // $NON-NLS-1$
    String lastSeries = "";
    // $NON-NLS-1$
    String seriesName = "";
    Class timePeriodClass = TimeSeriesCollectionChartDefinition.getTimePeriodClass(getDomainPeriodType());
    Object[] rowData = data.next();
    TimeSeries wrkSeries = null;
    while (rowData != null) {
        seriesName = (String) rowData[0];
        if (firstPass || !seriesName.equalsIgnoreCase(lastSeries)) {
            if (!firstPass) {
                addSeries(wrkSeries);
            }
            wrkSeries = new TimeSeries(seriesName, timePeriodClass);
            lastSeries = seriesName;
            firstPass = false;
        }
        Date keyDate = getValidDate(rowData[1]);
        RegularTimePeriod regularTimePeriod = RegularTimePeriod.createInstance(timePeriodClass, keyDate, RegularTimePeriod.DEFAULT_TIME_ZONE);
        TimeSeriesDataItem timeSeriesDataItem = new TimeSeriesDataItem(regularTimePeriod, ((Number) rowData[2]).doubleValue());
        if (wrkSeries != null) {
            wrkSeries.add(timeSeriesDataItem);
        }
        rowData = data.next();
    }
    if (!firstPass) {
        addSeries(wrkSeries);
    }
    if ((data.getRowCount() > 0) && (this.getSeriesCount() <= 0)) {
        // $NON-NLS-1$
        noDataMessage = Messages.getInstance().getString("CHART.USER_INCORRECT_DATA_FORMAT");
    }
}
Also used : TimeSeries(org.jfree.data.time.TimeSeries) TimeSeriesDataItem(org.jfree.data.time.TimeSeriesDataItem) RegularTimePeriod(org.jfree.data.time.RegularTimePeriod) Date(java.util.Date)

Example 14 with TimeSeries

use of org.jfree.data.time.TimeSeries in project spf4j by zolyfarkas.

the class Charts method createTimeSeriesCollection.

private static TimeSeriesCollection createTimeSeriesCollection(final String[] measurementNames, final long[] timestamps, final double[][] measurements) {
    TimeSeriesCollection timeseriescollection = new TimeSeriesCollection();
    for (int i = 0; i < measurementNames.length; i++) {
        TimeSeries tseries = new TimeSeries(measurementNames[i]);
        for (int j = 0; j < timestamps.length; j++) {
            FixedMillisecond ts = new FixedMillisecond(timestamps[j]);
            tseries.add(ts, measurements[i][j]);
        }
        timeseriescollection.addSeries(tseries);
    }
    return timeseriescollection;
}
Also used : TimeSeries(org.jfree.data.time.TimeSeries) FixedMillisecond(org.jfree.data.time.FixedMillisecond) TimeSeriesCollection(org.jfree.data.time.TimeSeriesCollection)

Example 15 with TimeSeries

use of org.jfree.data.time.TimeSeries in project spf4j by zolyfarkas.

the class Charts method createTimeSeriesCollection.

private static TimeSeriesCollection createTimeSeriesCollection(final String[] measurementNames, final long[][] timestamps, final double[][] measurements) {
    TimeSeriesCollection timeseriescollection = new TimeSeriesCollection();
    for (int i = 0; i < measurementNames.length; i++) {
        TimeSeries tseries = new TimeSeries(measurementNames[i]);
        for (int j = 0; j < timestamps[i].length; j++) {
            FixedMillisecond ts = new FixedMillisecond(timestamps[i][j]);
            tseries.add(ts, measurements[i][j]);
        }
        timeseriescollection.addSeries(tseries);
    }
    return timeseriescollection;
}
Also used : TimeSeries(org.jfree.data.time.TimeSeries) FixedMillisecond(org.jfree.data.time.FixedMillisecond) TimeSeriesCollection(org.jfree.data.time.TimeSeriesCollection)

Aggregations

TimeSeries (org.jfree.data.time.TimeSeries)53 TimeSeriesCollection (org.jfree.data.time.TimeSeriesCollection)37 XYPlot (org.jfree.chart.plot.XYPlot)11 Date (java.util.Date)10 JFreeChart (org.jfree.chart.JFreeChart)10 Month (org.jfree.data.time.Month)9 TimeSeriesDataItem (org.jfree.data.time.TimeSeriesDataItem)8 BasicStroke (java.awt.BasicStroke)7 Color (java.awt.Color)7 Map (java.util.Map)7 Day (org.jfree.data.time.Day)6 RegularTimePeriod (org.jfree.data.time.RegularTimePeriod)6 IOException (java.io.IOException)5 List (java.util.List)5 DateAxis (org.jfree.chart.axis.DateAxis)5 NumberAxis (org.jfree.chart.axis.NumberAxis)5 XYLineAndShapeRenderer (org.jfree.chart.renderer.xy.XYLineAndShapeRenderer)5 FixedMillisecond (org.jfree.data.time.FixedMillisecond)5 BufferedImage (java.awt.image.BufferedImage)4 SimpleDateFormat (java.text.SimpleDateFormat)4