Java 类com.github.mikephil.charting.data.LineDataSet 实例源码

项目:Synapse    文件:TrainedModelViewBinder.java   
private LineDataSet prepareInitData(@NonNull LineChart chart, @NonNull List<Entry> entries) {
    final LineDataSet set = new LineDataSet(entries, "Accuracy");

    set.setMode(LineDataSet.Mode.HORIZONTAL_BEZIER);
    set.setAxisDependency(YAxis.AxisDependency.LEFT);
    set.setLineWidth(2F);
    set.setDrawCircleHole(false);
    set.setDrawCircles(false);
    set.setHighlightEnabled(false);
    set.setDrawFilled(true);

    final LineData group = new LineData(set);
    group.setDrawValues(false);

    chart.setData(group);

    return set;
}
项目:GitHub    文件:SimpleFragment.java   
protected LineData generateLineData() {

    ArrayList<ILineDataSet> sets = new ArrayList<ILineDataSet>();

    LineDataSet ds1 = new LineDataSet(FileUtils.loadEntriesFromAssets(getActivity().getAssets(), "sine.txt"), "Sine function");
    LineDataSet ds2 = new LineDataSet(FileUtils.loadEntriesFromAssets(getActivity().getAssets(), "cosine.txt"), "Cosine function");

    ds1.setLineWidth(2f);
    ds2.setLineWidth(2f);

    ds1.setDrawCircles(false);
    ds2.setDrawCircles(false);

    ds1.setColor(ColorTemplate.VORDIPLOM_COLORS[0]);
    ds2.setColor(ColorTemplate.VORDIPLOM_COLORS[1]);

    // load DataSets from textfiles in assets folders
    sets.add(ds1);
    sets.add(ds2);

    LineData d = new LineData(sets);
    d.setValueTypeface(tf);
    return d;
}
项目:GitHub    文件:CombinedChartActivity.java   
private LineData generateLineData() {

        LineData d = new LineData();

        ArrayList<Entry> entries = new ArrayList<Entry>();

        for (int index = 0; index < itemcount; index++)
            entries.add(new Entry(index + 0.5f, getRandom(15, 5)));

        LineDataSet set = new LineDataSet(entries, "Line DataSet");
        set.setColor(Color.rgb(240, 238, 70));
        set.setLineWidth(2.5f);
        set.setCircleColor(Color.rgb(240, 238, 70));
        set.setCircleRadius(5f);
        set.setFillColor(Color.rgb(240, 238, 70));
        set.setMode(LineDataSet.Mode.CUBIC_BEZIER);
        set.setDrawValues(true);
        set.setValueTextSize(10f);
        set.setValueTextColor(Color.rgb(240, 238, 70));

        set.setAxisDependency(YAxis.AxisDependency.LEFT);
        d.addDataSet(set);

        return d;
    }
项目:GitHub    文件:RealtimeLineChartActivity.java   
private LineDataSet createSet() {

        LineDataSet set = new LineDataSet(null, "Dynamic Data");
        set.setAxisDependency(AxisDependency.LEFT);
        set.setColor(ColorTemplate.getHoloBlue());
        set.setCircleColor(Color.WHITE);
        set.setLineWidth(2f);
        set.setCircleRadius(4f);
        set.setFillAlpha(65);
        set.setFillColor(ColorTemplate.getHoloBlue());
        set.setHighLightColor(Color.rgb(244, 117, 117));
        set.setValueTextColor(Color.WHITE);
        set.setValueTextSize(9f);
        set.setDrawValues(false);
        return set;
    }
项目:GitHub    文件:RealmDatabaseActivityLine.java   
private void setData() {

        RealmResults<RealmDemoData> result = mRealm.where(RealmDemoData.class).findAll();

        RealmLineDataSet<RealmDemoData> set = new RealmLineDataSet<RealmDemoData>(result, "xValue", "yValue");
        set.setMode(LineDataSet.Mode.CUBIC_BEZIER);
        set.setLabel("Realm LineDataSet");
        set.setDrawCircleHole(false);
        set.setColor(ColorTemplate.rgb("#FF5722"));
        set.setCircleColor(ColorTemplate.rgb("#FF5722"));
        set.setLineWidth(1.8f);
        set.setCircleRadius(3.6f);

        ArrayList<ILineDataSet> dataSets = new ArrayList<ILineDataSet>();
        dataSets.add(set); // add the dataset

        // create a data object with the dataset list
        LineData data = new LineData(dataSets);
        styleData(data);

        // set data
        mChart.setData(data);
        mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
    }
项目:GitHub    文件:InvertedLineChartActivity.java   
private void setData(int count, float range) {

        ArrayList<Entry> entries = new ArrayList<Entry>();

        for (int i = 0; i < count; i++) {
            float xVal = (float) (Math.random() * range);
            float yVal = (float) (Math.random() * range);
            entries.add(new Entry(xVal, yVal));
        }

        // sort by x-value
        Collections.sort(entries, new EntryXComparator());

        // create a dataset and give it a type
        LineDataSet set1 = new LineDataSet(entries, "DataSet 1");

        set1.setLineWidth(1.5f);
        set1.setCircleRadius(4f);

        // create a data object with the datasets
        LineData data = new LineData(set1);

        // set data
        mChart.setData(data);
    }
项目:Rabbitqueue    文件:MainActivity.java   
/**
 * generates a random ChartData object with just one DataSet
 *
 * @return
 */

private LineData generateDataLine(float[] datas, String type) {

    ArrayList<Entry> entryList = new ArrayList<Entry>();
    for (int i = 0; i < datas.length; i++) {
        entryList.add(new Entry(i, datas[i]));
    }

    LineDataSet d1 = new LineDataSet(entryList, "DataSet :" + type);
    d1.setLineWidth(2.5f);
    Random r = new Random();
    d1.setHighLightColor(Color.rgb(r.nextInt(256), r.nextInt(256), r.nextInt(256)));
    d1.setDrawValues(false);

    ArrayList<ILineDataSet> sets = new ArrayList<>();
    sets.add(d1);

    return new LineData(sets);
}
项目:DOUSalaries    文件:DataBaseHelper.java   
private LineData buildLineData(List<Entry> seniors, List<Entry> engineer,
                               List<Entry> juniors, String[] jobTitles ){
    List<ILineDataSet> sets = new ArrayList<>();
    if (!seniors.isEmpty()){
        LineDataSet dSenior = buildLineDataSet(seniors, jobTitles[0]);
        sets.add(dSenior);
    }
    if (!engineer.isEmpty()){
        LineDataSet dEngineer = buildLineDataSet(engineer, jobTitles[1]);
        dEngineer.setColor(ColorTemplate.VORDIPLOM_COLORS[0]);
        dEngineer.setCircleColor(ColorTemplate.VORDIPLOM_COLORS[0]);
        sets.add(dEngineer);
    }
    if (!juniors.isEmpty()) {
        LineDataSet dJunior = buildLineDataSet(juniors, jobTitles[2]);
        dJunior.setColor(ColorTemplate.VORDIPLOM_COLORS[2]);
        dJunior.setCircleColor(ColorTemplate.VORDIPLOM_COLORS[2]);
        sets.add(dJunior);//add data
    }
    return  new LineData(sets);
}
项目:igrow-android    文件:EnvironmentalSensorDetailFragment.java   
private LineData generateLineData() {

        LineData d = new LineData();

        ArrayList<Entry> entries = new ArrayList<Entry>();

        for (int index = 0; index < itemcount; index++)
            entries.add(new Entry(index + 0.5f, getRandom(15, 5)));

        LineDataSet set = new LineDataSet(entries, "Line DataSet");
        set.setColor(Color.rgb(240, 238, 70));
        set.setLineWidth(2.5f);
        set.setCircleColor(Color.rgb(240, 238, 70));
        set.setCircleRadius(5f);
        set.setFillColor(Color.rgb(240, 238, 70));
        set.setMode(LineDataSet.Mode.CUBIC_BEZIER);
        set.setDrawValues(true);
        set.setValueTextSize(10f);
        set.setValueTextColor(Color.rgb(240, 238, 70));

        set.setAxisDependency(YAxis.AxisDependency.LEFT);
        d.addDataSet(set);

        return d;
    }
项目:Lunary-Ethereum-Wallet    文件:FragmentPrice.java   
private LineData getData(ArrayList<Entry> yVals) {
    LineDataSet set1 = new LineDataSet(yVals, "");
    set1.setLineWidth(1.45f);
    set1.setColor(Color.argb(240, 255, 255, 255));
    set1.setCircleColor(Color.WHITE);
    set1.setHighLightColor(Color.WHITE);
    set1.setFillColor(getResources().getColor(R.color.chartFilled));
    set1.setDrawCircles(false);
    set1.setDrawValues(false);
    set1.setDrawFilled(true);
    set1.setFillFormatter(new IFillFormatter() {
        @Override
        public float getFillLinePosition(ILineDataSet dataSet, LineDataProvider dataProvider) {
            return priceChart.getAxisLeft().getAxisMinimum();
        }
    });

    LineData data = new LineData(set1);
    return data;
}
项目:exchange-rates-mvvm    文件:LineChartExtensions.java   
@BindingAdapter({"bind:items"})
public static void populateDiagram(LineChart view, List<SingleValue> items) {

    if (null == items || items.size() == 0) {
        return;
    }
    List<Entry> entries = new ArrayList<>();
    for (int i = 0; i < items.size(); i++) {
        final SingleValue item = items.get(i);
        final Entry entry = new Entry(i, (float) item.getValue(), item);
        entries.add(entry);
    }
    LineDataSet dataSet = new LineDataSet(entries, view.getContext().getString(R.string.currency_value));
    LineData lineData = new LineData(dataSet);

    formatXAxisLabels(view, items);
    view.setData(lineData);
    view.invalidate();
}
项目:pm-home-station    文件:ChartFragment.java   
private LineDataSet createSet(String label) {
    LineDataSet set = new LineDataSet(null, label);
    set.setAxisDependency(YAxis.AxisDependency.LEFT);
    int color;
    if (label.equals(pm1Label)) {
        color = Color.BLUE;
    } else if (label.equals(pm25Label)) {
        color = Color.RED;
    } else {
        color = Color.BLACK;
    }
    set.setColor(color);
    set.setLineWidth(2f);
    set.setDrawValues(false);
    set.setDrawCircles(false);
    set.setMode(LineDataSet.Mode.LINEAR);
    return set;
}
项目:TwistyTimer    文件:ChartStatistics.java   
/**
 * Adds the main data set for all times and the data set for the progression of record best
 * times among all times. The progression of best times are marked in a different color to the
 * main line of all time using circles lined with a dashed line. This will appear to connect
 * the lowest troughs along the main line of all times.
 *
 * @param chartData The chart data to which to add the new data sets.
 * @param allLabel  The label of the all-times line.
 * @param allColor  The color of the all-times line.
 * @param bestLabel The label of the best-times line.
 * @param bestColor The color of the best-times line.
 */
private void addMainDataSets(LineData chartData, String allLabel, int allColor,
                             String bestLabel, int bestColor) {
    // Main data set for all solve times.
    chartData.addDataSet(createDataSet(allLabel, allColor));

    // Data set to show the progression of best times along the main line of all times.
    final LineDataSet bestDataSet = createDataSet(bestLabel, bestColor);

    bestDataSet.enableDashedLine(3f, 6f, 0f);

    bestDataSet.setDrawCircles(true);
    bestDataSet.setCircleRadius(BEST_TIME_CIRCLE_RADIUS_DP);
    bestDataSet.setCircleColor(bestColor);

    bestDataSet.setDrawValues(false);
    bestDataSet.setValueTextColor(bestColor);
    bestDataSet.setValueTextSize(BEST_TIME_VALUES_TEXT_SIZE_DP);
    bestDataSet.setValueFormatter(new TimeChartValueFormatter());

    chartData.addDataSet(bestDataSet);
}
项目:TwistyTimer    文件:ChartStatistics.java   
/**
     * Adds the data set for the average-of-N (AoN) times and the corresponding data set for the
     * single best average time for that value of "N". The best AoN times are not shown as a
     * progression; only one time is shown and it superimposed on its main AoN line, rendered in
     * the same color as a circle and with the value drawn on the chart.
     *
     * @param chartData The chart data to which to add the new data sets.
     * @param label     The label of the AoN line and best AoN time marker.
     * @param color     The color of the AoN line and best AoN time marker.
     */
    private void addAoNDataSets(LineData chartData, String label, int color) {
        // Main AoN data set for all AoN times for one value of "N".
        chartData.addDataSet(createDataSet(label, color));

        // Data set for the single best AoN time for this "N".
        final LineDataSet bestAoNDataSet = createDataSet(label, color);

        bestAoNDataSet.setDrawCircles(true);
        bestAoNDataSet.setCircleRadius(BEST_TIME_CIRCLE_RADIUS_DP);
        bestAoNDataSet.setCircleColor(color);

        // Drawing the value of the best AoN time for each "N" seems like it would be a good idea,
        // but the values are really hard because they appear over other chart lines and sometimes
        // over the values drawn for the best time progression. Disabling them is no great loss,
        // as the statistics table shows the same values, anyway. Just showing a circle to mark
        // the best AoN time looks well enough on its own.
        bestAoNDataSet.setDrawValues(false);
//        bestAoNDataSet.setValueTextColor(color);
//        bestAoNDataSet.setValueTextSize(BEST_TIME_VALUES_TEXT_SIZE_DP);
//        bestAoNDataSet.setValueFormatter(new TimeChartValueFormatter());

        chartData.addDataSet(bestAoNDataSet);
    }
项目:TwistyTimer    文件:ChartStatistics.java   
/**
 * Creates a data set with the given label and color. Highlights and drawing of values and
 * circles are disabled, as that is common for many cases.
 *
 * @param label The label to assign to the new data set.
 * @param color The line color to set for the new data set.
 */
private LineDataSet createDataSet(String label, int color) {
    // A legend is enabled on the chart view in the graph fragment. The legend is created
    // automatically, but requires a unique labels and colors on each data set.
    final LineDataSet dataSet = new LineDataSet(null, label);

    // A dashed line can make peaks inaccurate. It also makes the graph look too "busy". It
    // is OK for some uses, such as progressions of best times, but that is left to the caller
    // to change once this new data set is returned.
    //
    // If graphing only times for a session, there will be fewer, and a thicker line will look
    // well. However, if all times are graphed, a thinner line will probably look better, as
    // the finer details will be more visible.
    dataSet.setLineWidth(getLineWidth());
    dataSet.setColor(color);
    dataSet.setHighlightEnabled(false);

    dataSet.setDrawCircles(false);
    dataSet.setDrawValues(false);

    return dataSet;
}
项目:VMAndroid    文件:RecordDBFragment.java   
private LineDataSet createSet() {

        LineDataSet set = new LineDataSet(null, getString(R.string.app_name));
        set.setAxisDependency(YAxis.AxisDependency.LEFT);
        set.setColor(ColorTemplate.getHoloBlue());
        set.setCircleColor(Color.WHITE);
        set.setLineWidth(1f);
        set.setCircleRadius(1.5f);
        set.setFillAlpha(65);
        set.setFillColor(ColorTemplate.getHoloBlue());
        set.setHighLightColor(Color.rgb(244, 117, 117));
        set.setValueTextColor(Color.WHITE);
        set.setValueTextSize(9f);
        set.setDrawValues(false);
        return set;
    }
项目:VMAndroid    文件:StoreDbRecordFragment.java   
private LineDataSet createSet() {

        LineDataSet set = new LineDataSet(null, getString(R.string.app_name));
        set.setAxisDependency(YAxis.AxisDependency.LEFT);
        set.setColor(ColorTemplate.getHoloBlue());
        set.setCircleColor(Color.WHITE);
        set.setLineWidth(1f);
        set.setCircleRadius(1.5f);
        set.setFillAlpha(65);
        set.setFillColor(ColorTemplate.getHoloBlue());
        set.setHighLightColor(Color.rgb(244, 117, 117));
        set.setValueTextColor(Color.WHITE);
        set.setValueTextSize(9f);
        set.setDrawValues(false);
        return set;
    }
项目:BeaconTrackerAndroid    文件:DashboardFragment.java   
public LineData createLineChartData()
{
    mDashboardHelper = new DashboardHelper(getActivity());
    HashMap<String, ArrayList> holder = mDashboardHelper.generateBeaconTotalDurationPerDayMap();

    ArrayList<String> xValues = holder.get("dayOfThisMonth");
    ArrayList<Entry> entries = holder.get("totalDurationPerDay");

    LineDataSet set = new LineDataSet(entries, "");
    set.setCircleColor(0xFF2196f3);
    set.setCircleRadius(4f);
    set.setDrawCircleHole(false);
    set.setColor(0xFF2196f3);
    set.setLineWidth(2f);
    set.setDrawValues(false);

    return new LineData(xValues, set);
}
项目:shengyiplus-android    文件:HomeTricsActivity.java   
/**
 * 曲线
 */
private LineData generateLineData() {
    LineData lineData = new LineData();
    ArrayList<Entry> entries = new ArrayList<>();
    for (int index = 0; index < items.size(); index++) {
        entries.add(new Entry(index + 1f, (float) items.get(index).sub_data.getData()));
    }
    LineDataSet lineDataSet = new LineDataSet(entries, "对比数据");
    lineDataSet.setValues(entries);
    lineDataSet.setDrawValues(false);//是否在线上显示值
    lineDataSet.setColor(ContextCompat.getColor(mContext, R.color.co3));
    lineDataSet.setLineWidth(2.5f);
    lineDataSet.setCircleColor(ContextCompat.getColor(mContext, R.color.co3));
    lineDataSet.setCircleRadius(5f);
    lineDataSet.setDrawCircles(false);
    lineDataSet.setMode(LineDataSet.Mode.HORIZONTAL_BEZIER);//设置线条类型
    //set.setDrawHorizontalHighlightIndicator(false);//隐藏选中线
    //set.setDrawVerticalHighlightIndicator(false);//隐藏选中线条
    lineDataSet.setAxisDependency(YAxis.AxisDependency.LEFT);
    lineDataSet.setHighlightEnabled(false);
    lineData.setHighlightEnabled(false);
    lineData.addDataSet(lineDataSet);
    return lineData;
}
项目:Stayfit    文件:DrawChartActivity.java   
private void initWithDummyData() {
    ArrayList<String> xVals = new ArrayList<String>();
    for (int i = 0; i < 24; i++) {
        xVals.add((i) + ":00");
    }

    ArrayList<Entry> yVals = new ArrayList<Entry>();

    // create a dataset and give it a type (0)
    LineDataSet set1 = new LineDataSet(yVals, "DataSet");
    set1.setLineWidth(3f);
    set1.setCircleRadius(5f);

    ArrayList<ILineDataSet> dataSets = new ArrayList<ILineDataSet>();
    dataSets.add(set1); // add the datasets

    // create a data object with the datasets
    LineData data = new LineData(xVals, dataSets);

    mChart.setData(data);
}
项目:Stayfit    文件:CombinedChartActivity.java   
private LineData generateLineData() {

        LineData d = new LineData();

        ArrayList<Entry> entries = new ArrayList<Entry>();

        for (int index = 0; index < itemcount; index++)
            entries.add(new Entry(getRandom(15, 10), index));

        LineDataSet set = new LineDataSet(entries, "Line DataSet");
        set.setColor(Color.rgb(240, 238, 70));
        set.setLineWidth(2.5f);
        set.setCircleColor(Color.rgb(240, 238, 70));
        set.setCircleRadius(5f);
        set.setFillColor(Color.rgb(240, 238, 70));
        set.setDrawCubic(true);
        set.setDrawValues(true);
        set.setValueTextSize(10f);
        set.setValueTextColor(Color.rgb(240, 238, 70));

        set.setAxisDependency(YAxis.AxisDependency.LEFT);

        d.addDataSet(set);

        return d;
    }
项目:Stayfit    文件:RealtimeLineChartActivity.java   
private LineDataSet createSet() {

        LineDataSet set = new LineDataSet(null, "Dynamic Data");
        set.setAxisDependency(AxisDependency.LEFT);
        set.setColor(ColorTemplate.getHoloBlue());
        set.setCircleColor(Color.WHITE);
        set.setLineWidth(2f);
        set.setCircleRadius(4f);
        set.setFillAlpha(65);
        set.setFillColor(ColorTemplate.getHoloBlue());
        set.setHighLightColor(Color.rgb(244, 117, 117));
        set.setValueTextColor(Color.WHITE);
        set.setValueTextSize(9f);
        set.setDrawValues(false);
        return set;
    }
项目:bounswe2016group2    文件:userHomeFragment.java   
/**
 * Generate line data line data.
 *
 * @return the line data
 */
protected LineData generateLineData() {

    ArrayList<ILineDataSet> sets = new ArrayList<ILineDataSet>();

    LineDataSet ds1 = new LineDataSet(FileUtils.loadEntriesFromAssets(getActivity().getAssets(), "sine.txt"), "Sine function");
    LineDataSet ds2 = new LineDataSet(FileUtils.loadEntriesFromAssets(getActivity().getAssets(), "cosine.txt"), "Cosine function");

    ds1.setLineWidth(2f);
    ds2.setLineWidth(2f);

    ds1.setDrawCircles(false);
    ds2.setDrawCircles(false);

    ds1.setColor(ColorTemplate.VORDIPLOM_COLORS[0]);
    ds2.setColor(ColorTemplate.VORDIPLOM_COLORS[1]);

    // load DataSets from textfiles in assets folders
    sets.add(ds1);
    sets.add(ds2);

    LineData d = new LineData(sets);
    d.setValueTypeface(tf);
    return d;
}
项目:lp2go    文件:ViewControllerScope.java   
private LineDataSet createSet() {

        LineDataSet set = new LineDataSet(null, "Dynamic Data");
        set.setAxisDependency(YAxis.AxisDependency.LEFT);
        set.setColor(ColorTemplate.getHoloBlue());
        set.setCircleColor(Color.WHITE);
        set.setLineWidth(2f);
        set.setCircleRadius(4f);
        set.setFillAlpha(65);
        set.setFillColor(ColorTemplate.getHoloBlue());
        set.setHighLightColor(Color.rgb(244, 117, 117));
        set.setValueTextColor(Color.WHITE);
        set.setValueTextSize(9f);
        set.setDrawValues(false);
        return set;
    }
项目:wearDrip    文件:wearDripWatchFace.java   
private LineDataSet createSet() {
    LineDataSet set = new LineDataSet(null, "BG Data");
    set.setAxisDependency(YAxis.AxisDependency.LEFT);
    set.setColor(ColorTemplate.getHoloBlue());
    set.setCircleColor(Color.WHITE);
    set.setLineWidth(2f);
    set.setCircleRadius(3f);
    set.setFillAlpha(65);
    set.setFillColor(ColorTemplate.getHoloBlue());
    set.setHighLightColor(Color.rgb(244, 117, 117));
    set.setValueTextColor(Color.WHITE);
    set.setValueTextSize(9f);
    set.setDrawValues(false);
    //set.setColors(ColorTemplate.COLORFUL_COLORS);
    //set.setColors(ColorTemplate.VORDIPLOM_COLORS);
    //set.setColors(ColorTemplate.JOYFUL_COLORS);
    //set.setColors(ColorTemplate.LIBERTY_COLORS);
    //set.setColors(ColorTemplate.PASTEL_COLORS);
    //set.setDrawCubic(chartcubic);
    return set;
}
项目:P2P    文件:LineChartRenderer.java   
protected void drawLinearFill(Canvas c, LineDataSet dataSet, List<Entry> entries, int minx,
        int maxx,
        Transformer trans) {

    mRenderPaint.setStyle(Paint.Style.FILL);

    mRenderPaint.setColor(dataSet.getFillColor());
    // filled is drawn with less alpha
    mRenderPaint.setAlpha(dataSet.getFillAlpha());

    Path filled = generateFilledPath(
            entries,
            dataSet.getFillFormatter().getFillLinePosition(dataSet, mChart), minx, maxx);

    trans.pathValueToPixel(filled);

    c.drawPath(filled, mRenderPaint);

    // restore alpha
    mRenderPaint.setAlpha(255);
}
项目:xs-android-architecture    文件:SimpleFragment.java   
protected LineData generateLineData() {

    ArrayList<ILineDataSet> sets = new ArrayList<ILineDataSet>();

    LineDataSet ds1 = new LineDataSet(FileUtils.loadEntriesFromAssets(getActivity().getAssets(), "sine.txt"), "Sine function");
    LineDataSet ds2 = new LineDataSet(FileUtils.loadEntriesFromAssets(getActivity().getAssets(), "cosine.txt"), "Cosine function");

    ds1.setLineWidth(2f);
    ds2.setLineWidth(2f);

    ds1.setDrawCircles(false);
    ds2.setDrawCircles(false);

    ds1.setColor(ColorTemplate.VORDIPLOM_COLORS[0]);
    ds2.setColor(ColorTemplate.VORDIPLOM_COLORS[1]);

    // load DataSets from textfiles in assets folders
    sets.add(ds1);
    sets.add(ds2);

    LineData d = new LineData(sets);
    d.setValueTypeface(tf);
    return d;
}
项目:xs-android-architecture    文件:RealtimeLineChartActivity.java   
private LineDataSet createSet() {

        LineDataSet set = new LineDataSet(null, "Dynamic Data");
        set.setAxisDependency(AxisDependency.LEFT);
        set.setColor(ColorTemplate.getHoloBlue());
        set.setCircleColor(Color.WHITE);
        set.setLineWidth(2f);
        set.setCircleRadius(4f);
        set.setFillAlpha(65);
        set.setFillColor(ColorTemplate.getHoloBlue());
        set.setHighLightColor(Color.rgb(244, 117, 117));
        set.setValueTextColor(Color.WHITE);
        set.setValueTextSize(9f);
        set.setDrawValues(false);
        return set;
    }
项目:xs-android-architecture    文件:InvertedLineChartActivity.java   
private void setData(int count, float range) {

        ArrayList<Entry> entries = new ArrayList<Entry>();

        for (int i = 0; i < count; i++) {
            float xVal = (float) (Math.random() * range);
            float yVal = (float) (Math.random() * range);
            entries.add(new Entry(xVal, yVal));
        }

        // sort by x-value
        Collections.sort(entries, new EntryXComparator());

        // create a dataset and give it a type
        LineDataSet set1 = new LineDataSet(entries, "DataSet 1");

        set1.setLineWidth(1.5f);
        set1.setCircleRadius(4f);

        // create a data object with the datasets
        LineData data = new LineData(set1);

        // set data
        mChart.setData(data);
    }
项目:daily-dozen-android    文件:LoadServingsHistoryTask.java   
private LineData getLineData(List<String> xVals, List<Entry> lineEntries) {
    final LineDataSet dataSet = new LineDataSet(lineEntries, getContext().getString(R.string.moving_average));

    final int color = ContextCompat.getColor(getContext(), R.color.brown);

    dataSet.setColor(color);
    dataSet.setLineWidth(2.5f);
    dataSet.setCircleColor(color);
    dataSet.setFillColor(color);
    dataSet.setDrawValues(true);
    dataSet.setValueTextSize(12);
    dataSet.setValueTextColor(color);

    // Format the value labels to two decimal places
    dataSet.setValueFormatter(new LineChartValueFormatter());

    return new LineData(xVals, dataSet);
}
项目:go-bees    文件:RecordingsAdapter.java   
/**
 * Style char lines (type, color, etc.).
 *
 * @param entries list of entries.
 * @return line data chart.
 */
private LineData styleChartLines(List<Entry> entries) {
    // Set styles
    LineDataSet lineDataSet = new LineDataSet(entries, "Recording");
    lineDataSet.setMode(LineDataSet.Mode.HORIZONTAL_BEZIER);
    lineDataSet.setCubicIntensity(0.2f);
    lineDataSet.setDrawValues(false);
    lineDataSet.setDrawCircles(false);
    lineDataSet.setLineWidth(1.8f);
    lineDataSet.setColor(ContextCompat.getColor(context, R.color.colorAccent));
    if (((int) lineDataSet.getYMax()) != 0) {
        lineDataSet.setDrawFilled(true);
        lineDataSet.setFillAlpha(255);
        // Fix bug with vectors in API < 21
        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT){
            Drawable drawable = ResourcesCompat.getDrawable(context.getResources(),
                    R.drawable.chart_fade, null);
            lineDataSet.setFillDrawable(drawable);
        } else{
            lineDataSet.setFillColor(ContextCompat.getColor(context, R.color.colorPrimary));
        }
    }
    return new LineData(lineDataSet);
}
项目:gadgetbridge_artikcloud    文件:AbstractChartFragment.java   
protected LineDataSet createHeartrateSet(List<Entry> values, String label) {
        LineDataSet set1 = new LineDataSet(values, label);
        set1.setLineWidth(0.8f);
        set1.setColor(HEARTRATE_COLOR);
        set1.setDrawCubic(true);
        set1.setCubicIntensity(0.1f);
        set1.setDrawCircles(false);
//        set1.setCircleRadius(2f);
//        set1.setDrawFilled(true);
//        set1.setColor(getResources().getColor(android.R.color.background_light));
//        set1.setCircleColor(HEARTRATE_COLOR);
//        set1.setFillColor(ColorTemplate.getHoloBlue());
//        set1.setHighLightColor(Color.rgb(128, 0, 255));
//        set1.setColor(Color.rgb(89, 178, 44));
        set1.setDrawValues(true);
        set1.setValueTextColor(CHART_TEXT_COLOR);
        set1.setAxisDependency(YAxis.AxisDependency.RIGHT);
        return set1;
    }
