本文整理匯總了Java中com.github.mikephil.charting.data.LineDataSet.setDrawHorizontalHighlightIndicator方法的典型用法代碼示例。如果您正苦於以下問題:Java LineDataSet.setDrawHorizontalHighlightIndicator方法的具體用法?Java LineDataSet.setDrawHorizontalHighlightIndicator怎麽用?Java LineDataSet.setDrawHorizontalHighlightIndicator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.github.mikephil.charting.data.LineDataSet
的用法示例。
在下文中一共展示了LineDataSet.setDrawHorizontalHighlightIndicator方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setData
import com.github.mikephil.charting.data.LineDataSet; //導入方法依賴的package包/類
private void setData(int count, float range) {
ArrayList<String> xVals = new ArrayList<String>();
for (int i = 0; i < count; i++) {
xVals.add((1990 +i) + "");
}
ArrayList<Entry> vals1 = new ArrayList<Entry>();
for (int i = 0; i < count; i++) {
float mult = (range + 1);
float val = (float) (Math.random() * mult) + 20;// + (float)
// ((mult *
// 0.1) / 10);
vals1.add(new Entry(val, i));
}
// create a dataset and give it a type
LineDataSet set1 = new LineDataSet(vals1, "DataSet 1");
set1.setDrawCubic(true);
set1.setCubicIntensity(0.2f);
//set1.setDrawFilled(true);
set1.setDrawCircles(false);
set1.setLineWidth(1.8f);
set1.setCircleRadius(4f);
set1.setCircleColor(Color.WHITE);
set1.setHighLightColor(Color.rgb(244, 117, 117));
set1.setColor(Color.WHITE);
set1.setFillColor(Color.WHITE);
set1.setFillAlpha(100);
set1.setDrawHorizontalHighlightIndicator(false);
set1.setFillFormatter(new FillFormatter() {
@Override
public float getFillLinePosition(ILineDataSet dataSet, LineDataProvider dataProvider) {
return -10;
}
});
// create a data object with the datasets
LineData data = new LineData(xVals, set1);
data.setValueTypeface(tf);
data.setValueTextSize(9f);
data.setDrawValues(false);
// set data
mChart.setData(data);
}
示例2: setVotingHistory
import com.github.mikephil.charting.data.LineDataSet; //導入方法依賴的package包/類
/**
* Initialize the line graph to show voting history
* @param vF
* @param vA
*/
private void setVotingHistory(List<Integer> vF, List<Integer> vA) {
votesFor = vF;
votesAgainst = vA;
votesFor.add(resolution.votesFor);
votesAgainst.add(resolution.votesAgainst);
final float lineWidth = 2.5f;
List<Entry> entryFor = new ArrayList<Entry>();
List<Entry> entryAgainst = new ArrayList<Entry>();
// Build data
for (int i=0; i < votesFor.size(); i++) {
entryFor.add(new Entry(i, votesFor.get(i)));
entryAgainst.add(new Entry(i, votesAgainst.get(i)));
}
// lots of formatting for the FOR and AGAINST lines
LineDataSet setFor = new LineDataSet(entryFor, context.getString(R.string.wa_for));
setFor.setAxisDependency(YAxis.AxisDependency.LEFT);
setFor.setColors(ContextCompat.getColor(context, R.color.colorChart0));
setFor.setDrawValues(false);
setFor.setDrawVerticalHighlightIndicator(true);
setFor.setDrawHorizontalHighlightIndicator(false);
setFor.setHighLightColor(RaraHelper.getThemeButtonColour(context));
setFor.setHighlightLineWidth(lineWidth);
setFor.setDrawCircles(false);
setFor.setLineWidth(lineWidth);
LineDataSet setAgainst = new LineDataSet(entryAgainst, context.getString(R.string.wa_against));
setAgainst.setAxisDependency(YAxis.AxisDependency.LEFT);
setAgainst.setColors(ContextCompat.getColor(context, R.color.colorChart1));
setAgainst.setDrawValues(false);
setAgainst.setDrawVerticalHighlightIndicator(true);
setAgainst.setDrawHorizontalHighlightIndicator(false);
setAgainst.setHighLightColor(RaraHelper.getThemeButtonColour(context));
setAgainst.setHighlightLineWidth(lineWidth);
setAgainst.setDrawCircles(false);
setAgainst.setLineWidth(lineWidth);
// Match data with x-axis labels
List<ILineDataSet> dataSets = new ArrayList<ILineDataSet>();
dataSets.add(setFor);
dataSets.add(setAgainst);
LineData data = new LineData(dataSets);
List<String> xLabels = new ArrayList<String>();
for (int i=0; i < votesFor.size(); i++) {
// Only add labels for each day
if (i%24 == 0) {
xLabels.add(String.format(Locale.US, context.getString(R.string.wa_x_axis_d), (i/24)+1));
} else {
xLabels.add(String.format(Locale.US, context.getString(R.string.wa_x_axis_h), i));
}
}
// formatting
votingHistory = RaraHelper.getFormattedLineChart(context, votingHistory, this, xLabels, true, 24, false);
votingHistory.setData(data);
votingHistory.invalidate();
}
示例3: init
import com.github.mikephil.charting.data.LineDataSet; //導入方法依賴的package包/類
public void init(CensusHistoryScale scale) {
dataset = scale;
// Set selected indicator text to latest data
resetDataSelected();
// Calculate max, min, average
List<CensusHistoryPoint> datapoints = dataset.points;
float maxVal = Float.MIN_VALUE;
float minVal = Float.MAX_VALUE;
float total = 0;
for (int i=0; i < datapoints.size(); i++) {
float value = datapoints.get(i).score;
if (value > maxVal) {
maxVal = value;
}
if (value < minVal) {
minVal = value;
}
total += value;
}
float avgVal = total / datapoints.size();
max.setText(SparkleHelper.getPrettifiedNumber(maxVal));
min.setText(SparkleHelper.getPrettifiedNumber(minVal));
avg.setText(SparkleHelper.getPrettifiedNumber(avgVal));
// Set up chart
final float lineWidth = 2.5f;
List<Entry> historyEntries = new ArrayList<Entry>();
for (int i=0; i < datapoints.size(); i++) {
historyEntries.add(new Entry(i, datapoints.get(i).score));
}
// Formatting
LineDataSet lineHistoryData = new LineDataSet(historyEntries, "");
lineHistoryData.setAxisDependency(YAxis.AxisDependency.LEFT);
lineHistoryData.setColors(ContextCompat.getColor(context, R.color.colorChart0));
lineHistoryData.setDrawValues(false);
lineHistoryData.setDrawVerticalHighlightIndicator(true);
lineHistoryData.setDrawHorizontalHighlightIndicator(false);
lineHistoryData.setHighLightColor(RaraHelper.getThemeButtonColour(context));
lineHistoryData.setHighlightLineWidth(lineWidth);
lineHistoryData.setDrawCircles(false);
lineHistoryData.setLineWidth(lineWidth);
// Match data with x-axis labels
List<ILineDataSet> dataSets = new ArrayList<ILineDataSet>();
dataSets.add(lineHistoryData);
LineData dataFinal = new LineData(dataSets);
List<String> xLabels = new ArrayList<String>();
for (int i=0; i < datapoints.size(); i++) {
xLabels.add(String.format(Locale.US, SparkleHelper.getMonthYearDateFromUTC(datapoints.get(i).timestamp), i));
}
// formatting
boolean isLargeValue = maxVal >= 1000f;
chart = RaraHelper.getFormattedLineChart(context, chart, this, xLabels, isLargeValue, 12, false);
chart.setData(dataFinal);
chart.invalidate();
}