TeeChart Build 3.2014.0519
IDE Eclipse
Language Android
OS. Windows 7 32 bit
Problem is Loading a png image to back wall so appears between left axis and bottom axis,
but the same image is appearing over left axis see attached file.
Code: Select all
// Code
private void drawGraph(){
//Draw TeeChart
/////////////////////////////////////
int nTests = m_arrayTestData.size();
// chart.setAutoRepaint(false); //optional, disable repaints whilst setting up chart variables
//...call here to any Chart setup routines
// Clear previous graph from chart.
chart.removeAllSeries();
Color clrPanel = new Color(context.getResources().getColor(R.color.Black));
Color clrBlack = new Color(context.getResources().getColor(R.color.Black));
chart.getPanel().setColor(clrPanel);
chart.getAspect().setView3D(false);
//Set legend background black with white text.
chart.getLegend().getBrush().setColor(clrPanel);
Color clrWhite = new Color(context.getResources().getColor(R.color.White));
chart.getLegend().getFont().setColor(clrWhite);
chart.getLegend().getFont().setSize(18);
chart.getLegend().setVisible(false);
//////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////
// Load Graph background with Health Regions Chart.
//////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////
// Load image of Health Regions for background of chart.
/////////////////////////////////////////////////////////
Bitmap bitmapLogo = BitmapFactory.decodeResource(activity.getResources(),
R.drawable.health_regions_chart);
String strFilename = null;
try {
if(bitmapLogo!=null)
//save image to Pictures for Chart to read.
strFilename = saveImage(bitmapLogo,"Health_Regions.png");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
/* Fills whole of graph area to the very edge.
if(strFilename != null)
chart.getPanel().getBrush().loadImage(strFilename);
*/
// Fill between Axises Background.
if(strFilename != null)
chart.getWalls().getBack().getBrush().loadImage(strFilename);
// Set Back wall
chart.getPanel().getGradient().setVisible(false);
chart.getWalls().getBack().getGradient().setVisible(false);
chart.getWalls().getBack().setVisible(true);
// chart.getWalls().getBack().setColor(Color.RED);
chart.getWalls().getLeft().setVisible(false);
chart.getWalls().getRight().setVisible(false);
chart.getWalls().getBottom().setVisible(false);
/** X-Y */
/////////////////////////////
chart.getAxes().getBottom().setIncrement( 1 );
// Plot
try { // X point Y point L
plot = new Points(chart.getChart().chart);
} catch (IllegalArgumentException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
plot.setColor(Color.YELLOW);
plot.getLinePen().width = 50;
/////////////////////////////
//
// Load chart with data.
//
/////////////////////////////
// int i=0;
// for(i=0;i<nTests;i++)
// plot.add( m_arrayTestData.get(i), m_arrayTestData_TestDate.get(i),aDataColor );
plot.add(impedance,phase);
//Box above bars set background to black
// and have white text.
plot.getMarks().getFont().setColor(clrWhite); // Text color.
plot.getMarks().getFont().setSize(18); // Text size Number above bar.
plot.getMarks().getFont().setBold(true);
// No Tick under value above bar.
plot.getMarks().setArrowLength(0); // Places on bar top.
plot.getMarks().getBrush().setColor(clrWhite); // Box color.
// set marks to data value instead of cylinder number?
plot.getMarks().setStyle(MarksStyle.VALUE);
String strTitle = appState.getStateFullName();
strTitle += " "; // Gap between statements.
strTitle += context.getResources().getString(R.string.ProgressFatper);
strTitle += " "; // Gap between statements.
// Display number of tests on title.
String str;
if(m_arrayTestData.size() > 1)
str = String.format("%s %d",
context.getResources().getString(R.string.Tests),m_arrayTestData.size(),locale);
else
str = String.format("%s %d",
context.getResources().getString(R.string.Test),m_arrayTestData.size(),locale);
strTitle += str;
//The background is white.
// So configure text to be black.
chart.getAxes().getLeft().getLabels().getFont().setColor(clrWhite);
// Y Axis
chart.getAxes().getLeft().getAxisPen().setColor(clrWhite);
chart.getAxes().getLeft().getLabels().getFont().setColor(clrWhite);
chart.getAxes().getLeft().getLabels().getFont().setSize(18);
// Y Axis Title.
str = context.getResources().getString(R.string.BioMarker);
chart.getAxes().getLeft().getTitle().setText(str);
chart.getAxes().getLeft().getTitle().getFont().setColor(clrWhite);//
chart.getAxes().getLeft().getTitle().getFont().setSize(18);
// Set Y Axis plot range manually.
chart.getAxes().getLeft().setAutomatic(false);
// Adult Males
if(appState.getStateIntGender() == BioScanConstants.MALE){
chart.getAxes().getLeft().setMaximum(12f);
chart.getAxes().getLeft().setMinimum(2f);
}
else{
// Adult Females and Children
chart.getAxes().getLeft().setMaximum(11f);
chart.getAxes().getLeft().setMinimum(1f);
}
// X -Axis
chart.getAxes().getBottom().setAutomatic(false);
// Adult Males
if(appState.getStateIntGender() == BioScanConstants.MALE){
chart.getAxes().getBottom().setMaximum(750f);
chart.getAxes().getBottom().setMinimum(200f);
}
else{ // Adult Females and Children
chart.getAxes().getBottom().setMaximum(850f);
chart.getAxes().getBottom().setMinimum(300f);
}
chart.getAxes().getBottom().getAxisPen().setColor(clrWhite);
chart.getAxes().getBottom().getLabels().getFont().setColor(clrWhite);
chart.getAxes().getBottom().getLabels().getFont().setSize(18);
chart.getAxes().getBottom().getLabels().getFont().setBold(true);
str = context.getResources().getString(R.string.Impedance);
chart.getAxes().getBottom().getTitle().setText(str);
chart.getAxes().getBottom().getTitle().getFont().setSize(18);
chart.getAxes().getBottom().getTitle().getFont().setColor(clrWhite);
// Graph Title
// No Title
// chart.getHeader().getFont().setSize(24);
strTitle = "";
chart.getHeader().setText(strTitle);
// chart.getHeader().getFont().setColor(clrWhite);
// left axis grid
chart.getAxes().getLeft().getGrid().setColor(clrBlack);
// bottom axis grid
chart.getAxes().getBottom().getGrid().setColor(clrBlack);
// similar function for getTop() and getRight() grids.
// Removes outer rectangle round whole of graph
// chart.getPanel().setBevelOuter(BevelStyle.NONE);
// Diagnoised
/***
String msg;
String strFullname = appState.getStateFullName();
int n = m_arrayTestData.size();
msg = String.format("%s %s %d %s %d",
"Drawn Graph",strFullname,n,dataName,dataItem);
DisplayToast(msg);
**/
/*
// Save bar chart to Bitmap file.
chart.doInvalidate();
Image image = chart.getExport().getImage().image(400, 200);
// Save to Android memory folder
// data/data/(app id)in.wptrafficanalyzer.viewpagerdemo/files
try {
FileOutputStream out = activity.openFileOutput("targetFat.png", Context.MODE_PRIVATE);
image.save(out);
out.flush();
out.close();
} catch (Exception e) {
e.printStackTrace();
}
*/
}// End of drawGraph