项目:GitHub    文件:LineChartRenderer.java   
/**
 * Generates a path that is used for filled drawing.
 *
 * @param dataSet    The dataset from which to read the entries.
 * @param startIndex The index from which to start reading the dataset
 * @param endIndex   The index from which to stop reading the dataset
 * @param outputPath The path object that will be assigned the chart data.
 * @return
 */
private void generateFilledPath(final ILineDataSet dataSet, final int startIndex, final int endIndex, final Path outputPath) {

    final float fillMin = dataSet.getFillFormatter().getFillLinePosition(dataSet, mChart);
    final float phaseY = mAnimator.getPhaseY();
    final boolean isDrawSteppedEnabled = dataSet.getMode() == LineDataSet.Mode.STEPPED;

    final Path filled = outputPath;
    filled.reset();

    final Entry entry = dataSet.getEntryForIndex(startIndex);

    filled.moveTo(entry.getX(), fillMin);
    filled.lineTo(entry.getX(), entry.getY() * phaseY);

    // create a new path
    Entry currentEntry = null;
    Entry previousEntry = null;
    for (int x = startIndex + 1; x <= endIndex; x++) {

        currentEntry = dataSet.getEntryForIndex(x);

        if (isDrawSteppedEnabled && previousEntry != null) {
            filled.lineTo(currentEntry.getX(), previousEntry.getY() * phaseY);
        }

        filled.lineTo(currentEntry.getX(), currentEntry.getY() * phaseY);

        previousEntry = currentEntry;
    }

    // close up
    if (currentEntry != null) {
        filled.lineTo(currentEntry.getX(), fillMin);
    }

    filled.close();
}
项目:GitHub    文件:SimpleFragment.java   
protected LineData getComplexity() {

    ArrayList<ILineDataSet> sets = new ArrayList<ILineDataSet>();

    LineDataSet ds1 = new LineDataSet(FileUtils.loadEntriesFromAssets(getActivity().getAssets(), "n.txt"), "O(n)");
    LineDataSet ds2 = new LineDataSet(FileUtils.loadEntriesFromAssets(getActivity().getAssets(), "nlogn.txt"), "O(nlogn)");
    LineDataSet ds3 = new LineDataSet(FileUtils.loadEntriesFromAssets(getActivity().getAssets(), "square.txt"), "O(n\u00B2)");
    LineDataSet ds4 = new LineDataSet(FileUtils.loadEntriesFromAssets(getActivity().getAssets(), "three.txt"), "O(n\u00B3)");

    ds1.setColor(ColorTemplate.VORDIPLOM_COLORS[0]);
    ds2.setColor(ColorTemplate.VORDIPLOM_COLORS[1]);
    ds3.setColor(ColorTemplate.VORDIPLOM_COLORS[2]);
    ds4.setColor(ColorTemplate.VORDIPLOM_COLORS[3]);

    ds1.setCircleColor(ColorTemplate.VORDIPLOM_COLORS[0]);
    ds2.setCircleColor(ColorTemplate.VORDIPLOM_COLORS[1]);
    ds3.setCircleColor(ColorTemplate.VORDIPLOM_COLORS[2]);
    ds4.setCircleColor(ColorTemplate.VORDIPLOM_COLORS[3]);

    ds1.setLineWidth(2.5f);
    ds1.setCircleRadius(3f);
    ds2.setLineWidth(2.5f);
    ds2.setCircleRadius(3f);
    ds3.setLineWidth(2.5f);
    ds3.setCircleRadius(3f);
    ds4.setLineWidth(2.5f);
    ds4.setCircleRadius(3f);


    // load DataSets from textfiles in assets folders
    sets.add(ds1);        
    sets.add(ds2);
    sets.add(ds3);
    sets.add(ds4);

    LineData d = new LineData(sets);
    d.setValueTypeface(tf);
    return d;
}
项目:GitHub    文件:DrawChartActivity.java   
private void initWithDummyData() {

        ArrayList<Entry> yVals = new ArrayList<Entry>();

        // create a dataset and give it a type (0)
        LineDataSet set1 = new LineDataSet(yVals, "DataSet");
        set1.setLineWidth(3f);
        set1.setCircleRadius(5f);

        // create a data object with the datasets
        LineData data = new LineData(set1);

        mChart.setData(data);
    }
