Java Code Examples for lecho.lib.hellocharts.model.Axis#setValues()
The following examples show how to use
lecho.lib.hellocharts.model.Axis#setValues() .
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: BgGraphBuilder.java From xDrip with GNU General Public License v3.0 | 6 votes |
@NonNull private Axis xAxis() { List<AxisValue> axisValues = new ArrayList<AxisValue>(); final java.text.DateFormat timeFormat = hourFormat(); timeFormat.setTimeZone(TimeZone.getDefault()); GregorianCalendar calendar = new GregorianCalendar(); calendar.setTimeInMillis(start_time); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); if (calendar.getTimeInMillis()<start_time){ calendar.add(Calendar.HOUR, 1); } while (calendar.getTimeInMillis()<end_time){ axisValues.add(new AxisValue((calendar.getTimeInMillis() / FUZZER), (timeFormat.format(calendar.getTimeInMillis())).toCharArray())); calendar.add(Calendar.HOUR, 1); } Axis axis = new Axis(); axis.setValues(axisValues); axis.setHasLines(true); return axis; }
Example 2
Source File: BasalChart.java From xDrip with GNU General Public License v3.0 | 6 votes |
@NonNull static public Axis chartYAxis(float max_height) { Axis yAxis = new Axis(); yAxis.setAutoGenerated(false); yAxis.setHasLines(true); //max_height = max_height * 3; final float yStep = chooseClosestStep(max_height / 20f); // rounding??? final List<AxisValue> axisValues = new ArrayList<>(); // TODO autoscale this - rebuild on data change?? for (float j = 0; j <= max_height + yStep; j += yStep) { axisValues.add(new AxisValue(j)); } yAxis.setValues(axisValues); // yAxis.setHasLines(true); yAxis.setMaxLabelChars(5); yAxis.setInside(false); // yAxis.setTextSize(axisTextSize); AxisValueFormatter formatter = new SimpleAxisValueFormatter(2); yAxis.setFormatter(formatter); return yAxis; }
Example 3
Source File: BgGraphBuilder.java From xDrip-plus with GNU General Public License v3.0 | 6 votes |
@NonNull private Axis xAxis() { List<AxisValue> axisValues = new ArrayList<AxisValue>(); final java.text.DateFormat timeFormat = hourFormat(); timeFormat.setTimeZone(TimeZone.getDefault()); GregorianCalendar calendar = new GregorianCalendar(); calendar.setTimeInMillis(start_time); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); if (calendar.getTimeInMillis()<start_time){ calendar.add(Calendar.HOUR, 1); } while (calendar.getTimeInMillis()<end_time){ axisValues.add(new AxisValue((calendar.getTimeInMillis() / FUZZER), (timeFormat.format(calendar.getTimeInMillis())).toCharArray())); calendar.add(Calendar.HOUR, 1); } Axis axis = new Axis(); axis.setValues(axisValues); axis.setHasLines(true); return axis; }
Example 4
Source File: BasalChart.java From xDrip-plus with GNU General Public License v3.0 | 6 votes |
@NonNull static public Axis chartYAxis(float max_height) { Axis yAxis = new Axis(); yAxis.setAutoGenerated(false); yAxis.setHasLines(true); //max_height = max_height * 3; final float yStep = chooseClosestStep(max_height / 20f); // rounding??? final List<AxisValue> axisValues = new ArrayList<>(); // TODO autoscale this - rebuild on data change?? for (float j = 0; j <= max_height + yStep; j += yStep) { axisValues.add(new AxisValue(j)); } yAxis.setValues(axisValues); // yAxis.setHasLines(true); yAxis.setMaxLabelChars(5); yAxis.setInside(false); // yAxis.setTextSize(axisTextSize); AxisValueFormatter formatter = new SimpleAxisValueFormatter(2); yAxis.setFormatter(formatter); return yAxis; }
Example 5
Source File: BgGraphBuilder.java From xDrip-Experimental with GNU General Public License v3.0 | 6 votes |
@NonNull private Axis xAxis() { List<AxisValue> axisValues = new ArrayList<AxisValue>(); final java.text.DateFormat timeFormat = hourFormat(); timeFormat.setTimeZone(TimeZone.getDefault()); GregorianCalendar calendar = new GregorianCalendar(); calendar.setTimeInMillis(start_time); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); if (calendar.getTimeInMillis()<start_time){ calendar.add(Calendar.HOUR, 1); } while (calendar.getTimeInMillis()<end_time){ axisValues.add(new AxisValue((calendar.getTimeInMillis() / FUZZER), (timeFormat.format(calendar.getTimeInMillis())).toCharArray())); calendar.add(Calendar.HOUR, 1); } Axis axis = new Axis(); axis.setValues(axisValues); axis.setHasLines(true); return axis; }
Example 6
Source File: BasalVSTempBasalGraph.java From HAPP with GNU General Public License v3.0 | 6 votes |
public Axis basalVsTempBasalyAxis() { Axis yAxis = new Axis(); yAxis.setAutoGenerated(false); List<AxisValue> axisValues = new ArrayList<>(); for(double j = -maxBasal.intValue(); j <= maxBasal.intValue(); j += 1) { //axisValues.add(new AxisValue((float)fitIOB2COBRange(j))); AxisValue value = new AxisValue((float)j); if (j==0){ value.setLabel("Basal"); } else if (j>0){ value.setLabel("+" + String.valueOf(j) + "u"); } else { value.setLabel(String.valueOf(j) + "u"); } axisValues.add(value); } yAxis.setValues(axisValues); yAxis.setHasLines(true); yAxis.setMaxLabelChars(5); yAxis.setInside(true); return yAxis; }
Example 7
Source File: CommonChartSupport.java From HAPP with GNU General Public License v3.0 | 6 votes |
public Axis iobPastyAxis() { Axis yAxis = new Axis(); yAxis.setAutoGenerated(false); List<AxisValue> axisValues = new ArrayList<AxisValue>(); for(int j = 1; j <= 8; j += 1) { //axisValues.add(new AxisValue((float)fitIOB2COBRange(j))); AxisValue value = new AxisValue(j*10); value.setLabel(String.valueOf(j*2) + "u"); axisValues.add(value); } yAxis.setTextColor(ChartUtils.COLOR_BLUE); yAxis.setValues(axisValues); yAxis.setHasLines(true); yAxis.setMaxLabelChars(5); yAxis.setInside(true); return yAxis; }
Example 8
Source File: CommonChartSupport.java From HAPP with GNU General Public License v3.0 | 6 votes |
public Axis cobPastyAxis() { Axis yAxis = new Axis(); yAxis.setAutoGenerated(false); List<AxisValue> axisValues = new ArrayList<AxisValue>(); for(int j = 1; j <= 8; j += 1) { AxisValue value = new AxisValue(j*10); value.setLabel(String.valueOf(j*10) + "g"); axisValues.add(value); } yAxis.setTextColor(ChartUtils.COLOR_ORANGE); yAxis.setValues(axisValues); yAxis.setHasLines(true); yAxis.setMaxLabelChars(5); yAxis.setInside(true); return yAxis; }
Example 9
Source File: DataChartActivity.java From Memory-capsule with Apache License 2.0 | 5 votes |
private void initColumnChart(){//创建柱状图 columnChartView=new ColumnChartView(this); int columnWidth=(int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,400, getResources().getDisplayMetrics()); int columnHeigth=(int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,400, getResources().getDisplayMetrics()); RelativeLayout.LayoutParams columnChartParams=new RelativeLayout.LayoutParams(columnWidth,columnHeigth); columnChartParams.addRule(RelativeLayout.CENTER_HORIZONTAL); columnChartParams.addRule(RelativeLayout.CENTER_VERTICAL); List<Column>columnList=new ArrayList<>(); List<SubcolumnValue> values; for (int i=0;i<5;++i){ values=new ArrayList<SubcolumnValue>(); values.add(new SubcolumnValue((float)typesNum.get(i),colorData[i])); Column column=new Column(values); column.setHasLabels(false); column.setHasLabelsOnlyForSelected(true); columnList.add(column); } ColumnChartData columnChartData=new ColumnChartData(columnList); Axis axis=new Axis(); Axis axiy=new Axis().setHasLines(true); List<AxisValue>axisValues=new ArrayList<>(); for (int j=0;j<5;++j){ axisValues.add(new AxisValue(j).setLabel(stateChar[j])); } axis.setValues(axisValues); axis.setName("类别"); axiy.setName("数量"); columnChartData.setAxisXBottom(axis); columnChartData.setAxisYLeft(axiy); columnChartView.setColumnChartData(columnChartData); relativeLayout.addView(columnChartView,columnChartParams); }
Example 10
Source File: BasalChart.java From xDrip with GNU General Public License v3.0 | 5 votes |
static private Axis chartXAxis(int size) { final Axis xAxis = new Axis(); xAxis.setAutoGenerated(false); xAxis.setHasTiltedLabels(true); xAxis.setTiltAngle(-90f); xAxis.setMaxLabelChars(7); SimpleDateFormat sdf = new SimpleDateFormat(DateFormat.is24HourFormat(xdrip.getAppContext()) ? "HH:mm" : "a h:mm"); DateFormatSymbols symbols = new DateFormatSymbols(Locale.getDefault()); // OVERRIDE SOME symbols WHILE RETAINING OTHERS symbols.setAmPmStrings(new String[] { "a", "p" }); sdf.setDateFormatSymbols(symbols); final java.text.DateFormat timeFormat = sdf; timeFormat.setTimeZone(TimeZone.getTimeZone("UTC")); final GregorianCalendar calendar = new GregorianCalendar(); calendar.setTimeInMillis(JoH.tsl()); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); xAxis.setAutoGenerated(false); // TODO make this a better am/pm/24 hour thingy by dividing a day down? DST??? how does that work?? - done on load of value? List<AxisValue> axisValues = new ArrayList<>(); final int step = size / segments; final long dayStartMs = calendar.getTimeInMillis(); final long increment = Constants.DAY_IN_MS / segments; for (int i = 0; i < size; i = i + step) { calendar.setTimeInMillis(dayStartMs + i*increment); axisValues.add(new AxisValue(i / step, timeFormat.format(calendar.getTimeInMillis()).toCharArray())); } xAxis.setValues(axisValues); return xAxis; }
Example 11
Source File: BasalChart.java From xDrip-plus with GNU General Public License v3.0 | 5 votes |
static private Axis chartXAxis(int size) { final Axis xAxis = new Axis(); xAxis.setAutoGenerated(false); xAxis.setHasTiltedLabels(true); xAxis.setTiltAngle(-90f); xAxis.setMaxLabelChars(7); SimpleDateFormat sdf = new SimpleDateFormat(DateFormat.is24HourFormat(xdrip.getAppContext()) ? "HH:mm" : "a h:mm"); DateFormatSymbols symbols = new DateFormatSymbols(Locale.getDefault()); // OVERRIDE SOME symbols WHILE RETAINING OTHERS symbols.setAmPmStrings(new String[] { "a", "p" }); sdf.setDateFormatSymbols(symbols); final java.text.DateFormat timeFormat = sdf; timeFormat.setTimeZone(TimeZone.getTimeZone("UTC")); final GregorianCalendar calendar = new GregorianCalendar(); calendar.setTimeInMillis(JoH.tsl()); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); xAxis.setAutoGenerated(false); // TODO make this a better am/pm/24 hour thingy by dividing a day down? DST??? how does that work?? - done on load of value? List<AxisValue> axisValues = new ArrayList<>(); final int step = size / segments; final long dayStartMs = calendar.getTimeInMillis(); final long increment = Constants.DAY_IN_MS / segments; for (int i = 0; i < size; i = i + step) { calendar.setTimeInMillis(dayStartMs + i*increment); axisValues.add(new AxisValue(i / step, timeFormat.format(calendar.getTimeInMillis()).toCharArray())); } xAxis.setValues(axisValues); return xAxis; }
Example 12
Source File: BgGraphBuilder.java From NightWatch with GNU General Public License v3.0 | 5 votes |
public Axis previewXAxis(){ List<AxisValue> previewXaxisValues = new ArrayList<AxisValue>(); final java.text.DateFormat timeFormat = hourFormat(); timeFormat.setTimeZone(TimeZone.getDefault()); for(int l=0; l<=24; l+=hoursPreviewStep) { double timestamp = (endHour - (60000 * 60 * l)); previewXaxisValues.add(new AxisValue((long)(timestamp/fuzz), (timeFormat.format(timestamp)).toCharArray())); } Axis previewXaxis = new Axis(); previewXaxis.setValues(previewXaxisValues); previewXaxis.setHasLines(true); previewXaxis.setTextSize(previewAxisTextSize); return previewXaxis; }
Example 13
Source File: BgGraph.java From HAPP with GNU General Public License v3.0 | 5 votes |
public Axis previewXAxis() { List<AxisValue> previewXaxisValues = new ArrayList<AxisValue>(); //final java.text.DateFormat timeFormat = hourFormat(); //timeFormat.setTimeZone(TimeZone.getDefault()); for (int l = 0; l <= 26; l += hoursPreviewStep) { //Added 2 hours for future readings double timestamp = (endHour - (60000 * 60 * l)); previewXaxisValues.add(new AxisValue((long) (timestamp), (sdfHour.format(timestamp)).toCharArray())); } Axis previewXaxis = new Axis(); previewXaxis.setValues(previewXaxisValues); previewXaxis.setHasLines(true); previewXaxis.setTextSize(previewAxisTextSize); return previewXaxis; }
Example 14
Source File: BgGraphBuilder.java From NightWatch with GNU General Public License v3.0 | 5 votes |
public Axis previewXAxis(){ List<AxisValue> previewXaxisValues = new ArrayList<AxisValue>(); final java.text.DateFormat timeFormat = hourFormat(); timeFormat.setTimeZone(TimeZone.getDefault()); for(int l=0; l<=24; l+=hoursPreviewStep) { double timestamp = (endHour - (60000 * 60 * l)); previewXaxisValues.add(new AxisValue((long)(timestamp/fuzz), (timeFormat.format(timestamp)).toCharArray())); } Axis previewXaxis = new Axis(); previewXaxis.setValues(previewXaxisValues); previewXaxis.setHasLines(true); previewXaxis.setTextSize(previewAxisTextSize); return previewXaxis; }
Example 15
Source File: BgGraphBuilder.java From xDrip with GNU General Public License v3.0 | 5 votes |
public Axis previewXAxis(){ List<AxisValue> previewXaxisValues = new ArrayList<AxisValue>(); final java.text.DateFormat timeFormat = hourFormat(); timeFormat.setTimeZone(TimeZone.getDefault()); for(int l=0; l<=24; l+=hoursPreviewStep) { double timestamp = (endHour - (60000 * 60 * l)); previewXaxisValues.add(new AxisValue((long)(timestamp/fuzzer), (timeFormat.format(timestamp)).toCharArray())); } Axis previewXaxis = new Axis(); previewXaxis.setValues(previewXaxisValues); previewXaxis.setHasLines(true); previewXaxis.setTextSize(previewAxisTextSize); return previewXaxis; }
Example 16
Source File: MainActivity.java From healthgo with GNU General Public License v3.0 | 4 votes |
private void initLineChart() { Line line = new Line(mPointValues).setColor(Color.parseColor("#FFFAFA")); //折线的颜色(橙色) List<Line> lines = new ArrayList<>(); line.setShape(ValueShape.CIRCLE);//折线图上每个数据点的形状 这里是圆形 (有三种 :ValueShape.SQUARE ValueShape.CIRCLE ValueShape.DIAMOND) line.setCubic(false);//曲线是否平滑,即是曲线还是折线 line.setFilled(false);//是否填充曲线的面积 line.setHasLabels(true);//曲线的数据坐标是否加上备注 // line.setHasLabelsOnlyForSelected(true);//点击数据坐标提示数据(设置了这个line.setHasLabels(true);就无效) line.setHasLines(true);//是否用线显示。如果为false 则没有曲线只有点显示 line.setHasPoints(true);//是否显示圆点 如果为false 则没有原点只有点显示(每个数据点都是个大的圆点) lines.add(line); LineChartData data = new LineChartData(); data.setLines(lines); //坐标轴 Axis axisX = new Axis(); //X轴 axisX.setHasTiltedLabels(true); //X坐标轴字体是斜的显示还是直的,true是斜的显示 axisX.setTextColor(Color.WHITE); //设置字体颜色 //axisX.setName("date"); //表格名称 axisX.setTextSize(10);//设置字体大小 axisX.setMaxLabelChars(8); //最多几个X轴坐标,意思就是你的缩放让X轴上数据的个数7<=x<=mAxisXValues.length axisX.setValues(mAxisXValues); //填充X轴的坐标名称 data.setAxisXBottom(axisX); //x 轴在底部 //data.setAxisXTop(axisX); //x 轴在顶部 axisX.setHasLines(true); //x 轴分割线 // Y轴是根据数据的大小自动设置Y轴上限(在下面我会给出固定Y轴数据个数的解决方案) Axis axisY = new Axis(); axisY.setName("");//y轴标注 // axisY.setTextSize(10);//设置字体大小 axisY.setTextColor(Color.parseColor("#ffffff")); data.setAxisYLeft(axisY); //Y轴设置在左边 //data.setAxisYRight(axisY); //y轴设置在右边 //设置行为属性,支持缩放、滑动以及平移 lineChart.setInteractive(true); lineChart.setZoomType(ZoomType.HORIZONTAL); lineChart.setMaxZoom((float) 2);//最大方法比例 lineChart.setContainerScrollEnabled(true, ContainerScrollType.HORIZONTAL); lineChart.setLineChartData(data); lineChart.setVisibility(View.VISIBLE); /**注:下面的7,10只是代表一个数字去类比而已 * 当时是为了解决X轴固定数据个数。见(http://forum.xda-developers.com/tools/programming/library-hellocharts-charting-library-t2904456/page2); */ // Viewport v = new Viewport(lineChart.getMaximumViewport()); // v.left = 0; // v.right= 7; // lineChart.setCurrentViewport(v); }