Vertical Axis shows Decimal format values not integer

10 posts, 0 answers
  1. Jake
    Jake avatar
    8 posts
    Member since:
    Aug 2014

    Posted 18 Aug 2014 Link to this post

    Hi Team,

    i am working on chart part and i want to show integer value in Y Axis or Vertical Axis like 1,2,3,4 not like decimal values 0.0,1.0, 2.0, 3.0.
    here i have attached the code values please help me out for it. 


    public FrameLayout barChartView(String strLegend, List<DashBoardCharts> chart)
        {

            try
            {
                if (chart != null)
                {

                    radCartesianChartView = new RadCartesianChartView(activity);
                    BarSeries barSeries = new BarSeries(activity);
                    barSeries.setLegendTitle(strLegend);
                    barSeries.setCombineMode(ChartSeriesCombineMode.CLUSTER);
                    legendView = new RadLegendView(activity);
                    legendView.setLegendProvider(radCartesianChartView);

                    legendView.setX(50f);
                    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(450,
                            100);

                    params.setMargins(10, 0, 10, 10);

                    legendView.setLayoutParams(params);

                    barSeries.setCategoryBinding(new DataPointBinding()
                    {
                        @Override
                        public Object getValue(Object o)
                        {
                            return ((Dashboard.DashBoardCharts) o).getCategory();
                        }
                    });
                    barSeries.setValueBinding(new DataPointBinding()
                    {
                        @Override
                        public Object getValue(Object o)
                        {
                            return ((Dashboard.DashBoardCharts) o).getValue();
                        }
                    });

                    barSeries.setData(chart);

                    // ChartPalette customPalette = new ChartPalette();
                    // PaletteEntryCollection collection = new PaletteEntryCollection();
                    //
                    // PaletteEntry entry =null;
                    // collection.setFamily(barSeries.paletteFamily());
                    // entry = new
                    // PaletteEntry(Color.parseColor("#FF0079FF"));
                    // collection.add(entry);
                    // customPalette.seriesEntries().add(collection);
                    // radCartesianChartView.setPalette(customPalette);

                    radCartesianChartView.getSeries().add(barSeries);

                    CategoricalAxis horizontalAxis = new CategoricalAxis(activity);
                    radCartesianChartView.setHorizontalAxis(horizontalAxis);

                    //horizontalAxis.setLabelFitMode(AxisLabelFitMode.ROTATE);

                    LinearAxis verticalAxis = new LinearAxis(activity);
                    //verticalAxis.setLabelFormat("");
                    radCartesianChartView.setVerticalAxis(verticalAxis);

        
                    
                    ChartPanAndZoomBehavior behavior = new ChartPanAndZoomBehavior();

                    behavior.setZoomMode(ChartPanZoomMode.VERTICAL);
                    behavior.setPanMode(ChartPanZoomMode.BOTH);
                    radCartesianChartView.getBehaviors().add(behavior);
                    radCartesianChartView.getBehaviors().add(new ChartSelectionBehavior());

                    radCartesianChartView.addView(legendView);
                }
            } catch (Exception e)
            {
                if (LogLevels.ERROR)
                    Controller.logger.error(ErrorStackTraceUtil.getCombinedStackTrace(e));
                e.printStackTrace();
            }
            return radCartesianChartView;

        }


    Regards,
    jake
  2. Antony Jekov
    Admin
    Antony Jekov avatar
    88 posts

    Posted 19 Aug 2014 Link to this post

    Hello Jake,

    Thank you for contacting the Android team.

    The values of the axes are being kept as doubles for precision purposes, but you have full control on the end result. All you need to do is provide a custom value-to-string converter function.
    Here is an example regarding your question:
    verticalAxis.setLabelValueToStringConverter(new Function<Object, String>() {
        @Override
        public String apply(Object argument) {
            return String.valueOf((int)((MajorTickModel) argument).value());
        }
    });

    This will make all the values for the axis integers before turning them to strings. I hope this answers your question. Please feel free to add to this ticket or start a new one should you have any additional problems.

    Thank you for your time and all best!

    Regards,
    Antony Jekov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. DevCraft banner
  4. Jake
    Jake avatar
    8 posts
    Member since:
    Aug 2014

    Posted 19 Aug 2014 in reply to Antony Jekov Link to this post

    hi,

    thank you so much , it works fine.
  5. Antony Jekov
    Admin
    Antony Jekov avatar
    88 posts

    Posted 21 Aug 2014 Link to this post

    Hello Jake,

    I am glad to hear it. I will proceed and close this ticket. Please feel free to reopen it at any time.

    Thank you for your time and all best!

    Regards,
    Antony Jekov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  6. Thanh
    Thanh avatar
    3 posts
    Member since:
    Nov 2013

    Posted 04 Sep 2014 in reply to Jake Link to this post

    tks you!
  7. Richard
    Richard avatar
    44 posts
    Member since:
    Jun 2014

    Posted 12 May 2015 in reply to Antony Jekov Link to this post

    Isn't this what the setLabelFormat() function is supposed to do now? 

    However, there is no documentation on what string values to use for formatting and "#" and "0" return the literal values not the number formatted that way.

  8. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 14 May 2015 Link to this post

    Hello Richard,

    The label format is a standard java string format. You read more about it here.

    Regards,
    Victor
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  9. joe
    joe avatar
    3 posts
    Member since:
    Jun 2015

    Posted 12 Jun 2015 Link to this post

    I think all you need to do is provide a custom value-to-string converter function.
  10. joe
    joe avatar
    3 posts
    Member since:
    Jun 2015

    Posted 14 Jun 2015 in reply to joe Link to this post

    And i have just try it...

    [url=http://www.casesam.co.uk/category-galaxy-s6-edge-case-cover-10.html]Samsung Galaxy S6 edge cover[/url]

  11. joe
    joe avatar
    3 posts
    Member since:
    Jun 2015

    Posted 14 Jun 2015 in reply to joe Link to this post

    http://www.casesam.co.uk/category-galaxy-s6-edge-case-cover-10.html

    http://www.casesam.co.uk

Back to Top
DevCraft banner