Java Code Examples for com.github.mikephil.charting.data.LineDataSet#setHighlightEnabled()

The following examples show how to use com.github.mikephil.charting.data.LineDataSet#setHighlightEnabled() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TickChart.java    From android-kline with Apache License 2.0 7 votes vote down vote up
private ILineDataSet createSet(int type) {
        LineDataSet set = new LineDataSet(null, String.valueOf(type));
//        set.setAxisDependency(YAxis.AxisDependency.LEFT);
        if (type == TYPE_FULL) {
            set.setHighLightColor(mLineColor);
            set.setDrawHighlightIndicators(true);
//            set.setDrawVerticalHighlightIndicator(false);
            set.setHighlightLineWidth(0.5f);
            set.setCircleColor(mLineColor);
            set.setCircleRadius(1.5f);
            set.setDrawCircleHole(false);
            set.setDrawFilled(true);
            set.setColor(mLineColor);
            set.setLineWidth(1f);
            set.setFillDrawable(new ColorDrawable(transparentColor));
        } else if (type == TYPE_AVE) {
            set.setHighlightEnabled(true);
            set.setColor(ContextCompat.getColor(mContext, R.color.ave_color));
            set.setLineWidth(1f);
            set.setCircleRadius(1.5f);
            set.setDrawCircleHole(false);
            set.setCircleColor(transparentColor);
            set.setLineWidth(0.5f);
        } else {
            set.setHighlightEnabled(true);
            set.setDrawVerticalHighlightIndicator(false);
            set.setHighLightColor(transparentColor);
            set.setColor(mLineColor);
            set.enableDashedLine(3, 40, 0);
            set.setDrawCircleHole(false);
            set.setCircleColor(transparentColor);
            set.setLineWidth(1f);
            set.setVisible(true);
        }
        set.setDrawCircles(false);
        set.setDrawValues(false);
        return set;
    }
 
Example 2
Source File: CurrentDayFragment.java    From shinny-futures-android with GNU General Public License v3.0 6 votes vote down vote up
/**
 * date: 6/1/18
 * author: chenli
 * description: 初始化时产生分时图数据集
 */
private LineDataSet generateLineDataSet(List<Entry> entries, int color, String label, boolean isHighlight, YAxis.AxisDependency axisDependency) {
    LineDataSet set = new LineDataSet(entries, label);
    set.setColor(color);
    set.setLineWidth(0.7f);
    set.setDrawCircles(false);
    set.setDrawCircleHole(false);
    set.setDrawValues(false);
    set.setAxisDependency(axisDependency);
    if (isHighlight) {
        refreshYAxisRange(set);
        set.setHighlightLineWidth(0.7f);
        set.setHighLightColor(mHighlightColor);
    } else {
        set.setHighlightEnabled(false);
    }
    return set;
}
 
Example 3
Source File: KlineFragment.java    From shinny-futures-android with GNU General Public License v3.0 6 votes vote down vote up
private LineDataSet generateMALineDataSet(int para, int color, String label) {
    List<Entry> entries = new ArrayList<>();
    for (int i = mLeftIndex + para - 1; i <= mLastIndex; i++) {
        Entry entry = generateMALineDataEntry(i, para - 1);
        entries.add(entry);
    }
    LineDataSet set = new LineDataSet(entries, label);
    set.setColor(color);
    set.setLineWidth(0.7f);
    set.setDrawCircles(false);
    set.setDrawCircleHole(false);
    set.setDrawValues(false);
    set.setHighlightEnabled(false);
    set.setAxisDependency(YAxis.AxisDependency.LEFT);
    return set;
}
 
Example 4
Source File: KlineFragment.java    From shinny-futures-android with GNU General Public License v3.0 6 votes vote down vote up
/**
 * date: 2019/2/22
 * author: chenli
 * description: 产生持仓量数据集
 */
private LineDataSet generateLineDataSet(List<Entry> entries, int color, String label, boolean isHighlight, YAxis.AxisDependency axisDependency) {
    LineDataSet set = new LineDataSet(entries, label);
    set.setColor(color);
    set.setLineWidth(0.7f);
    set.setDrawCircles(false);
    set.setDrawCircleHole(false);
    set.setDrawValues(false);
    set.setAxisDependency(axisDependency);
    if (isHighlight) {
        set.setHighlightLineWidth(0.7f);
        set.setHighLightColor(color);
    } else {
        set.setHighlightEnabled(false);
    }
    return set;
}
 
Example 5
Source File: KLineDataManage.java    From StockChart-MPAndroidChart with MIT License 6 votes vote down vote up
private LineDataSet setALine(ColorType colorType, ArrayList<Entry> lineEntries, String label, boolean highlightEnable) {
    LineDataSet lineDataSetMa = new LineDataSet(lineEntries, label);
    lineDataSetMa.setDrawHorizontalHighlightIndicator(false);
    lineDataSetMa.setHighlightEnabled(highlightEnable);//是否画高亮十字线
    lineDataSetMa.setHighLightColor(ContextCompat.getColor(mContext, R.color.highLight_Color));//高亮十字线颜色
    lineDataSetMa.setDrawValues(false);//是否画出每个蜡烛线的数值
    if (colorType == ColorType.blue) {
        lineDataSetMa.setColor(ContextCompat.getColor(mContext, R.color.ma5));
    } else if (colorType == ColorType.yellow) {
        lineDataSetMa.setColor(ContextCompat.getColor(mContext, R.color.ma10));
    } else if (colorType == ColorType.purple) {
        lineDataSetMa.setColor(ContextCompat.getColor(mContext, R.color.ma20));
    }
    lineDataSetMa.setLineWidth(0.6f);
    lineDataSetMa.setDrawCircles(false);
    lineDataSetMa.setAxisDependency(YAxis.AxisDependency.LEFT);
    return lineDataSetMa;
}
 
Example 6
Source File: TrainedModelViewBinder.java    From Synapse with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 7
Source File: GraphFragment.java    From CryptoBuddy with GNU Affero General Public License v3.0 6 votes vote down vote up
public LineDataSet setUpLineDataSet(List<Entry> entries) {
    LineDataSet dataSet = new LineDataSet(entries, "Price");
    dataSet.setColor(chartBorderColor);
    dataSet.setFillColor(chartFillColor);
    dataSet.setDrawHighlightIndicators(true);
    dataSet.setDrawFilled(true);
    dataSet.setDrawCircles(true);
    dataSet.setCircleColor(chartBorderColor);
    dataSet.setDrawCircleHole(false);
    dataSet.setDrawValues(false);
    dataSet.setCircleRadius(1);
    dataSet.setHighlightLineWidth(2);
    dataSet.setHighlightEnabled(true);
    dataSet.setDrawHighlightIndicators(true);
    dataSet.setHighLightColor(chartBorderColor); // color for highlight indicator
    return dataSet;
}
 
Example 8
Source File: ChartStatistics.java    From TwistyTimer with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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.
    //
    // Also, the library specifies that a thicker line has increased performance use compared
    // thinner lines, so don't make lines too thick if the dataset is large!
    dataSet.setLineWidth(getLineWidth());
    dataSet.setColor(color);
    dataSet.setHighlightEnabled(false);

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

    return dataSet;
}
 
Example 9
Source File: ChartMeasurementView.java    From openScale with GNU General Public License v3.0 6 votes vote down vote up
private void addGoalLine(List<ILineDataSet> lineDataSets) {
    if (prefs.getBoolean("goalLine", true)) {
        List<Entry> valuesGoalLine = new Stack<>();

        ScaleUser user = OpenScale.getInstance().getSelectedScaleUser();
        float goalWeight = Converters.fromKilogram(user.getGoalWeight(), user.getScaleUnit());

        valuesGoalLine.add(new Entry(minXValue, goalWeight));
        valuesGoalLine.add(new Entry(maxXValue, goalWeight));

        LineDataSet goalLine = new LineDataSet(valuesGoalLine, getContext().getString(R.string.label_goal_line));
        goalLine.setLineWidth(1.5f);
        goalLine.setColor(ColorUtil.COLOR_GREEN);
        goalLine.setAxisDependency(prefs.getBoolean("weightOnRightAxis", true) ? YAxis.AxisDependency.RIGHT : YAxis.AxisDependency.LEFT);
        goalLine.setDrawValues(false);
        goalLine.setDrawCircles(false);
        goalLine.setHighlightEnabled(false);
        goalLine.enableDashedLine(10, 30, 0);

        lineDataSets.add(goalLine);
    }
}
 
