當前位置: 首頁>>代碼示例>>Java>>正文


Java LineDataSet.setDrawHorizontalHighlightIndicator方法代碼示例

本文整理匯總了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);
    }
 
開發者ID:rahulmaddineni,項目名稱:Stayfit,代碼行數:48,代碼來源:CubicLineChartActivity.java

示例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();
}
 
開發者ID:lloydtorres,項目名稱:stately,代碼行數:68,代碼來源:ResolutionRecyclerAdapter.java

示例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();
}
 
開發者ID:lloydtorres,項目名稱:stately,代碼行數:62,代碼來源:TrendsRecyclerAdapter.java


注:本文中的com.github.mikephil.charting.data.LineDataSet.setDrawHorizontalHighlightIndicator方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。