本文整理汇总了Java中com.github.mikephil.charting.data.LineData.getDataSetCount方法的典型用法代码示例。如果您正苦于以下问题:Java LineData.getDataSetCount方法的具体用法?Java LineData.getDataSetCount怎么用?Java LineData.getDataSetCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.data.LineData
的用法示例。
在下文中一共展示了LineData.getDataSetCount方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addEntry
import com.github.mikephil.charting.data.LineData; //导入方法依赖的package包/类
private void addEntry() {
LineData data = mChart.getData();
ILineDataSet set = data.getDataSetByIndex(0);
// set.addEntry(...); // can be called as well
if (set == null) {
set = createSet();
data.addDataSet(set);
}
// choose a random dataSet
int randomDataSetIndex = (int) (Math.random() * data.getDataSetCount());
float yValue = (float) (Math.random() * 10) + 50f;
data.addEntry(new Entry(data.getDataSetByIndex(randomDataSetIndex).getEntryCount(), yValue), randomDataSetIndex);
data.notifyDataChanged();
// let the chart know it's data has changed
mChart.notifyDataSetChanged();
mChart.setVisibleXRangeMaximum(6);
//mChart.setVisibleYRangeMaximum(15, AxisDependency.LEFT);
//
// // this automatically refreshes the chart (calls invalidate())
mChart.moveViewTo(data.getEntryCount() - 7, 50f, AxisDependency.LEFT);
}
示例2: addDataSet
import com.github.mikephil.charting.data.LineData; //导入方法依赖的package包/类
private void addDataSet() {
LineData data = mChart.getData();
if (data != null) {
int count = (data.getDataSetCount() + 1);
ArrayList<Entry> yVals = new ArrayList<Entry>();
for (int i = 0; i < data.getEntryCount(); i++) {
yVals.add(new Entry(i, (float) (Math.random() * 50f) + 50f * count));
}
LineDataSet set = new LineDataSet(yVals, "DataSet " + count);
set.setLineWidth(2.5f);
set.setCircleRadius(4.5f);
int color = mColors[count % mColors.length];
set.setColor(color);
set.setCircleColor(color);
set.setHighLightColor(color);
set.setValueTextSize(10f);
set.setValueTextColor(color);
data.addDataSet(set);
data.notifyDataChanged();
mChart.notifyDataSetChanged();
mChart.invalidate();
}
}
示例3: initBuffers
import com.github.mikephil.charting.data.LineData; //导入方法依赖的package包/类
@Override
public void initBuffers() {
LineData lineData = mChart.getLineData();
mLineBuffers = new LineBuffer[lineData.getDataSetCount()];
mCircleBuffers = new CircleBuffer[lineData.getDataSetCount()];
for (int i = 0; i < mLineBuffers.length; i++) {
ILineDataSet set = lineData.getDataSetByIndex(i);
mLineBuffers[i] = new LineBuffer(set.getEntryCount() * 4 - 4);
mCircleBuffers[i] = new CircleBuffer(set.getEntryCount() * 2);
}
}
示例4: addEntry
import com.github.mikephil.charting.data.LineData; //导入方法依赖的package包/类
private void addEntry() {
LineData data = mChart.getData();
if(data != null) {
ILineDataSet set = data.getDataSetByIndex(0);
// set.addEntry(...); // can be called as well
if (set == null) {
set = createSet();
data.addDataSet(set);
}
// add a new x-value first
data.addXValue(set.getEntryCount() + "");
// choose a random dataSet
int randomDataSetIndex = (int) (Math.random() * data.getDataSetCount());
data.addEntry(new Entry((float) (Math.random() * 10) + 50f, set.getEntryCount()), randomDataSetIndex);
// let the chart know it's data has changed
mChart.notifyDataSetChanged();
mChart.setVisibleXRangeMaximum(6);
mChart.setVisibleYRangeMaximum(15, AxisDependency.LEFT);
//
// // this automatically refreshes the chart (calls invalidate())
mChart.moveViewTo(data.getXValCount()-7, 50f, AxisDependency.LEFT);
}
}
示例5: addDataSet
import com.github.mikephil.charting.data.LineData; //导入方法依赖的package包/类
private void addDataSet() {
LineData data = mChart.getData();
if(data != null) {
int count = (data.getDataSetCount() + 1);
// create 10 y-vals
ArrayList<Entry> yVals = new ArrayList<Entry>();
if(data.getXValCount() == 0) {
// add 10 x-entries
for (int i = 0; i < 10; i++) {
data.addXValue("" + (i+1));
}
}
for (int i = 0; i < data.getXValCount(); i++) {
yVals.add(new Entry((float) (Math.random() * 50f) + 50f * count, i));
}
LineDataSet set = new LineDataSet(yVals, "DataSet " + count);
set.setLineWidth(2.5f);
set.setCircleRadius(4.5f);
int color = mColors[count % mColors.length];
set.setColor(color);
set.setCircleColor(color);
set.setHighLightColor(color);
set.setValueTextSize(10f);
set.setValueTextColor(color);
data.addDataSet(set);
mChart.notifyDataSetChanged();
mChart.invalidate();
}
}
示例6: initBuffers
import com.github.mikephil.charting.data.LineData; //导入方法依赖的package包/类
@Override
public void initBuffers() {
LineData lineData = mChart.getLineData();
mLineBuffers = new LineBuffer[lineData.getDataSetCount()];
mCircleBuffers = new CircleBuffer[lineData.getDataSetCount()];
for (int i = 0; i < mLineBuffers.length; i++) {
LineDataSet set = lineData.getDataSetByIndex(i);
mLineBuffers[i] = new LineBuffer(set.getEntryCount() * 4 - 4);
mCircleBuffers[i] = new CircleBuffer(set.getEntryCount() * 2);
}
}
示例7: populateDataForLanguage
import com.github.mikephil.charting.data.LineData; //导入方法依赖的package包/类
private LineChartItem populateDataForLanguage(@NonNull String language, Cursor cursor ){
LineData lineData;
List<Entry> seniors = new ArrayList<>();
List<Entry> engineer = new ArrayList<>();
List<Entry> juniors = new ArrayList<>();
cursor.moveToFirst();//set cursor up
for (int i = 0; i < cursor.getCount(); i++) {
cursor.moveToPosition(i);
String period = new DateTime(cursor.getLong(4))
.toString(Config.CHART_DATE_FORMAT, Locale.US);
if (language.equals(cursor.getString(1))){
if (Config.JOB_SOFT[0].equals(cursor.getString(0))){//senior software engineer
seniors.add(new Entry(AppUtils.getPeriodIndex(context, period),
(int) cursor.getFloat(2),
new SalaryData(period, (int) cursor.getFloat(3))));
}
if (Config.JOB_SOFT[1].equals(cursor.getString(0))){//software engineer
engineer.add(new Entry(AppUtils.getPeriodIndex(context, period),
(int) cursor.getFloat(2),
new SalaryData(period,(int) cursor.getFloat(3))));
}
if (Config.JOB_SOFT[2].equals(cursor.getString(0))){//juniors software engineer
juniors.add(new Entry(AppUtils.getPeriodIndex(context,period),
(int) cursor.getFloat(2),
new SalaryData(period,(int) cursor.getFloat(3))));
}
// QA
if (language.isEmpty() ){
if (Config.JOB_QA[0].equals(cursor.getString(0))) {//senior QA
seniors.add(new Entry(AppUtils.getPeriodIndex(context, period),
(int) cursor.getFloat(2),
new SalaryData(period, (int) cursor.getFloat(3))));
}
if (Config.JOB_QA[1].equals(cursor.getString(0))) {//engineer QA
engineer.add(new Entry(AppUtils.getPeriodIndex(context, period),
(int) cursor.getFloat(2),
new SalaryData(period, (int) cursor.getFloat(3))));
}
if (Config.JOB_QA[2].equals(cursor.getString(0))) {//juniors QA
juniors.add(new Entry(AppUtils.getPeriodIndex(context, period),
(int) cursor.getFloat(2),
new SalaryData(period, (int) cursor.getFloat(3))));
}
}
}
if (language.equals(Config.MANAGER)) { //Management
if (Config.JOB_MANAGER[0].equals(cursor.getString(0))) {//Senior Project Manager/PM
seniors.add(new Entry(AppUtils.getPeriodIndex(context, period),
(int) cursor.getFloat(2),
new SalaryData(period, (int) cursor.getFloat(3))));
}
if (Config.JOB_MANAGER[1].equals(cursor.getString(0))) {//Team lead
engineer.add(new Entry(AppUtils.getPeriodIndex(context, period),
(int) cursor.getFloat(2),
new SalaryData(period, (int) cursor.getFloat(3))));
}
if (Config.JOB_MANAGER[2].equals(cursor.getString(0))) {//Project manager
juniors.add(new Entry(AppUtils.getPeriodIndex(context, period),
(int) cursor.getFloat(2),
new SalaryData(period, (int) cursor.getFloat(3))));
}
}
}
switch (language) {
case "":
language = Config.QA;
lineData = buildLineData(seniors, engineer, juniors, Config.JOB_QA);
break;
case Config.MANAGER:
language = Config.MANAGER;
lineData = buildLineData(seniors, engineer, juniors, Config.JOB_MANAGER);
break;
default:
lineData = buildLineData(seniors, engineer, juniors, Config.JOB_SOFT);
break;
}
if (lineData.getDataSetCount() > 0) {
return new LineChartItem(context, lineData, language);
}
return null;
}
示例8: drawHighlighted
import com.github.mikephil.charting.data.LineData; //导入方法依赖的package包/类
@Override
public void drawHighlighted(Canvas c, Highlight[] indices) {
LineData lineData = mChart.getLineData();
for (Highlight high : indices) {
final int minDataSetIndex = high.getDataSetIndex() == -1
? 0
: high.getDataSetIndex();
final int maxDataSetIndex = high.getDataSetIndex() == -1
? lineData.getDataSetCount()
: (high.getDataSetIndex() + 1);
if (maxDataSetIndex - minDataSetIndex < 1) continue;
for (int dataSetIndex = minDataSetIndex;
dataSetIndex < maxDataSetIndex;
dataSetIndex++) {
ILineDataSet set = lineData.getDataSetByIndex(dataSetIndex);
if (set == null || !set.isHighlightEnabled())
continue;
int xIndex = high.getXIndex(); // get the
// x-position
if (xIndex > mChart.getXChartMax() * mAnimator.getPhaseX())
continue;
final float yVal = set.getYValForXIndex(xIndex);
if (Float.isNaN(yVal))
continue;
float y = yVal * mAnimator.getPhaseY(); // get
// the
// y-position
float[] pts = new float[]{
xIndex, y
};
mChart.getTransformer(set.getAxisDependency()).pointValuesToPixel(pts);
// draw the lines
drawHighlightLines(c, pts, set);
}
}
}