Example 10
Source File: TimeLineView.java    From android-kline with Apache License 2.0 5 votes vote down vote up
@android.support.annotation.NonNull
private LineDataSet setLine(int type, ArrayList<Entry> lineEntries) {
    LineDataSet lineDataSetMa = new LineDataSet(lineEntries, "ma" + type);
    lineDataSetMa.setDrawValues(false);
    if (type == NORMAL_LINE) {
        lineDataSetMa.setColor(getResources().getColor(R.color.normal_line_color));
        lineDataSetMa.setCircleColor(ContextCompat.getColor(mContext, R.color.normal_line_color));
    } else if (type == NORMAL_LINE_5DAY) {
        lineDataSetMa.setColor(getResources().getColor(R.color.normal_line_color));
        lineDataSetMa.setCircleColor(mTransparentColor);
    } else if (type == AVE_LINE) {
        lineDataSetMa.setColor(getResources().getColor(R.color.ave_color));
        lineDataSetMa.setCircleColor(mTransparentColor);
        lineDataSetMa.setHighlightEnabled(false);
    } else {
        lineDataSetMa.setVisible(false);
        lineDataSetMa.setHighlightEnabled(false);
    }
    lineDataSetMa.setAxisDependency(YAxis.AxisDependency.LEFT);
    lineDataSetMa.setLineWidth(1f);
    lineDataSetMa.setCircleRadius(1f);

    lineDataSetMa.setDrawCircles(false);
    lineDataSetMa.setDrawCircleHole(false);

    return lineDataSetMa;
}
 
Example 11
Source File: ModelDetailActivity.java    From Synapse with Apache License 2.0 5 votes vote down vote up
private boolean setUpChart(@NonNull Model model) {
    final double[] accuracies = model.getAccuracies();

    if (accuracies == null
            || accuracies.length == 0
            || model.getStepEpoch() < 1) {
        return false;
    }

    mAccuracyData.clear();

    for (int i = 0, len = model.getStepEpoch(); i < len; ++i) {
        mAccuracyData.add(new Entry(i + 1, (float) accuracies[i]));
    }

    final LineDataSet set = new LineDataSet(mAccuracyData, getString(R.string.text_chart_left_axis));

    set.setMode(LineDataSet.Mode.LINEAR);
    set.setAxisDependency(YAxis.AxisDependency.LEFT);
    set.setColor(ContextCompat.getColor(this, R.color.chart_left_axis));
    set.setCircleColor(ContextCompat.getColor(this, R.color.chart_left_axis));
    set.setHighLightColor(ContextCompat.getColor(this, R.color.chart_highlight));
    set.setCircleColorHole(Color.WHITE);
    set.setDrawCircleHole(true);
    set.setHighlightEnabled(true);
    set.setLineWidth(2F);
    set.setCircleRadius(3F);
    set.setDrawFilled(false);

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

    setXAxis(model.getEpochs());

    mChart.setData(group);
    mChart.invalidate();
    startChartAnimate();

    return true;
}
 
Example 12
Source File: PowerChart.java    From AndroidApp with GNU Affero General Public License v3.0 5 votes vote down vote up
private LineDataSet createDataSet() {
    LineDataSet powerDataset = new LineDataSet(null, "watts");
    powerDataset.setColor(ContextCompat.getColor(context, R.color.chartBlue));
    powerDataset.setValueTextColor(ContextCompat.getColor(context, R.color.lightGrey));
    powerDataset.setDrawCircles(false);
    powerDataset.setDrawFilled(true);
    powerDataset.setFillColor(ContextCompat.getColor(context, R.color.chartBlue));
    powerDataset.setDrawValues(false);
    powerDataset.setValueTextSize(R.integer.chartValueTextSize);
    powerDataset.setHighlightEnabled(false);
    return powerDataset;
}
 
