use of javafx.scene.chart.XYChart.Series in project Gargoyle by callakrsos.
the class ScmCommitComposite method scmHistoryWalk.
private void scmHistoryWalk() throws SVNException {
List<GagoyleDate> periodDaysByWeek = DateUtil.getPeriodDaysByWeek(supplier.getWeekSize());
Collection<SVNLogEntry> allLogs = supplier.getAllLogs();
// supplier.createStream(allLogs);
TreeMap<String, Long> dayOfMonths = allLogs.stream().collect(Collectors.groupingBy(v -> FxSVNHistoryDataSupplier.YYYYMMDD_EEE_PATTERN.format(v.getDate()), () -> new TreeMap<>(), Collectors.counting()));
Map<String, Long> dayOfWeeks = new LinkedHashMap<>();
//초기값 세팅. [중요한건 정렬순서를 유지해아하므로. 초기값을 넣어준것.]
for (GagoyleDate d : DateUtil.getPeriodDaysByWeek()) {
String eee = FxSVNHistoryDataSupplier.EEE_PATTERN.format(d.toDate());
dayOfWeeks.put(eee, new Long(0));
}
//실제값 add
dayOfWeeks.putAll(allLogs.stream().collect(Collectors.groupingBy(v -> FxSVNHistoryDataSupplier.EEE_PATTERN.format(v.getDate()), Collectors.counting())));
{
BarChart<String, Long> barChartDayOfMonth = getBarChartDayOfMonth();
ObservableList<Data<String, Long>> convert = convert(FxSVNHistoryDataSupplier.YYYYMMDD_EEE_PATTERN, periodDaysByWeek, dayOfMonths, true);
Series<String, Long> series = new Series<>(SERIES_LABEL, convert);
barChartDayOfMonth.getData().add(series);
}
{
LineChart<String, Long> lineChartDayOfWeek = getLineChartDayOfWeek();
ObservableList<Data<String, Long>> convert = convert(FxSVNHistoryDataSupplier.EEE_PATTERN, DateUtil.getPeriodDaysByWeek(), dayOfWeeks, false);
Series<String, Long> series = new Series<>(SERIES_LABEL, convert);
lineChartDayOfWeek.getData().add(series);
}
}
use of javafx.scene.chart.XYChart.Series in project Gargoyle by callakrsos.
the class ScheduleTimeLineComposite method initialize.
@FXML
public void initialize() {
Monitors.addListener(this);
Main.addPrimaryStageCloseListener(this);
chartTimeLine.setVerticalGridLinesVisible(false);
ObservableList<Series<String, Number>> data = chartTimeLine.getData();
// allJvmProcessSeries = new Series<String, Number>();
// allJvmProcessSeries.setName("All JVM Process");
// data.add(allJvmProcessSeries);
passBatchProcessSeries = new Series<String, Number>();
passBatchProcessSeries.setName("Java Process");
data.add(passBatchProcessSeries);
// monitorService.setOnRunning(ev ->{
// System.err.println("running~~~~~~~~~~~~~~~~~~~");
// });
// monitorService.setOnScheduled(ev ->{
// System.err.println("service schedule.....");
// });
monitorService = new Service<Void>() {
@Override
protected Task<Void> createTask() {
return new Task<Void>() {
@Override
protected Void call() throws Exception {
Thread.sleep(1000);
String mmss = format.format(new Date());
updateMessage(mmss);
return null;
}
};
}
};
monitorService.messageProperty().addListener((oba, oldval, newval) -> {
if (newval == null || newval.isEmpty())
return;
ObservableList<Data<String, Number>> seriesData = passBatchProcessSeries.getData();
Data<String, Number> e = new Data<String, Number>(newval, Monitors.getActivedJavaProcessCount());
e.setNode(new Rectangle(1, 1));
seriesData.add(e);
if (seriesData.size() > CHART_SHOWING_ITEM_COUNT) {
seriesData.remove(0);
}
});
monitorService.setOnSucceeded(ev -> {
if (running.get()) {
monitorService.restart();
onTickTock();
}
});
monitorService.start();
}
use of javafx.scene.chart.XYChart.Series in project drbookings by DrBookings.
the class ProfitChartController method flushBin.
@Override
protected void flushBin() {
if (bin.isEmpty()) {
return;
}
final Optional<LocalDate> xValue = bin.stream().map(d -> d.getDate()).max((d1, d2) -> d1.compareTo(d2));
final Map<String, Number> yValue = new TreeMap<>();
final double costsToCover = getCostsToCover();
final double refColdRentLongTerm = getRefColdRentLongTerm();
for (final DateBean d : bin) {
for (final Entry<String, Number> e : d.getEarningsPerOrigin().entrySet()) {
double n = yValue.getOrDefault(e.getKey(), Double.valueOf(0)).doubleValue();
final double earnings = e.getValue().doubleValue();
final double sizeThis = 1;
final double sizeAll = allBookingEntries.get();
System.err.println(sizeThis);
System.err.println(sizeAll);
final double percent = sizeThis / sizeAll;
if (logger.isDebugEnabled()) {
logger.debug("percent: " + percent);
logger.debug("earnings: " + earnings);
logger.debug("costsToCover: " + (costsToCover * percent));
logger.debug("refColdRent: " + (refColdRentLongTerm * percent));
}
final double performance = (earnings - (costsToCover * percent) - (refColdRentLongTerm * percent));
n += performance / bin.size();
yValue.put(e.getKey(), n);
System.err.println("yValue: " + yValue);
}
}
for (final Entry<String, Number> e : yValue.entrySet()) {
// System.err.println("Entry " + e);
Series<String, Number> s = mapSeries.get(e.getKey());
if (s == null) {
s = new Series<>();
s.setName(e.getKey());
mapSeries.put(e.getKey(), s);
chart.getData().add(s);
}
final XYChart.Data<String, Number> data = new XYChart.Data<>(xValue.get().toString(), e.getValue());
categories.add(xValue.get().toString());
s.getData().add(data);
// System.err.println("Adding " + data);
}
bin.clear();
}
use of javafx.scene.chart.XYChart.Series in project drbookings by DrBookings.
the class EarningsPerDayChartViewController method flushBin.
@Override
protected void flushBin() {
if (bin.isEmpty()) {
return;
}
final LocalDate xValue = bin.stream().map(d -> d.getDate()).max((d1, d2) -> d1.compareTo(d2)).get();
final Map<String, Number> yValue = new TreeMap<>();
final int dayCnt = bin.stream().map(d -> d.getDate()).collect(Collectors.toSet()).size();
for (final BookingEntry d : bin) {
final String originName = d.getElement().getBookingOrigin().getName();
Number n = yValue.getOrDefault(originName, 0);
n = n.doubleValue() + d.getEarnings(SettingsManager.getInstance().isShowNetEarnings());
yValue.put(originName, n);
}
for (final Entry<String, Number> e : yValue.entrySet()) {
Series<String, Number> s = mapSeries.get(e.getKey());
if (s == null) {
s = new Series<>();
s.setName(e.getKey());
mapSeries.put(e.getKey(), s);
chart.getData().add(s);
}
Number value = e.getValue();
if (BinType.MEAN.equals(toggle.getSelectionModel().getSelectedItem())) {
if (dayCnt < 1) {
if (logger.isWarnEnabled()) {
logger.warn("Invalid data, day cnt: " + dayCnt + " for " + bin.stream().map(d -> d.getDate()).collect(Collectors.toSet()));
}
}
value = value.doubleValue() / dayCnt;
}
final XYChart.Data<String, Number> data = new XYChart.Data<>(xValue.toString(), value);
categories.add(xValue.toString());
s.getData().add(data);
}
if (logger.isDebugEnabled()) {
logger.debug(xValue + ": " + yValue);
}
bin.clear();
}
use of javafx.scene.chart.XYChart.Series in project Money-Manager by krHasan.
the class GetMoneyChart method getSourceData.
public static Series<String, Number> getSourceData(String monthName) {
XYChart.Series<String, Number> source = new XYChart.Series<>();
String[] allSource = new ComboboxList().getSourceListForDashboard();
for (String sourceName : allSource) {
if (!sourceName.equals("All")) {
if (sourceName.equals("Carried Over Amount")) {
String sourceShortName = getAbbreviateName(sourceName);
double amount = longToDouble(new CarriedOver().getCOAmount(monthName));
source.getData().add(new XYChart.Data<>(sourceShortName, amount));
} else {
String sourceShortName = getAbbreviateName(sourceName);
double amount = longToDouble(new Source().getAmountBySourceFromGM(monthName, sourceName));
source.getData().add(new XYChart.Data<>(sourceShortName, amount));
}
}
}
return source;
}
Aggregations