I'm trying to refresh a chart using a SelectList tag. If i understand correctly, my "chartPeriod" variable should be updated to the selected value on every change(and the chart refreshed thanks to the apex:actionSupport tag). With debug logs though, I can see the value does not even get to the controller.

Any idea why ?

I can post all the code if needed but there is a lot irrelevant since the chart without filter is working fine. I've reviewed some posts with similar issues but couldn't find a fix.


My controller :

public class PipeChartController {

public Date chartPeriod{
        if(chartPeriod==null) chartPeriod = thisYear();
        return chartPeriod;

// Periods available to be charted, for <apex:selectList>
public static List<SelectOption> getChartPeriodOptions() {

    List<SelectOption> periods = new List<SelectOption>();

    String thisYear = String.valueOf(thisYear());
    periods.add(new SelectOption(thisYear,thisYear));

    String thisQuarter = String.valueOf(thisQuarter());
    periods.add(new SelectOption(thisQuarter,thisQuarter));

    String thisWeek = String.valueOf(thisWeek());
    periods.add(new SelectOption(thisWeek,thisWeek));

    return periods;

// Return a list of data points for a chart
public List<Data> getData() {
    return PipeChartController.getChartData(this.chartPeriod);

// Make the chart data available via JavaScript remoting
public static List<Data> getRemoteData(Date period) {
    return PipeChartController.getChartData(period);

// The actual chart data; needs to be static to be
// called by a @RemoteAction method
public static List<Data> getChartData(Date period) {
    //querying & formatting data for the chart
    return data;

public static Date thisYear(){
    Project_Budget__c[] thisYear = [Select createdDate from Project_Budget__c where createdDate=this_year Order by createdDate ASC Limit 1];
    DateTime dt = (Datetime)thisYear[0].get('createdDate');
    return Date.newInstance(dt.year(), dt.month(), dt.day());

VF Page :

<apex:page controller="PipeChartController" title="PipeChart">
<apex:outputText value="Pipe (k€)"/>
<apex:form id="form">
    <div style="float:left">
        <apex:commandButton value="Refresh"/>
    <div style="float:left">
        <apex:selectList value="{!chartPeriod}" size="1">
            <apex:selectOptions value="{!chartPeriodOptions}"/>
            <apex:actionSupport event="onchange" reRender="chartOutputPanel" status="actionStatusDisplay"/>                            

    <apex:actionStatus id="actionStatusDisplay" startText="loading..." stopText=""/>
    <apex:outputPanel id="chartOutputPanel">
        <apex:chart height="420" width="100%" data="{!data}" name="PipeChartCY" id="theChart">

1 Answer 1


Maybe I am not seeing the while picture, but it looks like chartPeriod should be declared as a String to match the select option? Once I did that, the setter worked for me


public String chartPeriod{
        if(chartPeriod==null) chartPeriod = String.valueOf(thisYear());
        return chartPeriod;
  • 1
    Worked great, i did just that and then changed public List<Data> getData() { return PipeChartController.getChartData(this.chartPeriod); } to public List<Data> getData() { return PipeChartController.getChartData(date.valueOf(this.chartPeriod)); } It's kind of weird how it doesn't accept Dates but now it works thank you so much !
    – Alexis
    Commented Aug 1, 2019 at 13:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .