Java Code Examples for com.github.mikephil.charting.data.LineDataSet#setLineWidth()
The following examples show how to use
com.github.mikephil.charting.data.LineDataSet#setLineWidth() .
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 |
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: LineChartActivityColored.java From StockChart-MPAndroidChart with MIT License | 6 votes |
private LineData getData(int count, float range) { ArrayList<Entry> values = new ArrayList<>(); for (int i = 0; i < count; i++) { float val = (float) (Math.random() * range) + 3; values.add(new Entry(i, val)); } // create a dataset and give it a type LineDataSet set1 = new LineDataSet(values, "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 data sets return new LineData(set1); }
Example 3
Source File: FragmentPrice.java From Lunary-Ethereum-Wallet with GNU General Public License v3.0 | 6 votes |
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; }
Example 4
Source File: CombinedChartActivity.java From StockChart-MPAndroidChart with MIT License | 6 votes |
private LineData generateLineData() { LineData d = new LineData(); ArrayList<Entry> entries = new ArrayList<>(); for (int index = 0; index < count; 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; }
Example 5
Source File: LineChartHelper.java From Ticket-Analysis with MIT License | 6 votes |
public ILineDataSet generateLineDataSet(List<Entry> yEntrys, int color, String label) { LineDataSet dataSet = new LineDataSet(yEntrys, label); dataSet.setLineWidth(2.0f); dataSet.setCircleRadius(3.5f); dataSet.setDrawCircleHole(true);//填充圆 // dataSet.setDrawValues(true); // dataSet.setValueTextColor(color); dataSet.setValueTextSize(9f); dataSet.setHighlightLineWidth(2.0f); // dataSet.setDrawFilled(true);//区域颜色 dataSet.setFillAlpha(51); // dataSet.setFillColor(color); //填充色 dataSet.setHighLightColor(color); //选中十字线色 dataSet.setColor(color); //线条颜色 dataSet.setCircleColor(color); //圆点颜色 dataSet.setCircleColorHole(Color.WHITE); dataSet.setCircleHoleRadius(2.0f); dataSet.setDrawValues(false); return dataSet; }
Example 6
Source File: KLineDataManage.java From StockChart-MPAndroidChart with MIT License | 6 votes |
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 7
Source File: SimpleFragment.java From StockChart-MPAndroidChart with MIT License | 6 votes |
protected LineData generateLineData() { ArrayList<ILineDataSet> sets = new ArrayList<>(); LineDataSet ds1 = new LineDataSet(FileUtils.loadEntriesFromAssets(context.getAssets(), "sine.txt"), "Sine function"); LineDataSet ds2 = new LineDataSet(FileUtils.loadEntriesFromAssets(context.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 files in assets folder sets.add(ds1); sets.add(ds2); LineData d = new LineData(sets); d.setValueTypeface(tf); return d; }
Example 8
Source File: InvertedLineChartActivity.java From Stayfit with Apache License 2.0 | 5 votes |
private void setData(int count, float range) { ArrayList<String> xVals = new ArrayList<String>(); for (int i = 0; i < count; i++) { xVals.add((i % 30) + "/" + (i % 12) + "/14"); } ArrayList<Entry> yVals = new ArrayList<Entry>(); for (int i = 0; i < count; i++) { float mult = (range + 1); float val = (float) (Math.random() * mult) + 3;// + (float) // ((mult * // 0.1) / 10); yVals.add(new Entry(val, i)); } // create a dataset and give it a type LineDataSet set1 = new LineDataSet(yVals, "DataSet 1"); set1.setLineWidth(1.5f); set1.setCircleRadius(4f); // create a data object with the datasets LineData data = new LineData(xVals, set1); // set data mChart.setData(data); }
Example 9
Source File: PerformanceLineChart.java From Stayfit with Apache License 2.0 | 5 votes |
private void setData(int count, float range) { ArrayList<String> xVals = new ArrayList<String>(); for (int i = 0; i < count; i++) { xVals.add((i) + ""); } ArrayList<Entry> yVals = new ArrayList<Entry>(); for (int i = 0; i < count; i++) { float mult = (range + 1); float val = (float) (Math.random() * mult) + 3;// + (float) // ((mult * // 0.1) / 10); yVals.add(new Entry(val, i)); } // create a dataset and give it a type LineDataSet set1 = new LineDataSet(yVals, "DataSet 1"); set1.setColor(Color.BLACK); set1.setLineWidth(0.5f); set1.setDrawValues(false); set1.setDrawCircles(false); set1.setDrawCubic(false); set1.setDrawFilled(false); // create a data object with the datasets LineData data = new LineData(xVals, set1); // set data mChart.setData(data); // get the legend (only possible after setting data) Legend l = mChart.getLegend(); l.setEnabled(false); }
Example 10
Source File: DynamicalAddingActivity.java From StockChart-MPAndroidChart with MIT License | 5 votes |
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; }
Example 11
Source File: SimpleFragment.java From Stayfit with Apache License 2.0 | 5 votes |
protected LineData generateLineData() { // DataSet ds1 = new DataSet(n, "O(n)"); // DataSet ds2 = new DataSet(nlogn, "O(nlogn)"); // DataSet ds3 = new DataSet(nsquare, "O(n\u00B2)"); // DataSet ds4 = new DataSet(nthree, "O(n\u00B3)"); 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); // sets.add(FileUtils.dataSetFromAssets(getActivity().getAssets(), "n.txt")); // sets.add(FileUtils.dataSetFromAssets(getActivity().getAssets(), "nlogn.txt")); // sets.add(FileUtils.dataSetFromAssets(getActivity().getAssets(), "square.txt")); // sets.add(FileUtils.dataSetFromAssets(getActivity().getAssets(), "three.txt")); int max = Math.max(sets.get(0).getEntryCount(), sets.get(1).getEntryCount()); LineData d = new LineData(ChartData.generateXVals(0, max), sets); d.setValueTypeface(tf); return d; }
Example 12
Source File: RideDetailActivity.java From android-ponewheel with MIT License | 5 votes |
private void setupDatasetWithDefaultValues(LineDataSet dataSet) { dataSet.setAxisDependency(YAxis.AxisDependency.LEFT); dataSet.setColor(ColorTemplate.getHoloBlue()); dataSet.setValueTextColor(ColorTemplate.getHoloBlue()); dataSet.setLineWidth(1.5f); dataSet.setDrawCircles(false); dataSet.setDrawValues(false); dataSet.setFillAlpha(65); dataSet.setFillColor(ColorTemplate.getHoloBlue()); dataSet.setHighLightColor(Color.rgb(244, 117, 117)); dataSet.setDrawCircleHole(false); }
Example 13
Source File: ChartRVAdapter.java From batteryhub with Apache License 2.0 | 5 votes |
private LineData loadData(ChartCard card) { // add entries to dataset LineDataSet lineDataSet = new LineDataSet(card.entries, null); lineDataSet.setMode(LineDataSet.Mode.LINEAR); lineDataSet.setDrawValues(false); lineDataSet.setDrawCircleHole(false); lineDataSet.setColor(card.color); lineDataSet.setCircleColor(card.color); lineDataSet.setLineWidth(1.8f); lineDataSet.setDrawFilled(true); lineDataSet.setFillColor(card.color); return new LineData(lineDataSet); }
Example 14
Source File: ProcessViewer.java From PowerFileExplorer with GNU General Public License v3.0 | 5 votes |
/** * Creates an instance for {@link LineDataSet} which will store the entries * @return */ private LineDataSet createDataSet() { LineDataSet lineDataset = new LineDataSet(new ArrayList<Entry>(), null); lineDataset.setLineWidth(1.75f); lineDataset.setCircleRadius(5f); lineDataset.setCircleHoleRadius(2.5f); lineDataset.setColor(Color.WHITE); lineDataset.setCircleColor(Color.WHITE); lineDataset.setHighLightColor(Color.WHITE); lineDataset.setDrawValues(false); lineDataset.setCircleColorHole(accentColor); return lineDataset; }
Example 15
Source File: LineChartActivityColored.java From Stayfit with Apache License 2.0 | 5 votes |
private LineData getData(int count, float range) { ArrayList<String> xVals = new ArrayList<String>(); for (int i = 0; i < count; i++) { xVals.add(mMonths[i % 12]); } ArrayList<Entry> yVals = new ArrayList<Entry>(); for (int i = 0; i < count; i++) { float val = (float) (Math.random() * range) + 3; yVals.add(new Entry(val, i)); } // 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(3f); set1.setColor(Color.WHITE); set1.setCircleColor(Color.WHITE); set1.setHighLightColor(Color.WHITE); set1.setDrawValues(false); 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); return data; }
Example 16
Source File: SimpleFragment.java From Stayfit with Apache License 2.0 | 5 votes |
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(ChartData.generateXVals(0, ds1.getEntryCount()), sets); d.setValueTypeface(tf); return d; }
Example 17
Source File: DynamicalAddingActivity.java From Stayfit with Apache License 2.0 | 5 votes |
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; }
Example 18
Source File: ListViewMultiChartActivity.java From Stayfit with Apache License 2.0 | 5 votes |
/** * 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((int) (Math.random() * 65) + 40, i)); } 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(e1.get(i).getVal() - 30, i)); } 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(getMonths(), sets); return cd; }
Example 19
Source File: LineChartActivity1.java From Stayfit with Apache License 2.0 | 4 votes |
private void setData(int count, float range) { ArrayList<String> xVals = new ArrayList<String>(); for (int i = 0; i < count; i++) { xVals.add((i) + ""); } ArrayList<Entry> yVals = new ArrayList<Entry>(); for (int i = 0; i < count; i++) { float mult = (range + 1); float val = (float) (Math.random() * mult) + 3;// + (float) // ((mult * // 0.1) / 10); yVals.add(new Entry(val, i)); } // create a dataset and give it a type LineDataSet set1 = new LineDataSet(yVals, "DataSet 1"); // set1.setFillAlpha(110); // set1.setFillColor(Color.RED); // set the line to be drawn like this "- - - - - -" set1.enableDashedLine(10f, 5f, 0f); set1.enableDashedHighlightLine(10f, 5f, 0f); set1.setColor(Color.BLACK); set1.setCircleColor(Color.BLACK); set1.setLineWidth(1f); set1.setCircleRadius(3f); set1.setDrawCircleHole(false); set1.setValueTextSize(9f); Drawable drawable = ContextCompat.getDrawable(this, R.drawable.fade_red); set1.setFillDrawable(drawable); set1.setDrawFilled(true); 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); // set data mChart.setData(data); }
Example 20
Source File: StatActivity.java From ankihelper with GNU General Public License v3.0 | 4 votes |
private void drawLastDaysChart(int[][] data) { List<Entry> lookupEntries = new ArrayList<>(); List<Entry> cardaddEntries = new ArrayList<>(); for(int i = 0; i < data[0].length; i ++){ lookupEntries.add(new Entry(i, data[1][i])); cardaddEntries.add(new Entry(i, data[2][i])); } if(lookupEntries.size() <= 1){ mLastDaysChart.setVisibility(View.INVISIBLE); }else{ mLastDaysChart.setVisibility(View.VISIBLE); } float lineWidth = 2; LineDataSet lineDataSet2 = new LineDataSet(lookupEntries, "Lookups"); lineDataSet2.setColor(DARK_PINK); lineDataSet2.setLineWidth(lineWidth); lineDataSet2.setMode(LineDataSet.Mode.HORIZONTAL_BEZIER); lineDataSet2.setDrawCircles(false); lineDataSet2.setDrawValues(false); LineDataSet lineDataSet3 = new LineDataSet(cardaddEntries, "Cards"); lineDataSet3.setColor(DARK_GREEN); lineDataSet3.setLineWidth(lineWidth); lineDataSet3.setMode(LineDataSet.Mode.HORIZONTAL_BEZIER); lineDataSet3.setDrawCircles(false); lineDataSet3.setDrawValues(false); List<ILineDataSet> dataSets = new ArrayList<ILineDataSet>(); dataSets.add(lineDataSet2); dataSets.add(lineDataSet3); mLastDaysChart.setData(new LineData(dataSets)); mLastDaysChart.getDescription().setText(""); //mHourChart.getDescription().setTextAlign(); mLastDaysChart.getXAxis().setDrawGridLines(false); mLastDaysChart.getXAxis().setPosition(XAxis.XAxisPosition.BOTTOM); mLastDaysChart.getAxisRight().setEnabled(false); //mHourChart.getAxisLeft().setDrawGridLines(false); mLastDaysChart.getXAxis().setValueFormatter( new IAxisValueFormatter() { @Override public String getFormattedValue(float value, AxisBase axis) { return + ((int)(-mLastDays + value + 1)) + "d"; } } ); mLastDaysChart.getLegend().setPosition(Legend.LegendPosition.BELOW_CHART_CENTER); mLastDaysChart.invalidate(); }