项目:GitHub    文件:DynamicalAddingActivity.java   
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();
        }
    }
项目:GitHub    文件:DynamicalAddingActivity.java   
private LineDataSet createSet() {

        LineDataSet set = new LineDataSet(null, "DataSet 1");
        set.setLineWidth(2.5f);
        set.setCircleRadius(4.5f);
        set.setColor(Color.rgb(240, 99, 99));
        set.setCircleColor(Color.rgb(240, 99, 99));
        set.setHighLightColor(Color.rgb(190, 190, 190));
        set.setAxisDependency(AxisDependency.LEFT);
        set.setValueTextSize(10f);

        return set;
    }
项目:GitHub    文件:LineChartActivityColored.java   
private LineData getData(int count, float range) {

        ArrayList<Entry> yVals = new ArrayList<Entry>();

        for (int i = 0; i < count; i++) {
            float val = (float) (Math.random() * range) + 3;
            yVals.add(new Entry(i, val));
        }

        // create a dataset and give it a type
        LineDataSet set1 = new LineDataSet(yVals, "DataSet 1");
        // set1.setFillAlpha(110);
        // set1.setFillColor(Color.RED);

        set1.setLineWidth(1.75f);
        set1.setCircleRadius(5f);
        set1.setCircleHoleRadius(2.5f);
        set1.setColor(Color.WHITE);
        set1.setCircleColor(Color.WHITE);
        set1.setHighLightColor(Color.WHITE);
        set1.setDrawValues(false);

        // create a data object with the datasets
        LineData data = new LineData(set1);

        return data;
    }
项目:GitHub    文件:LineChartTime.java   
private void setData(int count, float range) {

        // now in hours
        long now = TimeUnit.MILLISECONDS.toHours(System.currentTimeMillis());

        ArrayList<Entry> values = new ArrayList<Entry>();

        float from = now;

        // count = hours
        float to = now + count;

        // increment by 1 hour
        for (float x = from; x < to; x++) {

            float y = getRandom(range, 50);
            values.add(new Entry(x, y)); // add one entry per hour
        }

        // create a dataset and give it a type
        LineDataSet set1 = new LineDataSet(values, "DataSet 1");
        set1.setAxisDependency(AxisDependency.LEFT);
        set1.setColor(ColorTemplate.getHoloBlue());
        set1.setValueTextColor(ColorTemplate.getHoloBlue());
        set1.setLineWidth(1.5f);
        set1.setDrawCircles(false);
        set1.setDrawValues(false);
        set1.setFillAlpha(65);
        set1.setFillColor(ColorTemplate.getHoloBlue());
        set1.setHighLightColor(Color.rgb(244, 117, 117));
        set1.setDrawCircleHole(false);

        // create a data object with the datasets
        LineData data = new LineData(set1);
        data.setValueTextColor(Color.WHITE);
        data.setValueTextSize(9f);

        // set data
        mChart.setData(data);
    }
项目:GitHub    文件:ListViewMultiChartActivity.java   
/**
 * generates a random ChartData object with just one DataSet
 * 
 * @return
 */
private LineData generateDataLine(int cnt) {

    ArrayList<Entry> e1 = new ArrayList<Entry>();

    for (int i = 0; i < 12; i++) {
        e1.add(new Entry(i, (int) (Math.random() * 65) + 40));
    }

    LineDataSet d1 = new LineDataSet(e1, "New DataSet " + cnt + ", (1)");
    d1.setLineWidth(2.5f);
    d1.setCircleRadius(4.5f);
    d1.setHighLightColor(Color.rgb(244, 117, 117));
    d1.setDrawValues(false);

    ArrayList<Entry> e2 = new ArrayList<Entry>();

    for (int i = 0; i < 12; i++) {
        e2.add(new Entry(i, e1.get(i).getY() - 30));
    }

    LineDataSet d2 = new LineDataSet(e2, "New DataSet " + cnt + ", (2)");
    d2.setLineWidth(2.5f);
    d2.setCircleRadius(4.5f);
    d2.setHighLightColor(Color.rgb(244, 117, 117));
    d2.setColor(ColorTemplate.VORDIPLOM_COLORS[0]);
    d2.setCircleColor(ColorTemplate.VORDIPLOM_COLORS[0]);
    d2.setDrawValues(false);

    ArrayList<ILineDataSet> sets = new ArrayList<ILineDataSet>();
    sets.add(d1);
    sets.add(d2);

    LineData cd = new LineData(sets);
    return cd;
}