1. #1
    Ext User
    Join Date
    Sep 2010
    Posts
    26
    Vote Rating
    0
    kudos_ni_ is on a distinguished road

      0  

    Question HorizontalBarChart x axis help

    HorizontalBarChart x axis help


    Hi All,

    I've managed to get the horizontal bar chart working by following the example in the widget explorer. However, the X axis is displaying strangely... hard to describe...so here's an image:

    barchart.JPG

    As you can see the bars don't start from the y axis as expected.

    Is there something I have to change for this to happen?

    Here is the code that creates the chart:

    Code:
     
    Chart chart = new Chart(Registry.get(Service.URL_CHART).toString());
    
    
    ChartModel cm = new ChartModel("Portfolio %");
    cm.setBackgroundColour("#fffff5");
    XAxis xa = new XAxis();
    YAxis ya = new YAxis();
    ArrayList<PositionSummaryItem> list = Registry.get(summaryData);
    if(list!=null && list.size()>0){
    HorizontalBarChart bar = new HorizontalBarChart(); bar.setColour("#005791"); bar.setTooltip("#val#%");
    List<String> labels = new ArrayList<String>();
    for(PositionSummaryItem p : list){
    labels.add(p.get("name").toString()); bar.addBars(new HorizontalBarChart.Bar((Double)p.get("percent"), "#005791"));
    }
    ya.addLabels(labels); ya.setGridColour("-1"); ya.setOffset(true);
    double max = Math.round((Double)list.get(0).get("percent")); double steps = 0;
    if((Double)list.get(0).get("percent") < 5){
    steps = 0.5;
    }
    else{
    steps = 2;
    }
    xa.setRange(0, max, steps); xa.setGridColour("#737373");
    cm.setXAxis(xa); cm.setYAxis(ya); cm.setTooltipStyle(new ToolTip(MouseStyle.FOLLOW));
    cm.addChartConfig(bar); chart.setChartModel(cm); barContainer.add(chart);
    }
    Thanks!

  2. #2
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,966
    Vote Rating
    130
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    Have you tried to reproduce this in a small, standalone testcase? I just put together an example and it works fine for me.

  3. #3
    Ext User
    Join Date
    Sep 2010
    Posts
    26
    Vote Rating
    0
    kudos_ni_ is on a distinguished road

      0  

    Thumbs up


    Fixed:

    I previously had
    Code:
    xa.setRange(0, max, steps); 
    .

    I changed the minimum from zero to reflect the steps... so in the case of my code it is 0.5 or 5 depending on the data.
    It is now:
    Code:
    xa.setRange(steps, max, steps); 
    Cheers.

Similar Threads

  1. How can i add a label for x-axis and y-axis for a chart?
    By madhu_g in forum Ext GWT: Discussion
    Replies: 6
    Last Post: 22 Mar 2011, 12:39 AM
  2. A lot of values on the X axis
    By Evgeny Fisher in forum Ext GWT: Discussion
    Replies: 5
    Last Post: 29 Jul 2010, 7:57 PM
  3. Problem of y axis of barchart.
    By yh800701 in forum Ext GWT: Discussion
    Replies: 3
    Last Post: 23 Mar 2010, 3:45 AM

Thread Participants: 1

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar