use of org.swtchart.IBarSeries in project netxms by netxms.
the class PlotArea method paintControl.
/*
* @see PaintListener#paintControl(PaintEvent)
*/
public void paintControl(PaintEvent e) {
Point p = getSize();
final GC gc = e.gc;
// draw the plot area background
gc.setBackground(getBackground());
gc.fillRectangle(0, 0, p.x, p.y);
// draw grid
for (IAxis axis : chart.getAxisSet().getAxes()) {
((Grid) axis.getGrid()).draw(gc, p.x, p.y);
}
// draw behind series
for (ICustomPaintListener listener : paintListeners) {
if (listener.drawBehindSeries()) {
listener.paintControl(e);
}
}
// draw series. The line series should be drawn on bar series.
for (ISeries series : chart.getSeriesSet().getSeries()) {
if (series instanceof IBarSeries) {
((Series) series).draw(gc, p.x, p.y);
}
}
for (ISeries series : chart.getSeriesSet().getSeries()) {
if (series instanceof ILineSeries) {
((Series) series).draw(gc, p.x, p.y);
}
}
// draw over series
for (ICustomPaintListener listener : paintListeners) {
if (!listener.drawBehindSeries()) {
listener.paintControl(e);
}
}
}
use of org.swtchart.IBarSeries in project portfolio by buchen.
the class PerformanceChartSeriesBuilder method addClient.
private void addClient(DataSeries series, PerformanceIndex clientIndex, Aggregation.Period aggregationPeriod) {
PerformanceIndex index = aggregationPeriod != null ? Aggregation.aggregate(clientIndex, aggregationPeriod) : clientIndex;
switch((ClientDataSeries) series.getInstance()) {
case TOTALS:
ILineSeries lineSeries = getChart().addDateSeries(index.getDates(), index.getAccumulatedPercentage(), series.getLabel());
configure(series, lineSeries);
break;
case DELTA_PERCENTAGE:
String aggreagtionPeriodLabel = aggregationPeriod != null ? aggregationPeriod.toString() : Messages.LabelAggregationDaily;
IBarSeries barSeries = getChart().addDateBarSeries(index.getDates(), index.getDeltaPercentage(), aggreagtionPeriodLabel);
// update label, e.g. 'daily' to 'weekly'
series.setLabel(aggreagtionPeriodLabel);
configure(series, barSeries);
break;
default:
break;
}
}
use of org.swtchart.IBarSeries in project portfolio by buchen.
the class StatementOfAssetsSeriesBuilder method addClient.
private void addClient(DataSeries series, PerformanceIndex clientIndex) {
double[] values;
switch((ClientDataSeries) series.getInstance()) {
case TOTALS:
values = toDouble(clientIndex.getTotals(), Values.Amount.divider());
break;
case TRANSFERALS:
values = toDouble(clientIndex.getTransferals(), Values.Amount.divider());
break;
case INVESTED_CAPITAL:
values = toDouble(clientIndex.calculateInvestedCapital(), Values.Amount.divider());
break;
case ABSOLUTE_INVESTED_CAPITAL:
values = toDouble(clientIndex.calculateAbsoluteInvestedCapital(), Values.Amount.divider());
break;
case ABSOLUTE_DELTA:
values = toDouble(clientIndex.calculateDelta(), Values.Amount.divider());
break;
case ABSOLUTE_DELTA_ALL_RECORDS:
values = toDouble(clientIndex.calculateAbsoluteDelta(), Values.Amount.divider());
break;
case TAXES:
values = accumulateAndToDouble(clientIndex.getTaxes(), Values.Amount.divider());
break;
case DIVIDENDS:
values = toDouble(clientIndex.getDividends(), Values.Amount.divider());
break;
case DIVIDENDS_ACCUMULATED:
values = accumulateAndToDouble(clientIndex.getDividends(), Values.Amount.divider());
break;
case INTEREST:
values = toDouble(clientIndex.getInterest(), Values.Amount.divider());
break;
case INTEREST_ACCUMULATED:
values = accumulateAndToDouble(clientIndex.getInterest(), Values.Amount.divider());
break;
case INTEREST_CHARGE:
values = toDouble(clientIndex.getInterestCharge(), Values.Amount.divider());
break;
case INTEREST_CHARGE_ACCUMULATED:
values = accumulateAndToDouble(clientIndex.getInterestCharge(), Values.Amount.divider());
break;
default:
throw new IllegalArgumentException(String.valueOf(series.getInstance()));
}
if (series.isLineChart()) {
ILineSeries lineSeries = getChart().addDateSeries(clientIndex.getDates(), values, series.getLabel());
configure(series, lineSeries);
} else {
IBarSeries barSeries = getChart().addDateBarSeries(clientIndex.getDates(), values, series.getLabel());
configure(series, barSeries);
}
}
use of org.swtchart.IBarSeries in project portfolio by buchen.
the class DividendsPerYearChartTab method createSeries.
@Override
protected void createSeries() {
updateCategorySeries();
int startYear = model.getStartYear();
double[] series = new double[LocalDate.now().getYear() - startYear + 1];
for (int index = 0; index < model.getNoOfMonths(); index += 12) {
int year = (index / 12);
long total = 0;
int months = Math.min(12, model.getNoOfMonths() - index);
for (int ii = 0; ii < months; ii++) total += model.getSum().getValue(index + ii);
series[year] = total / Values.Amount.divider();
}
IBarSeries barSeries = (IBarSeries) getChart().getSeriesSet().createSeries(SeriesType.BAR, getLabel());
barSeries.setYSeries(series);
barSeries.setBarColor(Colors.DARK_BLUE);
}
Aggregations