Hi,
I’m trying to write an app which dynamically hides/shows (Visible/Gone) scichart surface without losing the data rendering. I’ve been trying to drive this via android visiblity and observable fields (MVVM design). An example of how our surfaces look is as follows:
<com.scichart.charting.visuals.SciChartSurface
android:id=”@+id/temperature_chart”
android:layout_width=”match_parent”
android:layout_height=”0dp”
android:layout_weight=”.99″
android:visibility=”@{graphViewModel.displayChartTemp ? View.VISIBLE : View.GONE}”
android:paddingTop=”@dimen/potrero_gap”
android:paddingBottom=”@dimen/potrero_gap”
scichart:verticalGroup=”@{graphViewModel.sharedVG}”
scichart:renderableSeries=”@{graphViewModel.tempRenderableSeries}”
scichart:xAxes=”@{graphViewModel.xTempAxes}”
scichart:yAxes=”@{graphViewModel.yTempAxes}”/>
and in the view model:
declaration:
var displayChartTemp = ObservableBoolean()
and to set the visibility….
displayChartTemp.set(true)
displayChartTemp.set(false)
I saw that historically, one solution was to
rsiChart.setRenderSurface(null);
rsiChart.setRenderSurface(new RenderSurfaceGL(getActivity()));
but I was wondering if there would be a good way to do this with MVVM architecture, and drive it similarly with observables?
Thanks,
-Andy
- Andrew Chin asked 5 years ago
- You must login to post comments
Hi Andrew,
I think you can do this by creating custom SciChartSurface and overriding it setVisibility() method with next code:
class CustomSciChartSurface extends SciChartSurface {
public CustomSciChartSurface(Context context) {
super(context);
}
public CustomSciChartSurface(Context context, AttributeSet attrs) {
super(context, attrs);
}
public CustomSciChartSurface(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
public void setVisibility(int visibility) {
super.setVisibility(visibility);
switch (visibility) {
case View.GONE:
setRenderSurface(null);
break;
case View.INVISIBLE:
break;
case View.VISIBLE:
setRenderSurface(new RenderSurfaceGL(getContext()));
break;
}
}
}
In this case you won’t need to do anything else except switching visibility.
Is this suitable for your needs?
Best regards,
Yura
- Yura Khariton answered 5 years ago
-
Hi Yura, That should work for us I think, thanks! -Andy
- You must login to post comments
Please login first to submit.