本文整理汇总了Java中com.github.mikephil.charting.interfaces.datasets.IDataSet类的典型用法代码示例。如果您正苦于以下问题:Java IDataSet类的具体用法?Java IDataSet怎么用?Java IDataSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IDataSet类属于com.github.mikephil.charting.interfaces.datasets包,在下文中一共展示了IDataSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setData
import com.github.mikephil.charting.interfaces.datasets.IDataSet; //导入依赖的package包/类
/**
* Sets a new data object for the chart. The data object contains all values
* and information needed for displaying.
*
* @param data
*/
public void setData(T data) {
mData = data;
mOffsetsCalculated = false;
if (data == null) {
return;
}
// calculate how many digits are needed
setupDefaultFormatter(data.getYMin(), data.getYMax());
for (IDataSet set : mData.getDataSets()) {
if (set.needsFormatter() || set.getValueFormatter() == mDefaultValueFormatter)
set.setValueFormatter(mDefaultValueFormatter);
}
// let the chart know there is new data
notifyDataSetChanged();
if (mLogEnabled)
Log.i(LOG_TAG, "Data is set.");
}
示例2: addEntry
import com.github.mikephil.charting.interfaces.datasets.IDataSet; //导入依赖的package包/类
/**
* Adds an Entry to the DataSet at the specified index.
* Entries are added to the end of the list.
*
* @param e
* @param dataSetIndex
*/
public void addEntry(Entry e, int dataSetIndex) {
if (mDataSets.size() > dataSetIndex && dataSetIndex >= 0) {
IDataSet set = mDataSets.get(dataSetIndex);
// add the entry to the dataset
if (!set.addEntry(e))
return;
calcMinMax(e, set.getAxisDependency());
} else {
Log.e("addEntry", "Cannot add Entry because dataSetIndex too high or too low.");
}
}
示例3: removeEntry
import com.github.mikephil.charting.interfaces.datasets.IDataSet; //导入依赖的package包/类
/**
* Removes the given Entry object from the DataSet at the specified index.
*
* @param e
* @param dataSetIndex
*/
public boolean removeEntry(Entry e, int dataSetIndex) {
// entry null, outofbounds
if (e == null || dataSetIndex >= mDataSets.size())
return false;
IDataSet set = mDataSets.get(dataSetIndex);
if (set != null) {
// remove the entry from the dataset
boolean removed = set.removeEntry(e);
if (removed) {
calcMinMax();
}
return removed;
} else
return false;
}
示例4: removeEntry
import com.github.mikephil.charting.interfaces.datasets.IDataSet; //导入依赖的package包/类
/**
* Removes the given Entry object from the DataSet at the specified index.
*
* @param e
* @param dataSetIndex
*/
public boolean removeEntry(Entry e, int dataSetIndex) {
// entry null, outofbounds
if (e == null || dataSetIndex >= mDataSets.size())
return false;
IDataSet set = mDataSets.get(dataSetIndex);
if (set != null) {
// remove the entry from the dataset
boolean removed = set.removeEntry(e);
if (removed) {
mYValCount -= 1;
calcMinMax(0, mYValCount);
}
return removed;
} else
return false;
}
示例5: getSelectionDetail
import com.github.mikephil.charting.interfaces.datasets.IDataSet; //导入依赖的package包/类
@Override
protected SelectionDetail getSelectionDetail(int xIndex, float y, int dataSetIndex) {
dataSetIndex = Math.max(dataSetIndex, 0);
BarData barData = mChart.getBarData();
IDataSet dataSet = barData.getDataSetCount() > dataSetIndex
? barData.getDataSetByIndex(dataSetIndex)
: null;
if (dataSet == null)
return null;
final float yValue = dataSet.getYValForXIndex(xIndex);
if (yValue == Double.NaN) return null;
return new SelectionDetail(
yValue,
dataSetIndex,
dataSet);
}
示例6: dataSetConfig
import com.github.mikephil.charting.interfaces.datasets.IDataSet; //导入依赖的package包/类
@Override
void dataSetConfig(IDataSet<BarEntry> dataSet, ReadableMap config) {
BarDataSet barDataSet = (BarDataSet) dataSet;
ChartDataSetConfigUtils.commonConfig(barDataSet, config);
ChartDataSetConfigUtils.commonBarLineScatterCandleBubbleConfig(barDataSet, config);
if (BridgeUtils.validate(config, ReadableType.Number, "barSpacePercent")) {
barDataSet.setBarSpacePercent((float) config.getDouble("barSpacePercent"));
}
if (BridgeUtils.validate(config, ReadableType.String, "barShadowColor")) {
barDataSet.setBarShadowColor(Color.parseColor(config.getString("barShadowColor")));
}
if (BridgeUtils.validate(config, ReadableType.Number, "highlightAlpha")) {
barDataSet.setHighLightAlpha(config.getInt("highlightAlpha"));
}
if (BridgeUtils.validate(config, ReadableType.Array, "stackLabels")) {
barDataSet.setStackLabels(BridgeUtils.convertToStringArray(config.getArray("stackLabels")));
}
}
示例7: drawMarkers
import com.github.mikephil.charting.interfaces.datasets.IDataSet; //导入依赖的package包/类
/**
* draws all MarkerViews on the highlighted positions
*/
protected void drawMarkers(Canvas canvas) {
// if there is no marker view or drawing marker is disabled
if (mMarker == null || !isDrawMarkersEnabled() || !valuesToHighlight())
return;
for (int i = 0; i < mIndicesToHighlight.length; i++) {
Highlight highlight = mIndicesToHighlight[i];
IDataSet set = mData.getDataSetByIndex(highlight.getDataSetIndex());
Entry e = mData.getEntryForHighlight(mIndicesToHighlight[i]);
int entryIndex = set.getEntryIndex(e);
// make sure entry not null
if (e == null || entryIndex > set.getEntryCount() * mAnimator.getPhaseX())
continue;
float[] pos = getMarkerPosition(highlight);
// check bounds
if (!mViewPortHandler.isInBounds(pos[0], pos[1]))
continue;
// callbacks to update the content
mMarker.refreshContent(e, highlight);
// draw the marker
mMarker.draw(canvas, pos[0], pos[1]);
}
}
示例8: setValueFormatter
import com.github.mikephil.charting.interfaces.datasets.IDataSet; //导入依赖的package包/类
/**
* Sets a custom IValueFormatter for all DataSets this data object contains.
*
* @param f
*/
public void setValueFormatter(IValueFormatter f) {
if (f == null)
return;
else {
for (IDataSet set : mDataSets) {
set.setValueFormatter(f);
}
}
}
示例9: isHighlightEnabled
import com.github.mikephil.charting.interfaces.datasets.IDataSet; //导入依赖的package包/类
/**
* Returns true if highlighting of all underlying values is enabled, false
* if not.
*
* @return
*/
public boolean isHighlightEnabled() {
for (IDataSet set : mDataSets) {
if (!set.isHighlightEnabled())
return false;
}
return true;
}
示例10: buildHighlights
import com.github.mikephil.charting.interfaces.datasets.IDataSet; //导入依赖的package包/类
/**
* An array of `Highlight` objects corresponding to the selected xValue and dataSetIndex.
*
* @param set
* @param dataSetIndex
* @param xVal
* @param rounding
* @return
*/
protected List<Highlight> buildHighlights(IDataSet set, int dataSetIndex, float xVal, DataSet.Rounding rounding) {
ArrayList<Highlight> highlights = new ArrayList<>();
//noinspection unchecked
List<Entry> entries = set.getEntriesForXValue(xVal);
if (entries.size() == 0) {
// Try to find closest x-value and take all entries for that x-value
final Entry closest = set.getEntryForXValue(xVal, Float.NaN, rounding);
if (closest != null)
{
//noinspection unchecked
entries = set.getEntriesForXValue(closest.getX());
}
}
if (entries.size() == 0)
return highlights;
for (Entry e : entries) {
MPPointD pixels = mChart.getTransformer(
set.getAxisDependency()).getPixelForValues(e.getX(), e.getY());
highlights.add(new Highlight(
e.getX(), e.getY(),
(float) pixels.x, (float) pixels.y,
dataSetIndex, set.getAxisDependency()));
}
return highlights;
}
示例11: buildHighlights
import com.github.mikephil.charting.interfaces.datasets.IDataSet; //导入依赖的package包/类
@Override
protected List<Highlight> buildHighlights(IDataSet set, int dataSetIndex, float xVal, DataSet.Rounding rounding) {
ArrayList<Highlight> highlights = new ArrayList<>();
//noinspection unchecked
List<Entry> entries = set.getEntriesForXValue(xVal);
if (entries.size() == 0) {
// Try to find closest x-value and take all entries for that x-value
final Entry closest = set.getEntryForXValue(xVal, Float.NaN, rounding);
if (closest != null)
{
//noinspection unchecked
entries = set.getEntriesForXValue(closest.getX());
}
}
if (entries.size() == 0)
return highlights;
for (Entry e : entries) {
MPPointD pixels = mChart.getTransformer(
set.getAxisDependency()).getPixelForValues(e.getY(), e.getX());
highlights.add(new Highlight(
e.getX(), e.getY(),
(float) pixels.x, (float) pixels.y,
dataSetIndex, set.getAxisDependency()));
}
return highlights;
}
示例12: setValueFormatter
import com.github.mikephil.charting.interfaces.datasets.IDataSet; //导入依赖的package包/类
/**
* Sets a custom ValueFormatter for all DataSets this data object contains.
*
* @param f
*/
public void setValueFormatter(ValueFormatter f) {
if (f == null)
return;
else {
for (IDataSet set : mDataSets) {
set.setValueFormatter(f);
}
}
}
示例13: setData
import com.github.mikephil.charting.interfaces.datasets.IDataSet; //导入依赖的package包/类
/**
* Sets a new data object for the chart. The data object contains all values
* and information needed for displaying.
*
* @param data
*/
public void setData(T data) {
if (data == null) {
Log.e(LOG_TAG,
"Cannot set data for chart. Provided data object is null.");
return;
}
// LET THE CHART KNOW THERE IS DATA
mOffsetsCalculated = false;
mData = data;
// calculate how many digits are needed
calculateFormatter(data.getYMin(), data.getYMax());
for (IDataSet set : mData.getDataSets()) {
if (Utils.needsDefaultFormatter(set.getValueFormatter()))
set.setValueFormatter(mDefaultFormatter);
}
// let the chart know there is new data
notifyDataSetChanged();
if (mLogEnabled)
Log.i(LOG_TAG, "Data is set.");
}
示例14: SelectionDetail
import com.github.mikephil.charting.interfaces.datasets.IDataSet; //导入依赖的package包/类
public SelectionDetail(float y, float value, int dataIndex, int dataSetIndex, IDataSet set) {
this.y = y;
this.value = value;
this.dataIndex = dataIndex;
this.dataSetIndex = dataSetIndex;
this.dataSet = set;
}
示例15: getSelectionDetailsAtIndex
import com.github.mikephil.charting.interfaces.datasets.IDataSet; //导入依赖的package包/类
/**
* Returns a list of SelectionDetail object corresponding to the given xIndex.
*
* @param xIndex
* @return
*/
@Override
protected List<SelectionDetail> getSelectionDetailsAtIndex(int xIndex, int dataSetIndex) {
List<SelectionDetail> vals = new ArrayList<SelectionDetail>();
float[] pts = new float[2];
CombinedData data = (CombinedData) mChart.getData();
// get all chartdata objects
List<ChartData> dataObjects = data.getAllData();
for (int i = 0; i < dataObjects.size(); i++) {
for(int j = 0; j < dataObjects.get(i).getDataSetCount(); j++) {
IDataSet dataSet = dataObjects.get(i).getDataSetByIndex(j);
// dont include datasets that cannot be highlighted
if (!dataSet.isHighlightEnabled())
continue;
// extract all y-values from all DataSets at the given x-index
final float yVals[] = dataSet.getYValsForXIndex(xIndex);
for (float yVal : yVals) {
pts[1] = yVal;
mChart.getTransformer(dataSet.getAxisDependency()).pointValuesToPixel(pts);
if (!Float.isNaN(pts[1])) {
vals.add(new SelectionDetail(pts[1], yVal, i, j, dataSet));
}
}
}
}
return vals;
}