use of com.github.mikephil.charting.data.CombinedData in project android-client by GenesisVision.
the class ProfitChartView method setChart.
public void setChart(List<Chart> charts) {
if (charts.isEmpty()) {
chart.clear();
return;
}
List<Entry> lineEntries = new ArrayList<>();
// List<BarEntry> barEntries = new ArrayList<>();
float index = 0;
for (Chart chart : charts) {
lineEntries.add(new Entry(index, chart.getTotalProfit().floatValue()));
// barEntries.add(new BarEntry(index, new float[]{
// chart.getManagerFund().floatValue() + chart.getInvestorFund().floatValue(),
// chart.getLoss().floatValue(),
// chart.getProfit().floatValue()}));
index++;
}
CombinedData data = new CombinedData();
data.setData(getLineData(lineEntries));
// data.setData(getBarData(barEntries));
chart.setData(data);
}
use of com.github.mikephil.charting.data.CombinedData in project MPAndroidChart by PhilJay.
the class CombinedChartActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_combined);
setTitle("CombinedChartActivity");
chart = findViewById(R.id.chart1);
chart.getDescription().setEnabled(false);
chart.setBackgroundColor(Color.WHITE);
chart.setDrawGridBackground(false);
chart.setDrawBarShadow(false);
chart.setHighlightFullBarEnabled(false);
// draw bars behind lines
chart.setDrawOrder(new DrawOrder[] { DrawOrder.BAR, DrawOrder.BUBBLE, DrawOrder.CANDLE, DrawOrder.LINE, DrawOrder.SCATTER });
Legend l = chart.getLegend();
l.setWordWrapEnabled(true);
l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
l.setDrawInside(false);
YAxis rightAxis = chart.getAxisRight();
rightAxis.setDrawGridLines(false);
// this replaces setStartAtZero(true)
rightAxis.setAxisMinimum(0f);
YAxis leftAxis = chart.getAxisLeft();
leftAxis.setDrawGridLines(false);
// this replaces setStartAtZero(true)
leftAxis.setAxisMinimum(0f);
XAxis xAxis = chart.getXAxis();
xAxis.setPosition(XAxisPosition.BOTH_SIDED);
xAxis.setAxisMinimum(0f);
xAxis.setGranularity(1f);
xAxis.setValueFormatter(new IAxisValueFormatter() {
@Override
public String getFormattedValue(float value, AxisBase axis) {
return months[(int) value % months.length];
}
});
CombinedData data = new CombinedData();
data.setData(generateLineData());
data.setData(generateBarData());
data.setData(generateBubbleData());
data.setData(generateScatterData());
data.setData(generateCandleData());
data.setValueTypeface(tfLight);
xAxis.setAxisMaximum(data.getXMax() + 0.25f);
chart.setData(data);
chart.invalidate();
}
use of com.github.mikephil.charting.data.CombinedData in project MPAndroidChart by PhilJay.
the class CombinedChartRenderer method drawHighlighted.
@Override
public void drawHighlighted(Canvas c, Highlight[] indices) {
Chart chart = mChart.get();
if (chart == null)
return;
for (DataRenderer renderer : mRenderers) {
ChartData data = null;
if (renderer instanceof BarChartRenderer)
data = ((BarChartRenderer) renderer).mChart.getBarData();
else if (renderer instanceof LineChartRenderer)
data = ((LineChartRenderer) renderer).mChart.getLineData();
else if (renderer instanceof CandleStickChartRenderer)
data = ((CandleStickChartRenderer) renderer).mChart.getCandleData();
else if (renderer instanceof ScatterChartRenderer)
data = ((ScatterChartRenderer) renderer).mChart.getScatterData();
else if (renderer instanceof BubbleChartRenderer)
data = ((BubbleChartRenderer) renderer).mChart.getBubbleData();
int dataIndex = data == null ? -1 : ((CombinedData) chart.getData()).getAllData().indexOf(data);
mHighlightBuffer.clear();
for (Highlight h : indices) {
if (h.getDataIndex() == dataIndex || h.getDataIndex() == -1)
mHighlightBuffer.add(h);
}
renderer.drawHighlighted(c, mHighlightBuffer.toArray(new Highlight[mHighlightBuffer.size()]));
}
}
Aggregations