SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and iOS Chart & Android Chart Components

0
0

Quick example. All charts visible:

enter image description here

Setting Visibility.GONE to RSI chart:

enter image description here

As you can see part of RSI chart is now visible on MACD chart.

Here is my layout. I want to be able to hide any of the charts inside LinearLayout and the remaining charts should equally fill the newly created space. I wasn’t able to recreate the desired behaviour with ConstraintLayout, otherwise I would use it.

<com.scichart.charting.visuals.SciChartSurface
        android:id="@+id/priceChart"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" />

    <LinearLayout
        android:layout_width="match_parent"
        android:orientation="vertical"
        android:layout_height="0dp"
        android:layout_weight="1">

        <com.scichart.charting.visuals.SciChartSurface
            android:id="@+id/macdChart"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"/>

        <com.scichart.charting.visuals.SciChartSurface
            android:id="@+id/rsiChart"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"/>

        <com.scichart.charting.visuals.SciChartSurface
            android:id="@+id/volumeChart"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"/>
    </LinearLayout>
Version
2.0.0.1654
  • Primoz
    Two things I forgot to mention. 1st, I would like to have separate chart views and not just one, like on the example page for multi plane stock charts (this way I should be able to turn on/off charts I want to see without wasting screen real estate). 2nd, it says my trial expired but I actually bought the product with 3 month support.
  • You must to post comments
0
0

Hi there,

I believe this happens because our default RenderSurface implementation is based on GLSurfaceView which ignores visibility values because it draws its content outside of Android View hierarchy.

To workaround this issue you can:

  1. set render surface to null when setting Visibility.GONE which will detach render surface from chart:

            rsiChart.setVisibility(View.GONE);
            rsiChart.setRenderSurface(null);
    

    and when you need to make chart visible again you’ll need to assign render surface again:

           rsiChart.setRenderSurface(new RenderSurfaceGL(getActivity()));
           rsiChart.setVisibility(View.VISIBLE);
    
  2. you can init chart after it is created with alternative render surface implementation which correctly handles visibility changes so you won’t need to set render surface when visibility changes:

    // use alternative OpenGL based render surface
    surface.setRenderSurface(new GLTextureView(getActivity()));
    // or use Canvas based render surface
    surface.setRenderSurface(new RenderSurface(getActivity()));
    
  3. as alternative to previous approach you can create custom SciChartSurface class and override method which creates render surface which is used by default to render chart:

    class CanvasSciChartSurface extends SciChartSurface {
    
    public CanvasSciChartSurface(Context context) {
        super(context);
    }
    
    public CanvasSciChartSurface(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
    
    public CanvasSciChartSurface(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }
    
    @Override
    protected IRenderSurface getDefaultRenderSurface(Context context) {
        return new RenderSurface(context); // return alternative render surface implementation here
    }
    }
    

Hope this will help you!

Best regards,
Yura

  • Primoz
    Thanks Yura, now it works well! Awesome support and quick response. Thanks
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.