Example 13
Source File: HourlyActivity.java    From weather with Apache License 2.0 4 votes vote down vote up
private void setChartValues(List<ItemHourlyDB> itemHourlyDBList) {
  List<Entry> entries = new ArrayList<>();
  int i = 0;
  if (AppUtil.isRTL(this)) {
    int j = itemHourlyDBList.size() - 1;
    while (j >= 0) {
      entries.add(new Entry(i, (float) itemHourlyDBList.get(j).getTemp()));
      i++;
      j--;
    }
  } else {
    for (ItemHourlyDB itemHourlyDB : itemHourlyDBList) {
      entries.add(new Entry(i, (float) itemHourlyDB.getTemp()));
      i++;
    }
  }
  LineDataSet dataSet = new LineDataSet(entries, "Label"); // add entries to dataset
  dataSet.setLineWidth(4f);
  dataSet.setCircleRadius(7f);
  dataSet.setHighlightEnabled(false);
  dataSet.setCircleColor(Color.parseColor("#33b5e5"));
  dataSet.setValueTextSize(12);
  dataSet.setValueTextColor(Color.WHITE);
  dataSet.setMode(LineDataSet.Mode.CUBIC_BEZIER);
  dataSet.setValueTypeface(typeface);
  dataSet.setValueFormatter(new ValueFormatter() {
    @Override
    public String getFormattedValue(float value) {
      return String.format(Locale.getDefault(), "%.0f", value);
    }
  });
  LineData lineData = new LineData(dataSet);
  chart.getDescription().setEnabled(false);
  chart.getAxisLeft().setDrawLabels(false);
  chart.getAxisRight().setDrawLabels(false);
  chart.getXAxis().setDrawLabels(false);
  chart.getLegend().setEnabled(false);   // Hide the legend

  chart.getXAxis().setDrawGridLines(false);
  chart.getAxisLeft().setDrawGridLines(false);
  chart.getAxisRight().setDrawGridLines(false);
  chart.getAxisLeft().setDrawAxisLine(false);
  chart.getAxisRight().setDrawAxisLine(false);
  chart.getXAxis().setDrawAxisLine(false);
  chart.setScaleEnabled(false);
  chart.setData(lineData);
  chart.animateY(1000);
}
 
Example 14
Source File: ChartUtil.java    From PocketEOS-Android with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * 曲线赋值与设置
 *
 * @param context   上下文
 * @param yDataList y轴数据
 * @return LineData
 */
private static LineData setLineData(Context context, List<Entry> yDataList,
                                    String curveLable) {
    // y轴的数据集合
    LineDataSet lineDataSet = new LineDataSet(yDataList, curveLable);
    // 用y轴的集合来设置参数
    lineDataSet.setAxisDependency(YAxis.AxisDependency.LEFT);
    // 不显示坐标点的数据
    lineDataSet.setDrawValues(false);
    // 显示坐标点的小圆点
    lineDataSet.setDrawCircles(false);
    // 定位线
    lineDataSet.setHighlightEnabled(false);
    // 线宽
    lineDataSet.setLineWidth(1f);
    // 显示的圆形大小
    lineDataSet.setCircleSize(2f);
    // 显示颜色
    lineDataSet.setColor(context.getApplicationContext().getResources().getColor(R.color.chart_color));
    // 圆形的颜色
    lineDataSet.setCircleColor(context.getApplicationContext().getResources().getColor(R.color.chart_color));
    // 高亮的线的颜色
    lineDataSet.setHighLightColor(context.getApplicationContext().getResources()
            .getColor(R.color.chart_color));
    // 设置填充的颜色

    Drawable drawable = ContextCompat.getDrawable(context, R.drawable.fade_color);
    lineDataSet.setFillDrawable(drawable);

    // 设置坐标点为空心环状
    lineDataSet.setDrawCircleHole(false);
    // lineDataSet.setValueTextSize(9f);
    lineDataSet.setFillAlpha(30);
    // 设置显示曲线和X轴围成的区域阴影
    lineDataSet.setDrawFilled(true);
    // 坐标轴在左侧
    lineDataSet.setAxisDependency(YAxis.AxisDependency.LEFT);
    // 设置每条曲线图例标签名
    // lineDataSet.setLabel("标签");
    lineDataSet.setValueTextSize(14f);
    // 曲线弧度(区间0.05f-1f,默认0.2f)
    lineDataSet.setCubicIntensity(0.2f);
    // 设置为曲线显示,false为折线
    lineDataSet.setMode(LineDataSet.Mode.CUBIC_BEZIER);
    lineDataSet.setValues(yDataList);
    // y轴的数据
    LineData lineData = new LineData(lineDataSet);
    return lineData;
}
 
