Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    setXAxisValueFormatter in Column FacetChart

    Version v9.1p_2014-07-03/Pro Deployment (2014-07-03)

    Is the method setXAxisValueFormatter supposed to work on FacetChart when Column type is chosen?
    It's not working for me and I'm trying to find a way of hiding the labels because they are big strings.

    If it is intended not to work I'd appreciate to know if there is a workaround.

    Thanks in advance!

    #2
    Yes, it should work for Column charts. We would need runnable test code to investigate the issue you're seeing.

    Comment


      #3
      Ok, here it is:

      Code:
      package br.com.dti.testesmartgwt.client;
      
      import java.util.ArrayList;
      import java.util.HashMap;
      import java.util.LinkedHashMap;
      import java.util.List;
      import java.util.Map;
      
      import com.google.gwt.core.client.EntryPoint;
      import com.google.gwt.user.client.ui.RootPanel;
      import com.smartgwt.client.data.Record;
      import com.smartgwt.client.types.Alignment;
      import com.smartgwt.client.types.ChartType;
      import com.smartgwt.client.widgets.chart.FacetChart;
      import com.smartgwt.client.widgets.chart.ValueFormatter;
      import com.smartgwt.client.widgets.cube.Facet;
      import com.smartgwt.client.widgets.layout.VLayout;
      
      public class TesteSmartGWTEntryPoint implements EntryPoint 
      {
      	private VLayout rootLayout;
      	
      	@Override
      	public void onModuleLoad()
      	{
      		try
      		{
      			rootLayout = new VLayout();
      			rootLayout.setWidth("98,5%");
      			rootLayout.setHeight("97%");
      			RootPanel.get().add(rootLayout);
      			buildLayout();
      		}
      		catch (Exception e)
      		{
      		}
      	}
      
      	private void buildLayout()
      	{
      		HashMap<String, Integer> map = new LinkedHashMap<String, Integer>();
      		map.put("String 1", 3);
      		map.put("String 2", 4);
      		map.put("String 3", 5);
      		
      		FacetChart chart = new FacetChart();
      		chart.setFacets(new Facet("currentAttribute", "Attribute"));
      		chart.setValueProperty("number");
      		chart.setChartType(ChartType.COLUMN);
      		chart.setTitle("Column Chart");
      		chart.setHeight100();
      		chart.setWidth100();
      		chart.setAlign(Alignment.CENTER);
      		chart.setShowDataValues(true);
              
      		List<ColumnChartRecord> recordList = new ArrayList<ColumnChartRecord>();
      		for (Map.Entry<String, Integer> cEstruturaComparacao : map.entrySet())
      			recordList.add(new ColumnChartRecord(cEstruturaComparacao.getKey(), cEstruturaComparacao.getValue()));
      		chart.setData(recordList.toArray(new ColumnChartRecord[] {}));
      		chart.setXAxisValueFormatter(new ValueFormatter()
              {
      			@Override
      			public String format(Object value)
      			{
      				return " ";
      			}
      		});
      		rootLayout.addMembers(chart);
      	}
      	
      	public class ColumnChartRecord extends Record 
      	{
      		protected ColumnChartRecord()
      		{
      			
      		}
      		
      		public ColumnChartRecord(String name, Integer value)
      		{
      			setAttribute("currentAttribute", name);
      			setAttribute("number", value);
      		}
      	}
      }

      Comment


        #4
        Please try with the latest patched build. If you're still having an issue, please post a screenshot so it's clear what the issue is.

        Comment


          #5
          I've just tried the latest patch (Version v9.1p_2014-09-02/Pro Deployment (2014-09-02)) and still got the problem.

          In the screenshot attached there is the chart produced by the code above. The X-axis labels (circled in yellow) should have been disappeared due to the formatter, but they didn't.
          Attached Files

          Comment


            #6
            Ah, the formatter API is called only when an axis is actually showing data values, to allow numeric/currency/time and similar formatting. Your X axis is showing facetValue titles which are already strings, so to modify them, just change the facetValue titles that you apply to the chart.

            Comment


              #7
              Ok, but my intention was to hide the labels and then show a legend separated from the chart.

              I'll talk to my customer and we will try to reduce the strings length.

              Comment

              Working...
              X