function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Soumya sri yaravaSoumya sri yarava 

how to pass the values in x co-ordinate and Y-cordinate in apex to display

public class OrignContrl {

  public decimal xvalue{get;set;}
  
   public decimal yvalue{get;set;}
   
   public string Totalcost{get;set;}
   
     public OrignContrl(){
      Totalcost ='Testing';
      }


    public void setvalues(){
    xvalue =48.05;
    yvalue =50.06;
   
     }
    
}

visualForce page:

 
<apex:page controller="OrignContrl" >
 <apex:form >
 <apex:commandButton value="Display in selected format" Action="{!setvalues}" />
 <apex:outputLabel >{!Totalcost}</apex:outputLabel>
 </apex:form>
</apex:page>

onclick on the button the values assigned to the particular outputlabel and display

thanks and regards
soumya reddy
Santosh Kumar 348Santosh Kumar 348
Hi Soumya,

If I understand your question you want to bind the values and display it on the page once button is clicked.

VF Page:
<apex:page controller="OrignContrl" >
    <apex:form >
        <apex:commandButton value="Display in selected format" action="{!setvalues}" />
        <apex:outputLabel >{!Totalcost}</apex:outputLabel>
    </apex:form>
</apex:page>

Apex Class:
public class OrignContrl {
    
    public decimal xvalue{get;set;}
    public decimal yvalue{get;set;}
    public decimal Totalcost{get;set;}
    
    public OrignContrl(){
        Totalcost = 0 ;
    }
    public void setvalues(){
        xvalue =48.05;
        yvalue =50.06;
        Totalcost = xvalue + yvalue;
    }
}

As you want to add the value and display in TotalCost so I have changed the data type from String to Decimal.
Basically whatever value you want to display on page can be easily habdled with {get;set;}

If this answer helps you then please mark it as a Best Answer, so that it will help others.


Regards,
Santosh Kumar 
 
Soumya sri yaravaSoumya sri yarava
hi santhosh , thanks for ur reply ,its not about adding the value , 
 
it is like garph, need to assign the values in x-axis and y-axis as the values changes it should have to change the location.

NOTE: Depending upon the values, the  location of the outputlabel should change.

its all about location


hope u understand my requirement,

thanks and regards
soumye



 
Santosh Kumar 348Santosh Kumar 348
Can you please elaborate your requirement what you are trying to achieve over here. Is it something related to chart?
 
Soumya sri yaravaSoumya sri yarava
hi santhosh, its like 
top: 0px; bottom: 0px; left: 0px; right: 0px; margin: auto; position: absolute; in style in css , can we take this scenario in the apex
to print the value in the particular desired position .
thanks 
soumya
 
Santosh Kumar 348Santosh Kumar 348
Hi Soumya,

You can bind any value to style attribute in  the way you bind normal variable. Refer below example:
 
<apex:page controller="OrignContrl" >
    <apex:form >
        <div style="top:{!top}!important; position: absolute;">
            <apex:outputLabel style="font-size:{!fontSize};padding-top: {!paddTop}; padding-left: {!paddLeft}; right: 0px; ">{!StyleApplied}</apex:outputLabel><br/>            
            
            <apex:commandButton value="Display in selected format" action="{!setvalues}" />
        </div>
    </apex:form>
</apex:page>
public class OrignContrl {
    
    public String paddLeft{get;set;}
    public String paddTop{get;set;}
    public String fontSize{get;set;}
    public String StyleApplied{get;set;}
    public String top{get;set;}
    
    public OrignContrl(){
        
        paddLeft = '0px';
        paddTop = '0px';
        fontSize = '10px';
        top = '0px';
        StyleApplied = 'Initial Style applied: padding-left : '+ paddLeft + ' padding-top:'+paddTop+' font:'+fontSize+' top:'+top ;
       
    }
    public void setvalues(){
        paddLeft = '30px';
        paddTop ='30px';
        fontSize = '20px';
        top = '40px';
        StyleApplied = 'New Style applied: padding-left : '+ paddLeft + ' padding-top:'+paddTop+' font:'+fontSize+' top:'+top ;
    }
}

If you will see I have applied some initial css to the label and I am changing it on button click same is reflected in Label as well you will see the updated value and the style is getting changed.

If this answer helps you then please mark it as a Best Answer, so that it will help others.

Regards,
Santosh Kumar