Pre loader

Change background FastLineRenderableSeries dynamicelly

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

0
0

Hello, for my bottom graph on my screenshot below, is it possible to dynamically change the black background to red? Indeed, when the microphone saturates like on the screenshot below I want to change the black background to red for 2 seconds, so I need to do it programmatically.

https://i.ibb.co/7XCLDwf/sature.png

I init my bottom graph like this :

 @Override
    public void initGraph(Context context) {
        Log.d(TAG, "initGraphs");
        SciChartSurface audioStreamSciChart = new SciChartSurface(context);
        mAudiostream.addView(audioStreamSciChart);
        xAxis = new NumericAxis(context);
        xAxis.setVisibleRange(new DoubleRange(startAudioStreamRange, endAudioStreamRange));
        xAxis.setDrawLabels(false);
        xAxis.setDrawMinorTicks(false);
        xAxis.setDrawMajorBands(false);
        xAxis.setDrawMinorGridLines(false);
        audioStreamSciChart.getXAxes().add(xAxis);

        NumericAxis yAxis = new NumericAxis(context);
        yAxis.setVisibleRange(new DoubleRange(-1.0, 1.0));
        yAxis.setDrawLabels(true);
        yAxis.setDrawMinorTicks(false);
        yAxis.setDrawMajorBands(false);
        yAxis.setDrawMinorGridLines(false);
        yAxis.setAxisAlignment(AxisAlignment.Left);

        audioStreamSciChart.getYAxes().add(yAxis);

        float lineThickness = SciChartExtensionsKt.dip(context, 1.0F);

        FastLineRenderableSeries f = new FastLineRenderableSeries();
        f.setDataSeries(scichartTools.getAudioDS());
        f.setStrokeStyle(new SolidPenStyle(ColorUtil.Grey, true, lineThickness, null));
        audioStreamSciChart.getRenderableSeries().add(f);
        scichartLayout = mAudiostream.getChildAt(0);
    }

I can keep a reference of my FastLineRenderableSeries to do it but i didn’t find any method to change his backgroud color.
Can i ?

Thanks,
Wavely

Version
2.2.2.2424
  • You must to post comments
2
1

Hi Damien,

I’m not sure what you mean by background of FastLineRenderableSeries because this series type doesn’t have any background to draw. It just draws a lines and black background is provided by chart itself and you can assign it as for regular Android View:

    // set background for whole chart
    surface.setBackgroundResource(R.drawable.example_box_annotation_background_1);

    // set background only for renderable series area where series are drawn 
    final View renderableSeriesArea = (View) surface.getRenderableSeriesArea();
    renderableSeriesArea.setBackgroundResource(R.drawable.example_box_annotation_background_1);

Another alternative is to create custom renderable series and add drawing of background there:

class CustomFastLineRenderableSeries extends FastLineRenderableSeries {

private final BrushStyle redFillStyle;

CustomFastLineRenderableSeries() {
    this.redFillStyle = new SolidBrushStyle(Color.RED);
}

@Override
protected void internalDraw(IRenderContext2D renderContext, IAssetManager2D assetManager, ISeriesRenderPassData renderPassData) {
    super.internalDraw(renderContext, assetManager, renderPassData);

    if(needToDrawRedFill) {
        final IBrush2D brush = assetManager.createBrush(redFillStyle);
        renderContext.fillRect(0, 0, renderContext.getViewportWidth(), renderContext.getViewportHeight(), brush);
    }
}
}

Is this suitable for your needs?

Best regards,
Yura

  • You must to post comments
0
0

Thanks for your answer,

I used custom renderable series and it works great

Thank you

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.