Problems with chart.

6 posts, 0 answers
  1. Сергей
    Сергей avatar
    3 posts
    Member since:
    Jan 2015

    Posted 03 Feb 2015 Link to this post

    Hi,

    I have several questions about using charts:

    1. How use different ChartTooltipBehavior for different series? Because it is method of chart, not a series.
    I want show specific strings for different series:

    tooltipBehavior.contentAdapter().setCategoryToStringConverter(new Function<Object, String>() {
        @Override
        public String apply(Object o) {
            return "Category for only first series";
        }
    });
    tooltipBehavior.contentAdapter().setValueToStringConverter(new Function<Object, String>() {
        @Override
        public String apply(Object o) {
            return "Value for only first series";
        }
    });

    2. How do offset with starting zoom?
    I set starting zoom programmatically: panZoom.setZoomToChart(100, 1, 1, 1); 
    But I don't want look left part of chart, I want right part instead.

    3. I want dynamically add points to chart.
       Now I add whole data list instead of adding one point:
       
       List<DataClass> lineSeriesData = (List<DataClass>) lineSeries.getData();
       lineSeriesData.add(new Point());
       lineSeries.setData(lineSeriesData);
       
       This is best way?

    4. It is possible do on axis touch/click listener?
       
    Thanks.
       
  2. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 05 Feb 2015 Link to this post

    Hi Сергей,

    Thanks for writing.
    In short, you can replace the content adapter with a custom adapter which will give you full control over the tooltip presentation.

    You can use ObservableCollection<T> as your data container. It will automatically update the chart when you add or remove data points.

    You can listen for gestures on the chart itself and check whether the user has tapped on an axis, this should be pretty straightforward.

    I will attach a sample app shortly that demonstrates the points above and also shows how to zoom and pan the chart to the right.

    Regards,
    Victor
    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. Сергей
    Сергей avatar
    3 posts
    Member since:
    Jan 2015

    Posted 06 Feb 2015 in reply to Victor Link to this post

    "In short, you can replace the content adapter with a custom adapter which will give you full control over the tooltip presentation.

    You can use ObservableCollection<T> as your data container. It will automatically update the chart when you add or remove data points.

    You can listen for gestures on the chart itself and check whether the user has tapped on an axis, this should be pretty straightforward."

    Many thanks, very helpful.

    "I will attach a sample app shortly that demonstrates the points above and also shows how to zoom and pan the chart to the right."

    I will wait your response.
  5. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 09 Feb 2015 Link to this post

    Hello, Сергей

    Please have a look at the attached example app. It contains code examples for each of your questions.
    Please write again if you need further assistance.

    Regards,
    Victor
    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. Сергей
    Сергей avatar
    3 posts
    Member since:
    Jan 2015

    Posted 10 Feb 2015 in reply to Victor Link to this post

    Thanks, very useful sample!

    But I have new problem with it.

    In your sample I can't set pan within onCreate method (as in onResume). But I noticed then it works
    if I create any button and set pan in it's onClick listener. 

    It also works if some delayed presents after Chart initialization:
    new Handler().postDelayed(new Runnable() {
      @Override
      public void run() {
       double plotWidth = pylonChart.getPlotAreaClip().getWidth();
       pylonChart.setPanOffset(-plotWidth * pylonChart.getZoomWidth(), 0);
      }
    }, 200);

    But it is a bad workaround.

    It is possible to set chart's pan immediately after creation? Maybe there are some events which I can use?

    And two more questions:

    1. I learned to handle touch event on annotation (based on your sample), but I want Popup to be shown when this touch occurs (just like it goes with series tooltip). Is it possible?

    2. I noticed that something wrong with DateTimeContinuousAxis if it used with multiple series (with different vertical axes).
    Here is steps to reproduce:

    1) Scale chart to state when no one labels visible(large zoom).
    2) Scroll it to the right end.
    3) Continue scrolling to the right.

    The chart starts tremble.
    And while scaling chart(zoom in) additional labels are not shown with multiple series.

    My horizontal axis initialization:
    horizontalAxis = new DateTimeContinuousAxis();
    horizontalAxis.setLabelMargin(Util.getDimen(TypedValue.COMPLEX_UNIT_DIP, 15));
    horizontalAxis.setDateTimeFormat(new SimpleDateFormat("HH:mm:ss", getResources().getConfiguration().locale));

    horizontalAxis.setMajorStepUnit(TimeInterval.MINUTE);
    horizontalAxis.setMajorStep(10);
  7. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 13 Feb 2015 Link to this post

    Hi Сергей,

    Thanks for writing.
    You can set the zoom and pan after the layout has passed. For example you can add a layout change listener for the first layout and then remove it immediately:
    @Override
    public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
        this.chart.removeOnLayoutChangeListener(this);
        chart.setZoom(3, 1);
        double plotWidth = chart.getPlotAreaClip().getWidth();
        chart.setPanOffset(-plotWidth * chart.getZoomWidth(), 0);
    }
    chart.addOnLayoutChangeListener(this);

    Unfortunately the chart tooltip can not be shown for an annotation at the moment. We'll consider implementing this for a future release. You will have to manually show a popup if an annotation is tapped. You can use the the previous gesture example and iterate over the annotations checking their layout slots.

    We will investigate the DateTimeContinuousAxis issue and will fix it if possible.
    Thank you for the feedback, much appreciated.

    For further support please consider purchasing a license for the controls.

    Regards,
    Victor
    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.

     
Back to Top
DevCraft banner