I have an ecg graph plotting application and the graph looks like this.
What I need to know is,is it possible to know the subgrid in which the point is plotted... say in a format like (row_index,column_index) or something like this. Actually I don't know whether it is a possible scenario. So if there is no way to do this please let me know. Given below is my graph configuring method.
private void configureGraph() {
/**
* ecgPlot corresponds to XYPlot
*/
XYGraphWidget graph = ecgPlot.getGraph();
/**
* Paint to denote line color
*/
Paint paint = new Paint();
paint.setColor(Color.WHITE);
paint.setStrokeWidth(3.0f);
/**
* Setting graph x and y boundary values
*/
ecgPlot.setRangeBoundaries(-40, 40, BoundaryMode.FIXED);
ecgPlot.setDomainBoundaries(0, 1500, BoundaryMode.FIXED);
ecgPlot.setPlotPadding(-10, 0, 0, 0);
/**
* Removes default bkg - ie; black
*/
ecgPlot.setBackgroundPaint(null);
graph.setBackgroundPaint(null);
graph.setGridBackgroundPaint(null);
/**
* Adjusting grid line width
*/
graph.getDomainGridLinePaint().setStrokeWidth(4.0f);
graph.getRangeGridLinePaint().setStrokeWidth(4.0f);
graph.getDomainSubGridLinePaint().setStrokeWidth(1.0f);
graph.getRangeSubGridLinePaint().setStrokeWidth(1.0f);
/**
* Removes border
*/
ecgPlot.setBorderPaint(null);
/**
* Setting grid color
*/
graph.getDomainGridLinePaint().setColor(getResources().getColor(R.color.colorECGGrid));
graph.getRangeGridLinePaint().setColor(getResources().getColor(R.color.colorECGGrid));
graph.getRangeSubGridLinePaint().setColor(getResources().getColor(R.color.colorECGGrid));
graph.getDomainSubGridLinePaint().setColor(getResources().getColor(R.color.colorECGGrid));
/**
* Setting number of sub grid lines per grid
*/
graph.setLinesPerDomainLabel(5);
graph.setLinesPerRangeLabel(5);
ecgPlot.setRangeStep(StepMode.INCREMENT_BY_VAL, 1);
ecgPlot.setDomainStepValue(75);
ecgPlot.setLinesPerDomainLabel(5);
ecgPlot.setDomainLabel(null);
ecgPlot.setRangeLabel(null);
Paint paintTest = new Paint();
paintTest.setColor(Color.TRANSPARENT);
paintTest.setStrokeWidth(3.0f);
ecgLinePointFormatter.setLegendIconEnabled(false);
// PointLabelFormatter pointLabelFormatter = new PointLabelFormatter();
// pointLabelFormatter.setTextPaint(paint);
}
Thanks in advance
Unfortunately I'm not at a place where I can actually test whether this code works, but here's a general idea on how you can convert from real XY values into subgrid coords:
Then, given Number x and Number y that you want to convert into subgrid coords:
If you need pixel values instead of real values, you can use the
XYPlot.seriesToScreenX/Y(Number)
andXYPlot.screenToSeriesX/Y(Number)
methods to convert back and forth.