Skip to content

Instantly share code, notes, and snippets.

@sohalloran
Last active April 4, 2018 21:07
Show Gist options
  • Save sohalloran/4694551 to your computer and use it in GitHub Desktop.
Save sohalloran/4694551 to your computer and use it in GitHub Desktop.
Visualforce Charting with drill down when clicking on chart sections/bars
<apex:chart height="300" width="300" data="{!data}”>
<apex:axis type="Category" position="bottom" fields="ctype">
<apex:chartLabel rotate="270"/>
</apex:axis>
<apex:axis type="Numeric" position="left" fields="cval"/>
<apex:barSeries axis="left" orientation="vertical" xField="ctype" yField="cval">
<apex:chartTips rendererFn="renderer"/>
</apex:barSeries>
</apex:chart>
<script type="text/javascript">
function renderer(klass, item) {
var type = item.storeItem.get('ctype');
var val = item.storeItem.get('cval');
var e = window.event;
var t = e.target || e.srcElement;
t.onclick=function(event){
window.parent.location = "{!$Page.MyDrilldown}?type="+type;
};
this.setTitle(type + " : " + val);
}
</script>
@priyaponni
Copy link

@sohalloran, This code doesn't work with firefox as window.event should be injected to the function, for it work in firefox. Any pointers how to make this work in Firefox.

Thanks in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment