use of org.jfree.data.time.Millisecond in project GT by Tencent.
the class APTLogFileParse method getData.
public static JfreeChartDatas getData(String fileName, APTLogFileHeader afh) {
if (afh == null) {
return null;
}
JfreeChartDatas result = new JfreeChartDatas();
int pkgNumber = afh.pkgNames.length;
int dataItemCount = afh.dataItems.length;
result.pkgNames = new String[pkgNumber];
//取进程名的后缀
for (int i = 0; i < pkgNumber; i++) {
int index = afh.pkgNames[i].lastIndexOf(".");
;
if (index == -1) {
index = 0;
}
result.pkgNames[i] = afh.pkgNames[i].substring(index + 1, afh.pkgNames[i].length());
}
result.monitorItem = afh.monitorItem;
result.dataItems = new String[dataItemCount];
System.arraycopy(afh.dataItems, 0, result.dataItems, 0, dataItemCount);
result.tsDataList = new ArrayList<TSData>();
for (int i = 0; i < pkgNumber * dataItemCount; i++) {
TSData tsData = new TSData();
result.tsDataList.add(tsData);
}
FileReader fr = null;
BufferedReader br = null;
try {
fr = new FileReader(fileName);
br = new BufferedReader(fr);
String line = "";
for (int i = 0; i < 3; i++) {
br.readLine();
}
Date lastDate = null;
while ((line = br.readLine()) != null) {
String[] datas = line.split(Constant.APTLOG_FILECONTENT_SPLIT);
if (datas == null || datas.length != pkgNumber * dataItemCount + 1) {
continue;
}
Date date = Constant.SIMPLE_DATE_FORMAT_MILLISECOND.parse(datas[0]);
/**
* 过滤相同时间点的数据
*/
if (date.equals(lastDate)) {
continue;
}
lastDate = date;
RegularTimePeriod time = new Millisecond(date);
for (int i = 0; i < pkgNumber * dataItemCount; i++) {
float value = Float.parseFloat(datas[i + 1]);
DataUnit du = new DataUnit(time, value);
result.tsDataList.get(i).dataUnitList.add(du);
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
fr.close();
br.close();
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
return result;
}
use of org.jfree.data.time.Millisecond in project GT by Tencent.
the class AbstractRealTimeLineChart method update.
/**
* 仅仅更新所有进程的某一种数据
* @Title: update
* @Description:
* @param time
* @param dataIndex
* @param datas
* void
* @throws
*/
public void update(Date time, int dataIndex, Number[] datas) {
for (int i = 0; i < objectNum; i++) {
int index = i * dataNum + dataIndex;
tsList.get(index).add(new Millisecond(), datas[i]);
}
}
use of org.jfree.data.time.Millisecond in project cubrid-manager by CUBRID.
the class StatusMonitorViewPart method addMaxObservation.
/**
* Adds the maximum value observation
*
* @param dval int[]
*/
private void addMaxObservation(int[] dval) {
for (int i = 0; i < numChart; i++) {
maximum[i].add(new Millisecond(), dval[i]);
maxTxt[i].setText(Integer.toString(dval[i]));
}
}
use of org.jfree.data.time.Millisecond in project logprocessing by cloudian.
the class GeminiChartUtil method createReport.
public void createReport(OutputStream out, List<ChartSeries> chartData, String strTitle, String strDomainAxisLabel) {
strDomainAxisLabel = "Time Interval: " + strDomainAxisLabel;
String strYAxisLabel;
//String strCategoryType = " ";
strYAxisLabel = "Count";
//SimpleDateFormat sdf = new SimpleDateFormat("MMMM-dd hh:mm a");
//build a dataset as needed by JFreeChart
// note: strCategoryType is for a chart with multiple categories.
// i.e. idisplay multiple bars for each time interval.
//
TimeSeriesCollection dataSet = new TimeSeriesCollection();
// For each series of data, create a TimeSeries
for (int i = 0; i < chartData.size(); i++) {
ChartSeries chartSeries = chartData.get(i);
TimeSeries timeSeries = new TimeSeries(chartSeries.getName(), Millisecond.class);
List<ChartValueByTime> data = chartSeries.getData();
//int cumulValue = 0;
for (int j = 0; j < data.size(); j++) {
ChartValueByTime chartVal = data.get(j);
Millisecond ms = new Millisecond(new Date(chartVal.getTime()));
// *NOT* Store the cumulative value . So maintain a running total.
//cumulValue += chartVal.getValue();
//timeSeries.add(ms, cumulValue);
timeSeries.add(ms, chartVal.getValue());
}
dataSet.addSeries(timeSeries);
}
JFreeChart lineChart = ChartFactory.createTimeSeriesChart(// chart title
strTitle, // domain axis label
strDomainAxisLabel, // range axis label
strYAxisLabel, // data
dataSet, // legend
true, // tooltips
false, // urls
false);
try {
ChartUtilities.writeChartAsPNG(out, lineChart, 800, 400);
} catch (IOException e) {
e.printStackTrace();
}
}
use of org.jfree.data.time.Millisecond in project pinot by linkedin.
the class AnomalyGraphGenerator method createTimeSeries.
/**
* Returns data with series 0 = current and 1 = baseline. This method assumes there is exactly one
* metric in the response data.
*/
private TimeSeriesCollection createTimeSeries(final TimeOnTimeComparisonResponse data) {
final TimeSeries baseline = new TimeSeries(BASELINE_LABEL);
final TimeSeries current = new TimeSeries(CURRENT_LABEL);
for (int i = 0; i < data.getNumRows(); i++) {
Row row = data.getRow(i);
// Plot the baseline data as an overlay on the corresponding current data point.
// long baselineStart = row.getBaselineStart().getMillis();
long currentStart = row.getCurrentStart().getMillis();
Date date = new Date(currentStart);
RegularTimePeriod timePeriod = new Millisecond(date);
Metric metric = row.getMetrics().get(0);
baseline.add(timePeriod, metric.getBaselineValue());
current.add(timePeriod, metric.getCurrentValue());
}
final TimeSeriesCollection dataset = new TimeSeriesCollection();
dataset.addSeries(current);
dataset.addSeries(baseline);
return dataset;
}
Aggregations