package com.oatsystems.raf.smartgwt.client.chart;

import java.util.ArrayList;
import java.util.List;

import com.smartgwt.client.types.ChartType;
import com.smartgwt.client.widgets.chart.FacetChart;
import com.smartgwt.client.widgets.cube.Facet;
import com.smartgwt.client.widgets.layout.VLayout;

public class TestGridLayout extends VLayout {

    public TestGridLayout() {

        setLayoutMargin(20);
        setHeight100();
        setWidth100();
        setBackgroundColor("#ABBCE1");

        addMember(createBarchart());
    }

    private FacetChart createBarchart() {
        List<ItemChartData> chartData = new ArrayList<ItemChartData>();
        
        // =========================================================================
        // ======  Setting one of these values to non-zero will fix the problem ====
        chartData.add(new ItemChartData("% Missing", 0.0d));
        chartData.add(new ItemChartData("% Extra", 0.0d));
        
        // Creating chart
        FacetChart chart = new FacetChart();  
        chart.setData(chartData.toArray(new ItemChartData[0]));  
        chart.setFacets(new Facet("statistic", "Statistic"));  
        chart.setValueProperty("percentage");
        chart.setChartType(ChartType.COLUMN);  
        chart.setTitle("Contribution to Errors");
        chart.setShowShadows(true);
        chart.setShowDataAxisLabel(false);
        chart.setAutoRotateLabels(false);
        chart.setBandedBackground(false);
        chart.setBackgroundColor("white");
        chart.setDataColors("#7597E1");        

        return chart;
    }
    
}
