Page 1 of 1

Back Wall LoadImage

Posted: Thu Oct 02, 2014 10:55 am
by 16967738
Good Morning

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

Re: Back Wall LoadImage

Posted: Thu Oct 02, 2014 1:37 pm
by yeray
Hello,

I'm afraid there are some functions and resources I don't have here so we can't run this here.
Could you please arrange a simple but self-containing example we can run as-is to reproduce the problem here?
http://www.sscce.org/

Thanks in advance.

Re: Back Wall LoadImage

Posted: Fri Oct 03, 2014 1:54 pm
by 16967738
To Yeray
Thank-you for the quick response.

Please find attached zip file containing three files

MainActivity.java self containing example
healthregionschart.png background image used to go over chart
and the manifest because need to set Write internal storage and write external storage permissions.

The example shows image between axis as required.
But there is a second reduced image overlapping the y-Axis.

Re: Back Wall LoadImage

Posted: Fri Oct 03, 2014 3:50 pm
by yeray
Hello,

Simplifying your testing app, this still reproduces the problem:

Code: Select all

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        createChart();
        testLoadImage();
    }

	private TChart tChart1;
	private void createChart() {
		LinearLayout layout = (LinearLayout) findViewById(R.id.chart_layout1);
		tChart1 = new TChart(this);
		layout.addView(tChart1);
	}

	private void testLoadImage() {
		
		tChart1.getAspect().setView3D(false);
		
		Bitmap bitmapLogo = BitmapFactory.decodeResource(
				getApplicationContext().getResources(),
				R.drawable.health_regions_chart);
		
		tChart1.getWalls().getBack().getBrush().setImage(new Image(bitmapLogo));
	}
I've added this to the public tracker:
http://bugs.teechart.net/show_bug.cgi?id=943

Re: Back Wall LoadImage

Posted: Mon Oct 06, 2014 11:36 am
by 16967738
Yeray,

When can I expect this bug to be fixed as required by our Android program?

Solomon

Re: Back Wall LoadImage

Posted: Tue Oct 07, 2014 1:20 pm
by yeray
Hi Solomon,
sol wrote:When can I expect this bug to be fixed as required by our Android program?
I've just applied a fix for this in our internal sources and I've closed the ticket, so the next maintenance release will include the fix.

Re: Back Wall LoadImage

Posted: Wed Oct 08, 2014 11:57 am
by 16967738
To Yeray,

Excellent news that you have fixed the problem.

Could you please explain how to download the Maintenance Release. (Android Mobile)

Re: Back Wall LoadImage

Posted: Wed Oct 08, 2014 12:08 pm
by yeray
Hi,
sol wrote:Could you please explain how to download the Maintenance Release. (Android Mobile)
The maintenance releases are announced in the news feed, this forum, Twitter and Facebook.
I'm afraid I can't tell you when the next one (including this fix) will be published.
When it will be published and announced, the download will be available in the client area, as usual.