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
CushtyCushty 

Opening visualforce chart in current window or new tab

Hi,

I am new to Apex and visualforce and having ago!

I have managed to create a small visualforce page to show charts on my projects page which filters fine using the following code (section of): -
<apex:page StandardController="pse__Proj__c">
   <apex:pageblock >
        <apex:pageblockSection columns="4">
               <analytics:reportChart reportId="00OJ0000000hi2k" 
                    filter="{column:'pse__Proj__c.Name', operator:'equals', value:'{!pse__Proj__c.Name}'}" size="small">
        </analytics:reportChart>

When I click on this it opens the report within the small visualforce section and I would like this chart, when clicked to open in a new window, or even in a new tab.

Do I need a controller for this or is it simple code like open.window...parent etc ...
Thanks

Me
R Z KhanR Z Khan
Hi,

where are you opening this page from?
On another note, you shouldn't hard code the report id. try saving it in cusotm setting, as the report id will chaneg when you deploy to production
CushtyCushty
Hi,
Its sitting on a custom objects page layout as a visualforce component.  SO a user clicks it and it just opens the visualforce component into a report where as I would rather be able to open the report in a new window or new tab if that makes sense
I didn't think if that withthe report ID, I will have a look at creating on of those 
Puneet KhoslaPuneet Khosla
<apex:page StandardController="pse__Proj__c">
<script type="text/javascript">
function Test(){
var url = '/00OJ0000000hi2k';
window.parent.location.replace(url);
}
</script>
<apex:outputLink onclick="Test();">
<analytics:reportChart reportId="00OJ0000000hi2k" 
                    filter="{column:'pse__Proj__c.Name', operator:'equals', value:'{!pse__Proj__c.Name}'}" size="small">
        </analytics:reportChart>
</apex:outputLink>
</apex:page>
goabhigogoabhigo
This doesn't work either. Did anyone get solution for this? I also have tried <a> tag, but it opens in the existing tag.