Example 15
Source File: KLineView.java    From android-kline with Apache License 2.0 4 votes vote down vote up
@android.support.annotation.NonNull
private LineDataSet setLine(int type, ArrayList<Entry> lineEntries) {
    LineDataSet lineDataSetMa = new LineDataSet(lineEntries, "ma" + type);
    lineDataSetMa.setDrawValues(false);
    if (type == NORMAL_LINE) {
        lineDataSetMa.setColor(getResources().getColor(R.color.normal_line_color));
        lineDataSetMa.setCircleColor(ContextCompat.getColor(mContext, R.color.normal_line_color));
    } else if (type == K) {
        lineDataSetMa.setColor(getResources().getColor(R.color.k));
        lineDataSetMa.setCircleColor(mTransparentColor);
    } else if (type == D) {
        lineDataSetMa.setColor(getResources().getColor(R.color.d));
        lineDataSetMa.setCircleColor(mTransparentColor);
        lineDataSetMa.setHighlightEnabled(false);
    } else if (type == J) {
        lineDataSetMa.setColor(getResources().getColor(R.color.j));
        lineDataSetMa.setCircleColor(mTransparentColor);
        lineDataSetMa.setHighlightEnabled(false);
    } else if (type == DIF) {
        lineDataSetMa.setColor(getResources().getColor(R.color.dif));
        lineDataSetMa.setCircleColor(mTransparentColor);
        lineDataSetMa.setHighlightEnabled(false);
    } else if (type == DEA) {
        lineDataSetMa.setColor(getResources().getColor(R.color.dea));
        lineDataSetMa.setCircleColor(mTransparentColor);
        lineDataSetMa.setHighlightEnabled(false);
    } else if (type == AVE_LINE) {
        lineDataSetMa.setColor(getResources().getColor(R.color.ave_color));
        lineDataSetMa.setCircleColor(mTransparentColor);
        lineDataSetMa.setHighlightEnabled(false);
    } else if (type == MA5) {
        lineDataSetMa.setColor(getResources().getColor(R.color.ma5));
        lineDataSetMa.setCircleColor(mTransparentColor);
        lineDataSetMa.setHighlightEnabled(false);
    } else if (type == MA10) {
        lineDataSetMa.setColor(getResources().getColor(R.color.ma10));
        lineDataSetMa.setCircleColor(mTransparentColor);
        lineDataSetMa.setHighlightEnabled(false);
    } else if (type == MA20) {
        lineDataSetMa.setColor(getResources().getColor(R.color.ma20));
        lineDataSetMa.setCircleColor(mTransparentColor);
        lineDataSetMa.setHighlightEnabled(false);
    } else if (type == MA30) {
        lineDataSetMa.setColor(getResources().getColor(R.color.ma30));
        lineDataSetMa.setCircleColor(mTransparentColor);
        lineDataSetMa.setHighlightEnabled(false);
    } else {
        lineDataSetMa.setVisible(false);
        lineDataSetMa.setHighlightEnabled(false);
    }
    lineDataSetMa.setAxisDependency(YAxis.AxisDependency.LEFT);
    lineDataSetMa.setLineWidth(1f);
    lineDataSetMa.setCircleRadius(1f);

    lineDataSetMa.setDrawCircles(false);
    lineDataSetMa.setDrawCircleHole(false);

    return lineDataSetMa;
}