本文整理汇总了Java中com.github.mikephil.charting.data.CombinedData.setData方法的典型用法代码示例。如果您正苦于以下问题:Java CombinedData.setData方法的具体用法?Java CombinedData.setData怎么用?Java CombinedData.setData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.data.CombinedData
的用法示例。
在下文中一共展示了CombinedData.setData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildDummyDataForLegend
import com.github.mikephil.charting.data.CombinedData; //导入方法依赖的package包/类
/**
* Create dataset to be displayed in chart legend
* @return CombinedData representing dummy data for a legend
*/
private CombinedData buildDummyDataForLegend(){
CombinedData combinedData = new CombinedData();
float xIndex = 1.5f;
float close = 13;
float open = 26f;
float shadowH = 30.33f;
float shadowL = -2.05f;
float average = 20f;
CandleData candleData = generateCandleData(xIndex, shadowH, shadowL, open, close, "EMU HI/LO" );
ScatterData scatterData = generateScatterData(average, "EMU Mean");
LineData s1 = generateOceanHiLo(close, open, "Ocean HI/LO");
combinedData.setData(s1);
combinedData.setData(candleData);
combinedData.setData(scatterData);
return combinedData;
}
示例2: buildTempData
import com.github.mikephil.charting.data.CombinedData; //导入方法依赖的package包/类
/**
* Build a CombinedData object containing temperature data
* @param observation - EMUObservation
* @param stat - EMUStat
* @return - CombinedData
*/
private CombinedData buildTempData(EMUObservation observation, EMUStat stat){
CombinedData combinedData = new CombinedData();
if (stat.getTemp_max() == null || stat.getTemp_min() == null || stat.getTemp_mean() == null || observation.getTemperature() == null){
return combinedData;
}
float xIndex = 1.5f;
float close = (float) stat.getTemp_min().doubleValue();
float open = (float) stat.getTemp_max().doubleValue();
float shadowH = (float)mDataManager.getMaxTemperatureFromSummary().doubleValue(); // 30.33f; // Greatest max temp from summary table
float shadowL = (float) mDataManager.getMinTemperatureFromSummary().doubleValue(); // -2.05f; // Lowest min temp from summary table
float averageTemp = (float)observation.getTemperature().doubleValue();
Log.i("SummaryChartPresenter", "Temperature: Ocean high = " + shadowH + " ocean low = "+ shadowL + " emu min = " + close + " emu max = "+ open + " emu mean for location = "+ averageTemp);
combinedData.setData(generateCandleData(xIndex, shadowH, shadowL, open, close, TEMPERATURE ));
ScatterData sdata = generateScatterData(averageTemp, TEMPERATURE);
combinedData.setData(sdata);
return combinedData;
}
示例3: buildSalinityData
import com.github.mikephil.charting.data.CombinedData; //导入方法依赖的package包/类
/**
* Build a CombinedData object containing salinity data
* @param observation - EMUObservation
* @param stat - EMUStat
* @return - CombinedData
*/
private CombinedData buildSalinityData(EMUObservation observation, EMUStat stat){
CombinedData combinedData = new CombinedData();
if (stat.getSalinity_max() == null || stat.getSalinity_min() == null || stat.getSalinity_mean() == null || observation.getSalinity() == null){
return combinedData;
}
float xIndex = 1.5f;
float close = (float) stat.getSalinity_min().doubleValue();
float open = (float) stat.getSalinity_max().doubleValue();
float shadowH = (float)mDataManager.getMaxSalinityFromSummary().doubleValue();
float shadowL = (float) mDataManager.getMinSalinityFromSummary().doubleValue();
float avgSalinity = (float)observation.getSalinity().doubleValue();
Log.i("SummaryChartPreseter", "Salinity: Ocean high = " + shadowH + " ocean low = "+ shadowL + " emu min = " + close + " emu max = "+ open + " emu mean for location = "+ avgSalinity);
combinedData.setData(generateCandleData(xIndex, shadowH, shadowL, open, close, SALINITY ));
combinedData.setData(generateScatterData(avgSalinity, SALINITY));
return combinedData;
}
示例4: buildOxygenData
import com.github.mikephil.charting.data.CombinedData; //导入方法依赖的package包/类
/**
* Build a CombinedData object containing oxygen data
* @param observation - EMUObservation
* @param stat - EMUStat
* @return - CombinedData
*/
private CombinedData buildOxygenData(EMUObservation observation, EMUStat stat){
CombinedData combinedData = new CombinedData();
if (stat.getDisso2_max() == null || stat.getDisso2_min() == null || stat.getDisso2_mean() == null || observation.getOxygen() == null){
return combinedData;
}
float xIndex = 1.5f;
float close = (float) stat.getDisso2_min().doubleValue();
float open = (float) stat.getDisso2_max().doubleValue();
float shadowH = (float)mDataManager.getMaxOxygenFromSummary().doubleValue();
float shadowL = (float) mDataManager.getMinOxygenFromSummary().doubleValue();
float averageOx = (float)observation.getOxygen().doubleValue();
Log.i("SummaryChartPreseter", "Oxygen: Ocean high = " + shadowH + " ocean low = "+ shadowL + " emu min = " + close + " emu max = "+ open + " emu mean for location = "+ averageOx);
combinedData.setData(generateCandleData(xIndex, shadowH, shadowL, open, close, OXYGEN ));
combinedData.setData(generateScatterData(averageOx, OXYGEN));
return combinedData;
}
示例5: buildPhosphateData
import com.github.mikephil.charting.data.CombinedData; //导入方法依赖的package包/类
/**
* Build a CombinedData object containing phosphate data
* @param observation - EMUObservation
* @param stat - EMUStat
* @return - CombinedData
*/
private CombinedData buildPhosphateData(EMUObservation observation, EMUStat stat){
CombinedData combinedData = new CombinedData();
if (stat.getPhosphate_max() == null || stat.getPhosphate_min() == null || stat.getPhosphate_mean() == null || observation.getPhosphate() == null){
return combinedData;
}
float xIndex = 1.5f;
float close = (float) stat.getPhosphate_min().doubleValue();
float open = (float) stat.getPhosphate_max().doubleValue();
float shadowH = (float)mDataManager.getMaxPhosphateFromSummary().doubleValue();
float shadowL = (float) mDataManager.getMinPhosphateFromSummary().doubleValue();
float averagePhos = (float)observation.getPhosphate().doubleValue();
Log.i("SummaryChartPreseter", "Phosphate: Ocean high = " + shadowH + " ocean low = "+ shadowL + " emu min = " + close + " emu max = "+ open + " emu mean for location = "+ averagePhos);
combinedData.setData(generateCandleData(xIndex, shadowH, shadowL, open, close, PHOSPHATE ));
combinedData.setData(generateScatterData(averagePhos, PHOSPHATE));
return combinedData;
}
示例6: buildSilicateData
import com.github.mikephil.charting.data.CombinedData; //导入方法依赖的package包/类
/**
* Build a CombinedData object containing silicate data
* @param observation - EMUObservation
* @param stat - EMUStat
* @return - CombinedData
*/
private CombinedData buildSilicateData(EMUObservation observation, EMUStat stat){
CombinedData combinedData = new CombinedData();
if (stat.getSilicate_max() == null || stat.getSilicate_min() == null || stat.getSilicate_mean() == null || observation.getSilicate() == null){
return combinedData;
}
float xIndex = 1.5f;
float close = (float) stat.getSilicate_min().doubleValue();
float open = (float) stat.getSilicate_max().doubleValue();
float shadowH = (float)mDataManager.getMaxSilicateFromSummary().doubleValue();
float shadowL = (float) mDataManager.getMinSilicateFromSummary().doubleValue();
float averageSil = (float)observation.getSilicate().doubleValue();
Log.i("SummaryChartPreseter", "Silicate: Ocean high = " + shadowH + " ocean low = "+ shadowL + " emu min = " + close + " emu max = "+ open + " emu mean for location = "+ averageSil);
combinedData.setData(generateCandleData(xIndex, shadowH, shadowL, open, close, SILICATE ));
combinedData.setData(generateScatterData(averageSil, SILICATE));
return combinedData;
}
示例7: buildNitrateData
import com.github.mikephil.charting.data.CombinedData; //导入方法依赖的package包/类
/**
* Build a CombinedData object containing nitrate data
* @param observation - EMUObservation
* @param stat - EMUStat
* @return - CombinedData
*/
private CombinedData buildNitrateData(EMUObservation observation, EMUStat stat){
CombinedData combinedData = new CombinedData();
if (stat.getNitrate_min() == null || stat.getNitrate_max() == null || stat.getNitrate_mean() == null || observation.getNitrate() == null){
return combinedData;
}
float xIndex = 1.5f;
float close = (float) stat.getNitrate_min().doubleValue();
float open = (float) stat.getNitrate_max().doubleValue();
float shadowH = (float)mDataManager.getMaxNitrateFromSummary().doubleValue();
float shadowL = (float) mDataManager.getMinNitrateFromSummary().doubleValue();
float averageN = (float)observation.getNitrate().doubleValue();
Log.i("SummaryChartPreseter", "Nitrate: Ocean high = " + shadowH + " ocean low = "+ shadowL + " emu min = " + close + " emu max = "+ open + " emu mean for location = "+ averageN);
combinedData.setData(generateCandleData(xIndex, shadowH, shadowL, open, close, NITRATE ));
combinedData.setData(generateScatterData(averageN, NITRATE));
return combinedData;
}
示例8: onCreate
import com.github.mikephil.charting.data.CombinedData; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_combined);
mChart = (CombinedChart) findViewById(R.id.chart1);
mChart.setDescription("");
mChart.setBackgroundColor(Color.WHITE);
mChart.setDrawGridBackground(false);
mChart.setDrawBarShadow(false);
// draw bars behind lines
mChart.setDrawOrder(new DrawOrder[] {
DrawOrder.BAR, DrawOrder.BUBBLE, DrawOrder.CANDLE, DrawOrder.LINE, DrawOrder.SCATTER
});
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setDrawGridLines(false);
rightAxis.setAxisMinValue(0f); // this replaces setStartAtZero(true)
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setDrawGridLines(false);
leftAxis.setAxisMinValue(0f); // this replaces setStartAtZero(true)
XAxis xAxis = mChart.getXAxis();
xAxis.setPosition(XAxisPosition.BOTH_SIDED);
CombinedData data = new CombinedData(mMonths);
data.setData(generateLineData());
data.setData(generateBarData());
// data.setData(generateBubbleData());
// data.setData(generateScatterData());
// data.setData(generateCandleData());
mChart.setData(data);
mChart.invalidate();
}
示例9: createLineAndBarData
import com.github.mikephil.charting.data.CombinedData; //导入方法依赖的package包/类
private CombinedData createLineAndBarData(List<String> xLabels, List<Entry> lineEntries, List<BarEntry> barEntries) {
final CombinedData combinedData = createLineData(xLabels, lineEntries);
if (combinedData != null) {
combinedData.setData(getBarData(xLabels, barEntries));
}
return combinedData;
}
示例10: createLineData
import com.github.mikephil.charting.data.CombinedData; //导入方法依赖的package包/类
private CombinedData createLineData(final List<String> xLabels, final List<Entry> lineEntries) {
if (isCancelled()) {
return null;
} else {
final CombinedData combinedData = new CombinedData(xLabels);
combinedData.setData(getLineData(xLabels, lineEntries));
return combinedData;
}
}
示例11: refreshWeekBeforeSteps
import com.github.mikephil.charting.data.CombinedData; //导入方法依赖的package包/类
private DefaultChartsData refreshWeekBeforeSteps(DBHandler db, CombinedChart combinedChart, Calendar day, GBDevice device) {
ActivityAnalysis analysis = new ActivityAnalysis();
day = (Calendar) day.clone(); // do not modify the caller's argument
day.add(Calendar.DATE, -7);
List<BarEntry> entries = new ArrayList<>();
List<String> labels = new ArrayList<>();
for (int counter = 0; counter < 7; counter++) {
entries.add(new BarEntry(analysis.calculateTotalSteps(getSamplesOfDay(db, day, device)), counter));
labels.add(day.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, mLocale));
day.add(Calendar.DATE, 1);
}
BarDataSet set = new BarDataSet(entries, "");
set.setColor(akActivity.color);
BarData barData = new BarData(labels, set);
barData.setValueTextColor(Color.GRAY); //prevent tearing other graph elements with the black text. Another approach would be to hide the values cmpletely with data.setDrawValues(false);
LimitLine target = new LimitLine(mTargetSteps);
combinedChart.getAxisLeft().removeAllLimitLines();
combinedChart.getAxisLeft().addLimitLine(target);
CombinedData combinedData = new CombinedData(labels);
combinedData.setData(barData);
return new DefaultChartsData(combinedData);
}
示例12: onCreate
import com.github.mikephil.charting.data.CombinedData; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_combined);
mChart = (CombinedChart) findViewById(R.id.chart1);
mChart.getDescription().setEnabled(false);
mChart.setBackgroundColor(Color.WHITE);
mChart.setDrawGridBackground(false);
mChart.setDrawBarShadow(false);
mChart.setHighlightFullBarEnabled(false);
// draw bars behind lines
mChart.setDrawOrder(new DrawOrder[]{
DrawOrder.BAR, DrawOrder.BUBBLE, DrawOrder.CANDLE, DrawOrder.LINE, DrawOrder.SCATTER
});
Legend l = mChart.getLegend();
l.setWordWrapEnabled(true);
l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
l.setDrawInside(false);
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setDrawGridLines(false);
rightAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setDrawGridLines(false);
leftAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)
XAxis xAxis = mChart.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 mMonths[(int) value % mMonths.length];
}
});
CombinedData data = new CombinedData();
data.setData(generateLineData());
data.setData(generateBarData());
data.setData(generateBubbleData());
data.setData(generateScatterData());
data.setData(generateCandleData());
data.setValueTypeface(mTfLight);
xAxis.setAxisMaximum(data.getXMax() + 0.25f);
mChart.setData(data);
mChart.invalidate();
}
示例13: initChart
import com.github.mikephil.charting.data.CombinedData; //导入方法依赖的package包/类
protected void initChart() {
mCombinedChart.getDescription().setEnabled(false);
mCombinedChart.setBackgroundColor(Color.WHITE);
mCombinedChart.setDrawGridBackground(false);
mCombinedChart.setDrawBarShadow(false);
mCombinedChart.setHighlightFullBarEnabled(false);
// draw bars behind lines
mCombinedChart.setDrawOrder(new CombinedChart.DrawOrder[]{
CombinedChart.DrawOrder.BAR, CombinedChart.DrawOrder.BUBBLE,
CombinedChart.DrawOrder.CANDLE, CombinedChart.DrawOrder.LINE,
CombinedChart.DrawOrder.SCATTER
});
Legend l = mCombinedChart.getLegend();
l.setWordWrapEnabled(true);
l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
l.setDrawInside(false);
YAxis rightAxis = mCombinedChart.getAxisRight();
rightAxis.setDrawGridLines(false);
rightAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)
YAxis leftAxis = mCombinedChart.getAxisLeft();
leftAxis.setDrawGridLines(false);
leftAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)
XAxis xAxis = mCombinedChart.getXAxis();
xAxis.setPosition(XAxis.XAxisPosition.BOTH_SIDED);
xAxis.setAxisMinimum(0f);
xAxis.setGranularity(1f);
xAxis.setValueFormatter(new IAxisValueFormatter() {
@Override
public String getFormattedValue(float value, AxisBase axis) {
return mMonths[(int) value % mMonths.length];
}
});
CombinedData data = new CombinedData();
data.setData(generateLineData());
data.setData(generateBarData());
data.setData(generateBubbleData());
data.setData(generateScatterData());
data.setData(generateCandleData());
//data.setValueTypeface(mTfLight);
xAxis.setAxisMaximum(data.getXMax() + 0.25f);
mCombinedChart.setData(data);
mCombinedChart.invalidate();
}
示例14: initChart
import com.github.mikephil.charting.data.CombinedData; //导入方法依赖的package包/类
/**
* 初始化报表
*
* @param showAnimation 是否显示动画
*/
void initChart(boolean showAnimation) {
int screenWidth = Utils.getScreenWidth(mContext);
combinedChart.getLayoutParams().height = screenWidth * 300 / 640;
//启用缩放和拖动
combinedChart.setDragEnabled(true);//拖动
combinedChart.setScaleEnabled(false);//缩放
combinedChart.setOnChartValueSelectedListener(this);
combinedChart.getDescription().setEnabled(false);
combinedChart.setBackgroundColor(ContextCompat.getColor(mContext, R.color.co10));
combinedChart.setDrawGridBackground(false);
combinedChart.setDrawBarShadow(false);
combinedChart.setHighlightFullBarEnabled(false);
Legend l = combinedChart.getLegend();
l.setForm(Legend.LegendForm.NONE);//底部样式
l.setTextColor(ContextCompat.getColor(mContext, R.color.transparent));
l.setWordWrapEnabled(false);
l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
l.setDrawInside(false);
YAxis rightAxis = combinedChart.getAxisRight();
rightAxis.setEnabled(false);
YAxis leftAxis = combinedChart.getAxisLeft();
leftAxis.setDrawGridLines(false);
leftAxis.setGranularityEnabled(false);
leftAxis.setDrawAxisLine(false);
leftAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)
leftAxis.setTextColor(ContextCompat.getColor(mContext, R.color.co4));
updateTitle(items.get(dateSelected));
XAxis xAxis = combinedChart.getXAxis();
xAxis.setTypeface(mTfLight);
xAxis.setEnabled(true);//设置轴启用或禁用 如果禁用以下的设置全部不生效
xAxis.setDrawAxisLine(true);//是否绘制轴线
xAxis.setDrawGridLines(false);//设置x轴上每个点对应的线
xAxis.setDrawLabels(true);//绘制标签 指x轴上的对应数值
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);//设置x轴的显示位置
xAxis.setTextSize(10f); //设置X轴文字大小
xAxis.setGranularityEnabled(true);//是否允许X轴上值重复出现
xAxis.setTextColor(ContextCompat.getColor(this, R.color.co4));//设置X轴文字颜色
// //设置竖线的显示样式为虚线
// //lineLength控制虚线段的长度
// //spaceLength控制线之间的空间
xAxis.enableGridDashedLine(10f, 10f, 0f);
xAxis.setAxisMinimum(0f);//设置x轴的最小值
xAxis.setAxisMaximum(mDatas.length);//设置最大值
xAxis.setAvoidFirstLastClipping(true);//图表将避免第一个和最后一个标签条目被减掉在图表或屏幕的边缘
xAxis.setLabelRotationAngle(0f);//设置x轴标签字体的旋转角度
// 设置x轴显示标签数量 还有一个重载方法第二个参数为布尔值强制设置数量 如果启用会导致绘制点出现偏差
xAxis.setLabelCount(10);
xAxis.setGridLineWidth(10f);//设置竖线大小
// xAxis.setGridColor(Color.RED);//设置竖线颜色
xAxis.setAxisLineColor(Color.GRAY);//设置x轴线颜色
xAxis.setAxisLineWidth(1f);//设置x轴线宽度
CombinedData combinedData = new CombinedData();
combinedData.setData(generateLineData());
combinedData.setData(generateBarData());
combinedData.setValueTypeface(mTfLight);
xAxis.setAxisMaximum(combinedData.getXMax() + 0.25f);
//X轴的数据格式
ValueFormatter xAxisFormatter = new ValueFormatter(combinedChart);
xAxisFormatter.setmValues(xAxisValue);
xAxis.setValueFormatter(xAxisFormatter);//格式化x轴标签显示字符
combinedChart.setData(combinedData);
combinedChart.invalidate();
if (showAnimation) {
combinedChart.animateY(2000);
}
}
示例15: onCreate
import com.github.mikephil.charting.data.CombinedData; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mChart = (CombinedChart) findViewById(R.id.chart1);
//描述
mChart.getDescription().setEnabled(false);
mChart.setBackgroundColor(Color.WHITE);
mChart.setDrawGridBackground(false);
mChart.setDrawBarShadow(false);
mChart.setHighlightFullBarEnabled(false);
mChart.setScaleEnabled(false);
mChart.setScaleYEnabled(false);
mChart.setScaleXEnabled(false);
mChart.setPinchZoom(false);
// mChart.setScaleMinima(2f, 1f);
// mChart.setAutoScaleMinMaxEnabled(true);
// draw bars behind lines
mChart.setDrawOrder(new CombinedChart.DrawOrder[]{
CombinedChart.DrawOrder.BAR
});
//图例
Legend l = mChart.getLegend();
l.setWordWrapEnabled(true);
l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
l.setDrawInside(false);
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setEnabled(false);
rightAxis.setAxisMinimum(0f);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setEnabled(false);
leftAxis.setAxisMinimum(0f);
XAxis xAxis = mChart.getXAxis();
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setDrawGridLines(false);
// xAxis.setAvoidFirstLastClipping(true);
xAxis.setAxisMinimum(0.5f);
xAxis.setGranularity(1f);
xAxis.setValueFormatter(new IAxisValueFormatter() {
@Override
public String getFormattedValue(float value, AxisBase axis) {
if (value % 1 == 0&&value>=1) {
return mMonths[(int) value % mMonths.length-1];
} else {
return "";
}
}
});
CombinedData data = new CombinedData();
data.setData(generateBarData(1f, 1f));
xAxis.setAxisMaximum(data.getXMax() + 0.25f);
mChart.setData(data);
mChart.setVisibleXRange(3, 5);
mChart.setExtraOffsets(10, 0, 0, 0);
mChart.invalidate();
}