Saturday, 20 June 2015
Email and Phone Validation
Friday, 17 April 2015
Custom Lookup Salesforce
<apex:page standardController="Contact" extensions="MyCustomLookupController" id="Page" tabstyle="Contact"> <script type="text/javascript"> function openLookup(baseURL, width, modified, searchParam){ var originalbaseURL = baseURL; var originalwidth = width; var originalmodified = modified; var originalsearchParam = searchParam; alert(modified+'hello'+baseURL); var lookupType = baseURL.substr(baseURL.length-3, 3); if (modified == '1') baseURL = baseURL + searchParam; var isCustomLookup = false; // Following "001" is the lookup type for Account object so change this as per your standard or custom object if(lookupType == "001"){ var urlArr = baseURL.split("&"); var txtId = ''; if(urlArr.length > 2) { urlArr = urlArr[1].split('='); txtId = urlArr[1]; } // Following is the url of Custom Lookup page. You need to change that accordingly baseURL = "/apex/CustomAccountLookup?txt=" + txtId; // Following is the id of apex:form control "myForm". You need to change that accordingly baseURL = baseURL + "&frm=" + escapeUTF("{!$Component.myForm}"); if (modified == '1') { baseURL = baseURL + "&lksearch=" + searchParam; } // Following is the ID of inputField that is the lookup to be customized as custom lookup if(txtId.indexOf('Account') > -1 ){ isCustomLookup = true; } } if(isCustomLookup == true){ openPopup(baseURL, "lookup", 350, 480, "width="+width+",height=480,toolbar=no,status=no,directories=no,menubar=no,resizable=yes,scrollable=no", true); } else { if (modified == '1') originalbaseURL = originalbaseURL + originalsearchParam; openPopup(originalbaseURL, "lookup", 350, 480, "width="+originalwidth+",height=480,toolbar=no,status=no,directories=no,menubar=no,resizable=yes,scrollable=no", true); } } </script> <apex:sectionHeader title="Demo" subtitle="Custom Lookup" /> <apex:form id="myForm"> <apex:PageBlock id="PageBlock"> <apex:pageBlockButtons > <apex:commandButton action="{!Save}" value="Save"/> </apex:pageBlockButtons> <apex:pageBlockSection columns="1" title="Custom Lookup"> <apex:inputField value="{!Contact.LastName}"/> <apex:inputField id="Account" value="{!contact.AccountId}" /> <apex:inputField id="owner" value="{!contact.HR_Manager__c}" /> </apex:pageBlockSection> </apex:PageBlock> </apex:form> </apex:page> ===========================<apex:page controller="CustomAccountLookupController" title="Search" showHeader="false" sideBar="false" tabStyle="Account" id="pg"> <apex:form > <apex:outputPanel id="page" layout="block" style="margin:5px;padding:10px;padding-top:2px;"> <apex:tabPanel switchType="client" selectedTab="name1" id="tabbedPanel"> <!-- SEARCH TAB --> <apex:tab label="Search" name="tab1" id="tabOne"> <apex:actionRegion > <apex:outputPanel id="top" layout="block" style="margin:5px;padding:10px;padding-top:2px;"> <apex:outputLabel value="Search" style="font-weight:Bold;padding-right:10px;" for="txtSearch"/> <apex:inputText id="txtSearch" value="{!searchString}" /> <span style="padding-left:5px"><apex:commandButton id="btnGo" value="Go" action="{!Search}" rerender="searchResults"></apex:commandButton></span> </apex:outputPanel> <apex:outputPanel id="pnlSearchResults" style="margin:10px;height:350px;overflow-Y:auto;" layout="block"> <apex:pageBlock id="searchResults"> <apex:pageBlockTable value="{!results}" var="a" id="tblResults"> <apex:column > <apex:facet name="header"> <apex:outputPanel >Name</apex:outputPanel> </apex:facet> <apex:outputLink value="javascript:top.window.opener.lookupPick2('{!FormTag}','{!TextBox}_lkid','{!TextBox}','{!a.Id}','{!a.Name}', false)" rendered="{!NOT(ISNULL(a.Id))}">{!a.Name}</apex:outputLink> </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:outputPanel> </apex:actionRegion> </apex:tab> <!-- NEW ACCOUNT TAB --> <!-- <apex:tab label="New Account" name="tab2" id="tabTwo"> <apex:pageBlock id="newAccount" title="New Account" > <apex:pageBlockButtons > <apex:commandButton action="{!saveAccount}" value="Save"/> </apex:pageBlockButtons> <apex:pageMessages /> <apex:pageBlockSection columns="2"> <apex:repeat value="{!$ObjectType.Account.FieldSets.CustomAccountLookup}" var="f"> <apex:inputField value="{!Account[f]}"/> </apex:repeat> </apex:pageBlockSection> </apex:pageBlock> </apex:tab>--> </apex:tabPanel> </apex:outputPanel> </apex:form> </apex:page>======================public with sharing class MyCustomLookupController {
private ApexPages.StandardController con;
public Contact contact {get;set;}
public MyCustomLookupController(ApexPages.StandardController controller) {
con=controller;
contact = new Contact();
}
public MyCustomLookupController() {
}
public PageReference Save()
{
// con.save();
ApexPages.StandardController c=new ApexPages.StandardController(contact );
c.save();
PageReference goTothis=new PageReference('/'+c.getId());
goTothis.setRedirect(true);
return goTothis;
}
}===============
| public with sharing class CustomAccountLookupController { public Account account {get;set;} // new account to create public List<Account> results{get;set;} // search results public string searchString{get;set;} // search keyword public CustomAccountLookupController() { account = new Account(); // get the current search string searchString = System.currentPageReference().getParameters().get('krishna'); runSearch(); } // performs the keyword search public PageReference search() { runSearch(); return null; } // prepare the query and issue the search command private void runSearch() { // TODO prepare query string for complex serarches & prevent injections results = performSearch(searchString); } // run the search and return the records found. private List<Account> performSearch(string searchString) { String soql = 'select id, name from account '; if(searchString != '' && searchString != null) soql = soql + ' where name LIKE \'%' + searchString +'%\''; soql = soql + ' limit 25'; System.debug(soql); return database.query(soql); } // save the new account record public PageReference saveAccount() { insert account; // reset the account account = new Account(); return null; } // used by the visualforce page to send the link to the right dom element public string getFormTag() { return System.currentPageReference().getParameters().get('frm'); } // used by the visualforce page to send the link to the right dom element for the text box public string getTextBox() { return System.currentPageReference().getParameters().get('txt'); } } |
Wednesday, 10 December 2014
Monday, 13 October 2014
Pie Chart google
- ▸Overview
- ▾Chart Gallery
- Miscellaneous Examples
- Annotation Charts
- Area Charts
- Bar Charts
- Bubble Charts
- Calendar Charts
- Candlestick Charts
- Column Charts
- Combo Charts
- Diff Charts
- Gauge Charts
- Geo Charts
- Histograms
- Intervals
- Line Charts
- Maps
- Org Charts
- Pie Charts
- Sankey Diagrams
- Scatter Charts
- Stepped Area Charts
- Table Charts
- Timelines
- Tree Map Charts
- Trendlines
- Word TreesNew!
- ▸Advanced Usage
- ▸Community
- ▸API Reference
- Google Chart News
- ▸Related Chart Tools
- ▸Terms and Conditions
Visualization: Pie Chart
- Overview
- A Simple Example
- Making a 3D Pie Chart
- Making a Donut Chart
- Rotating a Pie Chart
- Exploding a Slice
- Removing Slices
- Loading
- Data Format
- Configuration Options
- Methods
- Events
- Data Policy
Overview
A pie chart that is rendered within the browser using SVG or VML. Displays tooltips when hovering over slices.
Example
<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Task', 'Hours per Day'],
['Work', 11],
['Eat', 2],
['Commute', 2],
['Watch TV', 2],
['Sleep', 7]
]);
var options = {
title: 'My Daily Activities'
};
var chart = new google.visualization.PieChart(document.getElementById('piechart'));
chart.draw(data, options);
}
</script>
</head>
<body>
<div id="piechart" style="width: 900px; height: 500px;"></div>
</body>
</html>
Making a 3D Pie Chart
If you set the is3D option to true, your pie chart will be drawn as though it has three dimensions:
is3D is false by default, so here we explicitly set it to true:
<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Task', 'Hours per Day'],
['Work', 11],
['Eat', 2],
['Commute', 2],
['Watch TV', 2],
['Sleep', 7]
]);
var options = {
title: 'My Daily Activities',
is3D: true,
};
var chart = new google.visualization.PieChart(document.getElementById('piechart_3d'));
chart.draw(data, options);
}
</script>
</head>
<body>
<div id="piechart_3d" style="width: 900px; height: 500px;"></div>
</body>
</html>
Making a Donut Chart
A donut chart is a pie chart with a hole in the center. You can create donut charts with the pieHole option:
The pieHole option should be set to a number between 0 and 1, corresponding to the ratio of radii between the hole and the chart. Numbers between 0.4 and 0.6 will look best on most charts. Values equal to or greater than 1 will be ignored, and a value of 0 will completely shut your piehole.
<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Task', 'Hours per Day'],
['Work', 11],
['Eat', 2],
['Commute', 2],
['Watch TV', 2],
['Sleep', 7]
]);
var options = {
title: 'My Daily Activities',
pieHole: 0.4,
};
var chart = new google.visualization.PieChart(document.getElementById('donutchart'));
chart.draw(data, options);
}
</script>
</head>
<body>
<div id="donutchart" style="width: 900px; height: 500px;"></div>
</body>
</html>
You can't combine the pieHole and is3D options; if you do, pieHole will be ignored.
Rotating a Pie Chart
By default, pie charts begin with the left edge of the first slice pointing straight up. You can change that with the pieStartAngle option:
Here, we rotate the chart clockwise 100 degrees with an option of pieStartAngle: 100. (So chosen because that particular angle happens to make the "Italian" label fit inside the slice.)
<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Language', 'Speakers (in millions)'],
['German', 5.85],
['French', 1.66],
['Italian', 0.316],
['Romansh', 0.0791]
]);
var options = {
legend: 'none',
pieSliceText: 'label',
title: 'Swiss Language Use (100 degree rotation)',
pieStartAngle: 100,
};
var chart = new google.visualization.PieChart(document.getElementById('piechart'));
chart.draw(data, options);
}
</script>
</head>
<body>
<div id="piechart" style="width: 900px; height: 500px;"></div>
</body>
</html>
Exploding a Slice
You can separate pie slices from the rest of the chart with the offset property of the slices option: To separate a slice, create a slices object and assign the appropriate slice number an offset between 0 and 1. Below, we assign progressively larger offsets to slices 4 (Gujarati), 12 (Marathi), 14 (Oriya), and 15 (Punjabi):
<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Language', 'Speakers (in millions)'],
['Assamese', 13], ['Bengali', 83], ['Bodo', 1.4],
['Dogri', 2.3], ['Gujarati', 46], ['Hindi', 300],
['Kannada', 38], ['Kashmiri', 5.5], ['Konkani', 5],
['Maithili', 20], ['Malayalam', 33], ['Manipuri', 1.5],
['Marathi', 72], ['Nepali', 2.9], ['Oriya', 33],
['Punjabi', 29], ['Sanskrit', 0.01], ['Santhali', 6.5],
['Sindhi', 2.5], ['Tamil', 61], ['Telugu', 74], ['Urdu', 52]
]);
var options = {
title: 'Indian Language Use',
legend: 'none',
pieSliceText: 'label',
slices: { 4: {offset: 0.2},
12: {offset: 0.3},
14: {offset: 0.4},
15: {offset: 0.5},
},
};
var chart = new google.visualization.PieChart(document.getElementById('piechart'));
chart.draw(data, options);
}
</script>
</head>
<body>
<div id="piechart" style="width: 900px; height: 500px;"></div>
</body>
</html>
Removing Slices
To omit a slice, change the color to 'transparent':
We also used the pieStartAngle to rotate the chart 135 degrees, pieSliceText to remove the text from the slices, and tooltip.trigger to disable tooltips:
<html> <head> <script type="text/javascript" src="https://www.google.com/jsapi"></script> <script type="text/javascript"> google.load("visualization", "1", {packages:["corechart"]}); google.setOnLoadCallback(drawChart); function drawChart() { var data = google.visualization.arrayToDataTable([ ['Pac Man', 'Percentage'], ['', 75], ['', 25] ]); var options = { legend: 'none', pieSliceText: 'none', pieStartAngle: 135, tooltip: { trigger: 'none' }, slices: { 0: { color: 'yellow' }, 1: { color: 'transparent' } } }; var chart = new google.visualization.PieChart(document.getElementById('pacman')); chart.draw(data, options); } </script> </head> <body> <div id="pacman" style="width: 900px; height: 500px;"></div> </body> </html>
Loading
The google.load package name is "corechart".
google.load("visualization", "1", {packages: ["corechart"]});
The visualization's class name is google.visualization.PieChart.
var visualization = new google.visualization.PieChart(container);
Data Format
Rows: Each row in the table represents a slice.
Columns:
| Column 0 | Column 1 | |
|---|---|---|
| Purpose: | Slice labels | Slice values |
| Data Type: | string | number |
| Role: | domain | data |
| Optional column roles: | None | None |
Configuration Options
| Name | Type | Default | Description |
|---|---|---|---|
| backgroundColor | string or object | 'white' | The background color for the main area of the chart. Can be either a simple HTML color string, for example: 'red' or '#00cc00', or an object with the following properties. |
| backgroundColor.stroke | string | '#666' | The color of the chart border, as an HTML color string. |
| backgroundColor.strokeWidth | number | 0 | The border width, in pixels. |
| backgroundColor.fill | string | 'white' | The chart fill color, as an HTML color string. |
| chartArea | Object | null | An object with members to configure the placement and size of the chart area (where the chart itself is drawn, excluding axis and legends). Two formats are supported: a number, or a number followed by %. A simple number is a value in pixels; a number followed by % is a percentage. Example: chartArea:{left:20,top:0,width:'50%',height:'75%'} |
| chartArea.backgroundColor | string or object | 'white' | Chart area background color. When a string is used, it can be either a hex string (e.g., '#fdc') or an English color name. When an object is used, the following properties can be provided:
|
| chartArea.left | number or string | auto | How far to draw the chart from the left border. |
| chartArea.top | number or string | auto | How far to draw the chart from the top border. |
| chartArea.width | number or string | auto | Chart area width. |
| chartArea.height | number or string | auto | Chart area height. |
| colors | Array of strings | default colors | The colors to use for the chart elements. An array of strings, where each element is an HTML color string, for example: colors:['red','#004411']. |
| enableInteractivity | boolean | true | Whether the chart throws user-based events or reacts to user interaction. If false, the chart will not throw 'select' or other interaction-based events (but willthrow ready or error events), and will not display hovertext or otherwise change depending on user input. |
| fontSize | number | automatic | The default font size, in pixels, of all text in the chart. You can override this using properties for specific chart elements. |
| fontName | string | 'Arial' | The default font face for all text in the chart. You can override this using properties for specific chart elements. |
| forceIFrame | boolean | false | Draws the chart inside an inline frame. (Note that on IE8, this option is ignored; all IE8 charts are drawn in i-frames.) |
| height | number | height of the containing element | Height of the chart, in pixels. |
| is3D | boolean | false | If true, displays a three-dimensional chart. |
| legend | Object | null | An object with members to configure various aspects of the legend. To specify properties of this object, you can use object literal notation, as shown here: |
| legend.alignment | string | automatic | Alignment of the legend. Can be one of the following:
Start, center, and end are relative to the style -- vertical or horizontal -- of the legend. For example, in a 'right' legend, 'start' and 'end' are at the top and bottom, respectively; for a 'top' legend, 'start' and 'end' would be at the left and right of the area, respectively. The default value depends on the legend's position. For 'bottom' legends, the default is 'center'; other legends default to 'start'. |
| legend.position | string | 'right' | Position of the legend. Can be one of the following:
|
| legend.maxLines | number | 1 | Maximum number of lines in the legend. Set this to a number greater than one to add lines to your legend. Note: The exact logic used to determine the actual number of lines rendered is still in flux. This option currently works only when legend.position is 'top'. |
| legend.textStyle | Object | {color: 'black', fontName: <global-font-name>, fontSize: <global-font-size>} | An object that specifies the legend text style. The object has this format: { color: <string>, fontName: <string>, fontSize: <number>, bold: <boolean>, italic: <boolean> } The |
| pieHole | number | 0 | If between 0 and 1, displays a donut chart. The hole with have a radius equal tonumber times the radius of the chart. |
| pieSliceBorderColor | string | 'white' | The color of the slice borders. Only applicable when the chart is two-dimensional. |
| pieSliceText | string | 'percentage' | The content of the text displayed on the slice. Can be one of the following:
|
| pieSliceTextStyle | Object | {color: 'black', fontName: <global-font-name>, fontSize: <global-font-size>} | An object that specifies the slice text style. The object has this format: {color: <string>, fontName: <string>, fontSize: <number>}The |
| pieStartAngle | Number | 0 | The angle, in degrees, to rotate the chart by. The default of |
| reverseCategories | boolean | false | If true, draws slices counterclockwise. The default is to draw clockwise. |
| pieResidueSliceColor | string | '#ccc' | Color for the combination slice that holds all slices belowsliceVisibilityThreshold. |
| pieResidueSliceLabel | string | 'Other' | A label for the combination slice that holds all slices belowsliceVisibilityThreshold. |
| slices | Array of objects, or object with nested objects | {} | An array of objects, each describing the format of the corresponding slice in the pie. To use default values for a slice, specify an empty object (i.e.,
You can specify either an array of objects, each of which applies to the slice in the order given, or you can specify an object where each child has a numeric key indicating which slice it applies to. For example, the following two declarations are identical, and declare the first slice as black and the fourth as red: slices: [{color: 'black', {}, {}, {color: 'red'}] slices: {0: {color: 'black'}, 3: {color: 'red'}} |
| sliceVisibilityThreshold | number | 1/720 | The slice relative part, below which a slice will not show individually. All slices that have not passed this threshold will be combined to a single slice, whose size is the sum of all their sizes. Default is not to show individually any slice which is smaller than half a degree. |
| title | string | no title | Text to display above the chart. |
| titleTextStyle | Object | {color: 'black', fontName: <global-font-name>, fontSize: <global-font-size>} | An object that specifies the title text style. The object has this format: { color: <string>, fontName: <string>, fontSize: <number>, bold: <boolean>, italic: <boolean> } The |
| tooltip | Object | null | An object with members to configure various tooltip elements. To specify properties of this object, you can use object literal notation, as shown here: {textStyle: {color: '#FF0000'}, showColorCode: true} |
| tooltip.showColorCode | boolean | false | If true, show colored squares next to the slice information in the tooltip. |
| tooltip.text | string | 'both' | What information to display when the user hovers over a pie slice. The following values are supported:
|
| tooltip.textStyle | Object | {color: 'black', fontName: <global-font-name>, fontSize: <global-font-size>} | An object that specifies the tooltip text style. The object has this format: { color: <string>, fontName: <string>, fontSize: <number>, bold: <boolean>, italic: <boolean> } The |
| tooltip.trigger | string | 'focus' | The user interaction that causes the tooltip to be displayed:
|
| width | number | width of the containing element | Width of the chart, in pixels. |
Methods
| Method | Return Type | Description |
|---|---|---|
draw(data, options) | none | Draws the chart. The chart accepts further method calls only after the ready event is fired.Extended description. |
getBoundingBox(id) | Object | Returns an object containing the left, top, width, and height of chart element
Values are relative to the container of the chart. Call this after the chart is drawn. |
getChartAreaBoundingBox() | Object | Returns an object containing the left, top, width, and height of the chart content (i.e., excluding labels and legend):
Values are relative to the container of the chart. Call this after the chart is drawn. |
getChartLayoutInterface() | Object | Returns an object containing information about the onscreen placement of the chart and its elements. The following methods can be called on the returned object:
Call this after the chart is drawn. |
getHAxisValue(position, optional_axis_index) | Number | Returns the logical horizontal value at Example: Call this after the chart is drawn. |
getImageURI() | String | Returns the chart serialized as an image URI. Call this after the chart is drawn. See Printing PNG Charts. |
getSelection() | Array of selection elements | Returns an array of the selected chart entities. Selectable entities are slices and legend entries. A slice or legend entry correlates to a row in the data table (column index is null). For this chart, only one entity can be selected at any given moment. Extended description. |
getVAxisValue(position, optional_axis_index) | Number | Returns the logical vertical value at Example: Call this after the chart is drawn. |
getXLocation(position, optional_axis_index) | Number | Returns the screen x-coordinate of Example: Call this after the chart is drawn. |
getYLocation(position, optional_axis_index) | Number | Returns the screen y-coordinate of Example: Call this after the chart is drawn. |
setSelection() | none | Selects the specified chart entities. Cancels any previous selection. Selectable entities are slices and legend entries. A slice or legend entry correlates to a row in the data table (column index is null). For this chart, only one entity can be selected at a time. Extended description. |
clearChart() | none | Clears the chart, and releases all of its allocated resources. |
Events
For more information on how to use these events, see Basic Interactivity, Handling Events, and Firing Events.
| Name | Description | Properties |
|---|---|---|
click | Fired when the user clicks inside the chart. Can be used to identify when the title, data elements, legend entries, axes, gridlines, or labels are clicked. | targetID |
error | Fired when an error occurs when attempting to render the chart. | id, message |
onmouseover | Fired when the user mouses over a visual entity. Passes back the row and column indices of the corresponding data table element. A slice or legend entry correlates to a row in the data table (column index is null). | row, column |
onmouseout | Fired when the user mouses away from a visual entity. Passes back the row and column indices of the corresponding data table element. A slice or legend entry correlates to a row in the data table (column index is null). | row, column |
ready | The chart is ready for external method calls. If you want to interact with the chart, and call methods after you draw it, you should set up a listener for this event before you call the draw method, and call them only after the event was fired. | None |
select | Fired when the user clicks a visual entity. To learn what has been selected, call getSelection(). | None |
Data Policy
All code and data are processed and rendered in the browser. No data is sent to any server.
Salvo indicação em contrário, o conteúdo desta página está licenciado de acordo com a Licença de Atribuição 3.0 do Creative Commons, e as amostras de código estão licenciadas de acordo com a Licença do Apache 2.0. Para ver detalhes, consulte nossas Políticas de sites.




