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

0
0

Hello,

As you have already the examples of the EEG -50 channel, Is it possible to set the sensitivity factor for the channels to show the graph.
Basically, this will set the amplitude based on the frequency variation example 7micro volts/millimeter (7microvolts/mm) for each channel. Is there any way we can do it using Scichart, please let us know.

Appreciate your help

Regards,
Aditya

Version
V4
  • Aditya Kadambi
    Hi, to further clarify, we noticed that Scichart automatically scales as per the values and the height of the smartphone screen. We would like to control it a bit more like “traditional” EEG charts which can show amplitude at 7Uv/mm or 20Uv/mm or 200Uv/mm or even 1000Uv/mm. Can Scichart help us with this?
  • You must to post comments
0
0

Hi Aditya,

You can set VisibleRange for X and Y axes manually – this should allow to control what data is displayed by chart. Also to disable default scaling of chart you would need to set AutoRange.Never for both axes.

Best regards,
Yura

  • You must to post comments
0
0

Hi Yura,

Thanks for the answer, We are able to achieve this sensitivity factor by adding SetVisibleRange.

yAxisFp1Ref.setAutoRange(AutoRange.Never);
yAxisFp1Ref.setVisibleRange(dataProvider.getCh1_valueRange());

This happens at the initiation of the graph. But how can we do it on the fly when the graph is running.

When the graph is in progress, we have a Dropdown with Sensitivity values. and We can select the sensitivity, now the graph should set the visible ranges for all the channels should change accordingly. Image is attached for your reference.

I have added this change in updateIndicators(long time) method, which updates for every five seconds.

But this is not making changes to setvisible range.

Images
  • Yura Khariton
    Have you tried to update VisibleRange value in same place where you update your DataSeries? So if you update data for some channel you just recalculate and set Y range for this channel. Is it suitable for your needs?
  • You must to post comments
0
0

Hi

i am adding it where i m changing the data series. but its not taking. I tried to re initialize the graph also whenever we change th sensitivity.
pls check and let us know

  • Yura Khariton
    Can you provide project which reproduces this issue, because I’m not sure what I should check ( you didn’t provide any source code that I can take a look on)
  • Aditya Kadambi
    I have added it in update indicators method() where I update impedence every 5 sec. i update visible range based on sensitivity selection. I m able to see the toast msg for every 5 sec with the selected sensitivity and min and max visible range. But graph is not updated. it may be because numeriicAxis is defined as final. But without final i will not be able to define it. Note; impedence values updates properly every five sec. But graph setvisible range not updated, private void updateIndicators(long time) { //final ExampleVitalSignsBloodOxygenationIndicatorLayoutBinding bloodOxygenationIndicator = binding.bloodOxygenationIndicator; // final ExampleVitalSignsBloodPressureIndicatorLayoutBinding bloodPressureIndicator = binding.bloodPressureIndicator; // binding.heartRateIndicator.heartIcon.setVisibility(time % 2 == 0 ? View.VISIBLE : View.INVISIBLE); final Context context1 = getActivity(); if(time % 5 == 0) { indicatorsProvider.update(); binding.heartRateIndicator.impedencech0.setText(“Fp1-Ref: ” + (Double.toString(Math.round(Impedance_ch[0]*100.0)/100.0))); if (Impedance_ch[0] <= 5000) { binding.heartRateIndicator.impedencech0.setTextColor(Color.DKGRAY); int Fp1Ref = ContextCompat.getColor(context1, R.color.DKGREEN); } if (Impedance_ch[0] 5000) { binding.heartRateIndicator.impedencech0.setTextColor(Color.GREEN); int Fp1Ref = ContextCompat.getColor(context1, R.color.GREEN); } if (Impedance_ch[0] > 10000) { binding.heartRateIndicator.impedencech0.setTextColor(Color.RED); int Fp1Ref = ContextCompat.getColor(context1, R.color.RED); } binding.heartRateIndicator.impedencech1.setText(“Fp2-Ref: ” + (Double.toString(Math.round(Impedance_ch[1]*100.0)/100.0))); if (Impedance_ch[1] <= 5000) { binding.heartRateIndicator.impedencech1.setTextColor(Color.DKGRAY); int Fp2Ref = ContextCompat.getColor(context1, R.color.DKGREEN); } if (Impedance_ch[1] 5000) { binding.heartRateIndicator.impedencech1.setTextColor(Color.GREEN); int Fp2Ref = ContextCompat.getColor(context1, R.color.GREEN); } if (Impedance_ch[1] > 10000) { binding.heartRateIndicator.impedencech1.setTextColor(Color.RED); int Fp2Ref = ContextCompat.getColor(context1, R.color.RED); } binding.heartRateIndicator.impedencech2.setText(“F3-Ref: ” + (Double.toString(Math.round(Impedance_ch[2]*100.0)/100.0))); if (Impedance_ch[2] <= 5000) { binding.heartRateIndicator.impedencech2.setTextColor(Color.DKGRAY); } if (Impedance_ch[2] 5000) { binding.heartRateIndicator.impedencech2.setTextColor(Color.GREEN); } if (Impedance_ch[2] > 10000) { binding.heartRateIndicator.impedencech2.setTextColor(Color.RED); } binding.heartRateIndicator.impedencech3.setText(“F4-Ref: ” + (Double.toString(Math.round(Impedance_ch[3]*100.0)/100.0))); if (Impedance_ch[3] <= 5000) { binding.heartRateIndicator.impedencech3.setTextColor(Color.DKGRAY); } if (Impedance_ch[3] 5000) { binding.heartRateIndicator.impedencech3.setTextColor(Color.GREEN); } if (Impedance_ch[3] > 10000) { binding.heartRateIndicator.impedencech3.setTextColor(Color.RED); } binding.heartRateIndicator.impedencech4.setText(“C3-Ref: ” + (Double.toString(Math.round(Impedance_ch[4]*100.0)/100.0))); if (Impedance_ch[4] <= 5000) { binding.heartRateIndicator.impedencech4.setTextColor(Color.DKGRAY); } if (Impedance_ch[4] 5000) { binding.heartRateIndicator.impedencech4.setTextColor(Color.GREEN); } if (Impedance_ch[4] > 10000) { binding.heartRateIndicator.impedencech4.setTextColor(Color.RED); } binding.heartRateIndicator.impedencech5.setText(“C4-Ref: ” + (Double.toString(Math.round(Impedance_ch[5]*100.0)/100.0))); if (Impedance_ch[5] <= 5000) { binding.heartRateIndicator.impedencech5.setTextColor(Color.DKGRAY); } if (Impedance_ch[5] 5000) { binding.heartRateIndicator.impedencech5.setTextColor(Color.GREEN); } if (Impedance_ch[5] > 10000) { binding.heartRateIndicator.impedencech5.setTextColor(Color.RED); } binding.heartRateIndicator.impedencech6.setText(“P3-Ref: ” + (Double.toString(Math.round(Impedance_ch[6]*100.0)/100.0))); if (Impedance_ch[6] <= 5000) { binding.heartRateIndicator.impedencech6.setTextColor(Color.DKGRAY); } if (Impedance_ch[6] 5000) { binding.heartRateIndicator.impedencech6.setTextColor(Color.GREEN); } if (Impedance_ch[6] > 10000) { binding.heartRateIndicator.impedencech6.setTextColor(Color.RED); } binding.heartRateIndicator.impedencech7.setText(“P4-Ref: ” + (Double.toString(Math.round(Impedance_ch[7]*100.0)/100.0))); if (Impedance_ch[7] <= 5000) { binding.heartRateIndicator.impedencech7.setTextColor(Color.DKGRAY); } if (Impedance_ch[7] 5000) { binding.heartRateIndicator.impedencech7.setTextColor(Color.GREEN); } if (Impedance_ch[7] > 10000) { binding.heartRateIndicator.impedencech7.setTextColor(Color.RED); } binding.heartRateIndicator.impedencech8.setText(“O1-Ref: ” + (Double.toString(Math.round(Impedance_ch[8]*100.0)/100.0))); if (Impedance_ch[8] <= 5000) { binding.heartRateIndicator.impedencech8.setTextColor(Color.DKGRAY); } if (Impedance_ch[8] 5000) { binding.heartRateIndicator.impedencech8.setTextColor(Color.GREEN); } if (Impedance_ch[8] > 10000) { binding.heartRateIndicator.impedencech8.setTextColor(Color.RED); } binding.heartRateIndicator.impedencech9.setText(“O2-Ref: ” + (Double.toString(Math.round(Impedance_ch[9]*100.0)/100.0))); if (Impedance_ch[9] <= 5000) { binding.heartRateIndicator.impedencech9.setTextColor(Color.DKGRAY); } if (Impedance_ch[9] 5000) { binding.heartRateIndicator.impedencech9.setTextColor(Color.GREEN); } if (Impedance_ch[9] > 10000) { binding.heartRateIndicator.impedencech9.setTextColor(Color.RED); } binding.heartRateIndicator.impedencech10.setText(“F7-Ref: ” + (Double.toString(Math.round(Impedance_ch[10]*100.0)/100.0))); if (Impedance_ch[10] <= 5000) { binding.heartRateIndicator.impedencech10.setTextColor(Color.DKGRAY); } if (Impedance_ch[10] 5000) { binding.heartRateIndicator.impedencech10.setTextColor(Color.GREEN); } if (Impedance_ch[10] > 10000) { binding.heartRateIndicator.impedencech10.setTextColor(Color.RED); } // binding.heartRateIndicator.impedencech11.setText(“F8-Ref: ” + (Double.toString(Math.round(Impedance_ch[11]*100.0)/100.0))); if (Impedance_ch[11] <= 5000) { binding.heartRateIndicator.impedencech11.setTextColor(Color.DKGRAY); } if (Impedance_ch[11] 5000) { binding.heartRateIndicator.impedencech11.setTextColor(Color.GREEN); } if (Impedance_ch[11] > 10000) { binding.heartRateIndicator.impedencech11.setTextColor(Color.RED); } binding.heartRateIndicator.impedencech12.setText(“T3-Ref: ” + (Double.toString(Math.round(Impedance_ch[12]*100.0)/100.0))); if (Impedance_ch[12] <= 5000) { binding.heartRateIndicator.impedencech12.setTextColor(Color.DKGRAY); } if (Impedance_ch[12] 5000) { binding.heartRateIndicator.impedencech12.setTextColor(Color.GREEN); } if (Impedance_ch[12] > 10000) { binding.heartRateIndicator.impedencech12.setTextColor(Color.RED); } binding.heartRateIndicator.impedencech13.setText(“T4-Ref: ” + (Double.toString(Math.round(Impedance_ch[13]*100.0)/100.0))); if (Impedance_ch[13] <= 5000) { binding.heartRateIndicator.impedencech13.setTextColor(Color.DKGRAY); } if (Impedance_ch[13] 5000) { binding.heartRateIndicator.impedencech13.setTextColor(Color.GREEN); } if (Impedance_ch[13] > 10000) { binding.heartRateIndicator.impedencech13.setTextColor(Color.RED); } binding.heartRateIndicator.impedencech14.setText(“T5-Ref: ” + (Double.toString(Math.round(Impedance_ch[14]*100.0)/100.0))); if (Impedance_ch[14] <= 5000) { binding.heartRateIndicator.impedencech14.setTextColor(Color.DKGRAY); } if (Impedance_ch[14] 5000) { binding.heartRateIndicator.impedencech14.setTextColor(Color.GREEN); } if (Impedance_ch[14] > 10000) { binding.heartRateIndicator.impedencech14.setTextColor(Color.RED); } binding.heartRateIndicator.impedencech15.setText(“T6-Ref: ” + (Double.toString(Math.round(Impedance_ch[15]*100.0)/100.0))); if (Impedance_ch[15] <= 5000) { binding.heartRateIndicator.impedencech15.setTextColor(Color.DKGRAY); } if (Impedance_ch[15] 5000) { binding.heartRateIndicator.impedencech15.setTextColor(Color.GREEN); } if (Impedance_ch[15] > 10000) { binding.heartRateIndicator.impedencech15.setTextColor(Color.RED); } binding.heartRateIndicator.impedencech16.setText(“A1-Ref: ” + (Double.toString(Math.round(Impedance_ch[16]*100.0)/100.0))); if (Impedance_ch[16] <= 5000) { binding.heartRateIndicator.impedencech16.setTextColor(Color.DKGRAY); } if (Impedance_ch[16] 5000) { binding.heartRateIndicator.impedencech16.setTextColor(Color.GREEN); } if (Impedance_ch[16] > 10000) { binding.heartRateIndicator.impedencech16.setTextColor(Color.RED); } binding.heartRateIndicator.impedencech17.setText(“A2-Ref: ” + (Double.toString(Math.round(Impedance_ch[17]*100.0)/100.0))); if (Impedance_ch[17] <= 5000) { binding.heartRateIndicator.impedencech17.setTextColor(Color.DKGRAY); } if (Impedance_ch[17] 5000) { binding.heartRateIndicator.impedencech17.setTextColor(Color.GREEN); } if (Impedance_ch[17] > 10000) { binding.heartRateIndicator.impedencech17.setTextColor(Color.RED); } binding.heartRateIndicator.impedencech18.setText(“Fz-Ref: ” + (Double.toString(Math.round(Impedance_ch[18]*100.0)/100.0))); if (Impedance_ch[18] <= 5000) { binding.heartRateIndicator.impedencech18.setTextColor(Color.DKGRAY); } if (Impedance_ch[18] 5000) { binding.heartRateIndicator.impedencech18.setTextColor(Color.GREEN); } if (Impedance_ch[18] > 10000) { binding.heartRateIndicator.impedencech18.setTextColor(Color.RED); } binding.heartRateIndicator.impedencech19.setText(“Cz-Ref: ” + (Double.toString(Math.round(Impedance_ch[19]*100.0)/100.0))); if (Impedance_ch[19] <= 5000) { binding.heartRateIndicator.impedencech19.setTextColor(Color.DKGRAY); } if (Impedance_ch[19] 5000) { binding.heartRateIndicator.impedencech17.setTextColor(Color.GREEN); } if (Impedance_ch[19] > 10000) { binding.heartRateIndicator.impedencech19.setTextColor(Color.RED); } binding.heartRateIndicator.impedencech20.setText(“Pz-Ref: ” + (Double.toString(Math.round(Impedance_ch[20]*100.0)/100.0))); if (Impedance_ch[20] <= 5000) { binding.heartRateIndicator.impedencech20.setTextColor(Color.DKGRAY); } if (Impedance_ch[20] 5000) { binding.heartRateIndicator.impedencech20.setTextColor(Color.GREEN); } if (Impedance_ch[20] > 10000) { binding.heartRateIndicator.impedencech20.setTextColor(Color.RED); } binding.heartRateIndicator.impedencech21.setText(“Oz-Ref: ” + (Double.toString(Math.round(Impedance_ch[21]*100.0)/100.0))); if (Impedance_ch[21] <= 5000) { binding.heartRateIndicator.impedencech21.setTextColor(Color.DKGRAY); } if (Impedance_ch[21] 5000) { binding.heartRateIndicator.impedencech21.setTextColor(Color.GREEN); } if (Impedance_ch[21] > 10000) { binding.heartRateIndicator.impedencech21.setTextColor(Color.RED); } binding.heartRateIndicator.impedencech22.setText(“PG1-Ref: ” + (Double.toString(Math.round(Impedance_ch[22]*100.0)/100.0))); if (Impedance_ch[22] <= 5000) { binding.heartRateIndicator.impedencech22.setTextColor(Color.DKGRAY); } if (Impedance_ch[22] 5000) { binding.heartRateIndicator.impedencech22.setTextColor(Color.GREEN); } if (Impedance_ch[22] > 10000) { binding.heartRateIndicator.impedencech22.setTextColor(Color.RED); } binding.heartRateIndicator.impedencech23.setText(“PG2-Ref: ” + (Double.toString(Math.round(Impedance_ch[23]*100.0)/100.0))); if (Impedance_ch[23] <= 5000) { binding.heartRateIndicator.impedencech23.setTextColor(Color.DKGRAY); } if (Impedance_ch[23] 5000) { binding.heartRateIndicator.impedencech21.setTextColor(Color.GREEN); } if (Impedance_ch[23] > 10000) { binding.heartRateIndicator.impedencech23.setTextColor(Color.RED); } Toast.makeText(getActivity(), “Selected Sensitivity position in update: “+ Sensitivity_pos, Toast.LENGTH_LONG).show(); // final Context context1 = getActivity(); final DefaultVitalSignsDataProvider dataProvider = new DefaultVitalSignsDataProvider(getActivity()); Toast.makeText(getActivity(), “Selected Sensitivity rage: “+ dataProvider.getCh1_valueRange(), Toast.LENGTH_LONG).show(); final String Fp1RefId = “Fp1-Ref”; final String Fp2RefId = “Fp2-Ref”; final String F3RefId = “F3-Ref”; final String F4RefId = “F4-Ref”; final String C3RefId = “C3-Ref”; final String C4RefId = “C4-Ref”; final String P3RefId = “P3-Ref”; final String P4RefId = “P4-Ref”; final String O1RefId = “O1-Ref”; final String O2RefId = “O2-Ref”; final String F7RefId = “F7-Ref”; final String F8RefId = “F8-Ref”; final String T3RefId = “T3-Ref”; final String T4RefId = “T4-Ref”; final String T5RefId = “T5-Ref”; final String T6RefId = “T6-Ref”; final String A1RefId = “A1-Ref”; final String A2RefId = “A2-Ref”; final String FzRefId = “Fz-Ref”; final String CzRefId = “Cz-Ref”; final String PzRefId = “Pz-Ref”; final String OzRefId = “Oz-Ref”; final String PG1RefId = “PG1-Ref”; final String PG2RefId = “PG2-Ref”; final NumericAxis yAxisFp1Ref = generateYAxis(Fp1RefId, dataProvider.getCh1_valueRange()); final NumericAxis yAxisFp2Ref = generateYAxis(Fp2RefId, dataProvider.getCh1_valueRange()); final NumericAxis yAxisF3Ref = generateYAxis(F3RefId, dataProvider.getCh1_valueRange()); final NumericAxis yAxisF4Ref = generateYAxis(F4RefId, dataProvider.getCh1_valueRange()); final NumericAxis yAxisC3Ref = generateYAxis(C3RefId, dataProvider.getCh1_valueRange()); final NumericAxis yAxisC4Ref = generateYAxis(C4RefId, dataProvider.getCh1_valueRange()); final NumericAxis yAxisP3Ref = generateYAxis(P3RefId, dataProvider.getCh1_valueRange()); final NumericAxis yAxisP4Ref = generateYAxis(P4RefId, dataProvider.getCh1_valueRange()); final NumericAxis yAxisO1Ref = generateYAxis(O1RefId, dataProvider.getCh1_valueRange()); final NumericAxis yAxisO2Ref = generateYAxis(O2RefId, dataProvider.getCh1_valueRange()); final NumericAxis yAxisF7Ref = generateYAxis(F7RefId, dataProvider.getCh1_valueRange()); final NumericAxis yAxisF8Ref = generateYAxis(F8RefId, dataProvider.getCh1_valueRange()); final NumericAxis yAxisT3Ref = generateYAxis(T3RefId, dataProvider.getCh1_valueRange()); final NumericAxis yAxisT4Ref = generateYAxis(T4RefId, dataProvider.getCh1_valueRange()); final NumericAxis yAxisT5Ref = generateYAxis(T5RefId, dataProvider.getCh1_valueRange()); final NumericAxis yAxisT6Ref = generateYAxis(T6RefId, dataProvider.getCh1_valueRange()); final NumericAxis yAxisA1Ref = generateYAxis(A1RefId, dataProvider.getCh1_valueRange()); final NumericAxis yAxisA2Ref = generateYAxis(A2RefId, dataProvider.getCh1_valueRange()); final NumericAxis yAxisFzRef = generateYAxis(FzRefId, dataProvider.getCh1_valueRange()); final NumericAxis yAxisCzRef = generateYAxis(CzRefId, dataProvider.getCh1_valueRange()); final NumericAxis yAxisPzRef = generateYAxis(PzRefId, dataProvider.getCh1_valueRange()); final NumericAxis yAxisOzRef = generateYAxis(OzRefId, dataProvider.getCh1_valueRange()); final NumericAxis yAxisPG1Ref = generateYAxis(PG1RefId, dataProvider.getCh1_valueRange()); final NumericAxis yAxisPG2Ref = generateYAxis(PG2RefId, dataProvider.getBloodOxygenationRange()); //change the sensitivity yAxisFp1Ref.setAutoRange(AutoRange.Never); yAxisFp1Ref.setVisibleRange(dataProvider.getCh1_valueRange()); yAxisFp2Ref.setAutoRange(AutoRange.Never); yAxisFp2Ref.setVisibleRange(dataProvider.getCh1_valueRange()); yAxisF3Ref.setAutoRange(AutoRange.Never); yAxisF3Ref.setVisibleRange(dataProvider.getCh1_valueRange()); yAxisF4Ref.setAutoRange(AutoRange.Never); yAxisF4Ref.setVisibleRange(dataProvider.getCh1_valueRange()); yAxisC3Ref.setAutoRange(AutoRange.Never); yAxisC3Ref.setVisibleRange(dataProvider.getCh1_valueRange()); yAxisC4Ref.setAutoRange(AutoRange.Never); yAxisC4Ref.setVisibleRange(dataProvider.getCh1_valueRange()); yAxisP3Ref.setAutoRange(AutoRange.Never); yAxisP3Ref.setVisibleRange(dataProvider.getCh1_valueRange()); yAxisP4Ref.setAutoRange(AutoRange.Never); yAxisP4Ref.setVisibleRange(dataProvider.getCh1_valueRange()); yAxisO1Ref.setAutoRange(AutoRange.Never); yAxisO1Ref.setVisibleRange(dataProvider.getCh1_valueRange()); yAxisO2Ref.setAutoRange(AutoRange.Never); yAxisO2Ref.setVisibleRange(dataProvider.getCh1_valueRange()); yAxisF7Ref.setAutoRange(AutoRange.Never); yAxisF7Ref.setVisibleRange(dataProvider.getCh1_valueRange()); yAxisF8Ref.setAutoRange(AutoRange.Never); yAxisF8Ref.setVisibleRange(dataProvider.getCh1_valueRange()); yAxisT3Ref.setAutoRange(AutoRange.Never); yAxisT3Ref.setVisibleRange(dataProvider.getCh1_valueRange()); yAxisT4Ref.setAutoRange(AutoRange.Never); yAxisT4Ref.setVisibleRange(dataProvider.getCh1_valueRange()); yAxisT5Ref.setAutoRange(AutoRange.Never); yAxisT5Ref.setVisibleRange(dataProvider.getCh1_valueRange()); yAxisT6Ref.setAutoRange(AutoRange.Never); yAxisT6Ref.setVisibleRange(dataProvider.getCh1_valueRange()); yAxisA1Ref.setAutoRange(AutoRange.Never); yAxisA1Ref.setVisibleRange(dataProvider.getCh1_valueRange()); yAxisA2Ref.setAutoRange(AutoRange.Never); yAxisA2Ref.setVisibleRange(dataProvider.getCh1_valueRange()); yAxisFzRef.setAutoRange(AutoRange.Never); yAxisFzRef.setVisibleRange(dataProvider.getCh1_valueRange()); yAxisCzRef.setAutoRange(AutoRange.Never); yAxisCzRef.setVisibleRange(dataProvider.getCh1_valueRange()); yAxisPzRef.setAutoRange(AutoRange.Never); yAxisPzRef.setVisibleRange(dataProvider.getCh1_valueRange()); yAxisOzRef.setAutoRange(AutoRange.Never); yAxisOzRef.setVisibleRange(dataProvider.getCh1_valueRange()); yAxisPG1Ref.setAutoRange(AutoRange.Never); yAxisPG1Ref.setVisibleRange(dataProvider.getCh1_valueRange()); yAxisPG2Ref.setAutoRange(AutoRange.Never); yAxisPG2Ref.setVisibleRange(dataProvider.getCh1_valueRange()); } }
  • You must to post comments
0
0

I have added it in update indicators method() where I update impedence every 5 sec. i update visible range based on sensitivity selection. I m able to see the toast msg for every 5 sec with the selected sensitivity and min and max visible range. But graph is not updated. it may be because numeriicAxis is defined as final. But without final i will not be able to define it. Note; impedence values updates properly every five sec. But graph setvisible range not updated,

 private void updateIndicators(long time) {
        final Context context1 = getActivity();
    if(time % 5 == 0) {
        indicatorsProvider.update();

        binding.heartRateIndicator.impedencech0.setText("Fp1-Ref: " + (Double.toString(Math.round(Impedance_ch[0]*100.0)/100.0)));
        if (Impedance_ch[0] <= 5000) {
            binding.heartRateIndicator.impedencech0.setTextColor(Color.DKGRAY);
            int Fp1Ref = ContextCompat.getColor(context1, R.color.DKGREEN);
        }
        if (Impedance_ch[0] <= 10000 & Impedance_ch[0] > 5000) {
            binding.heartRateIndicator.impedencech0.setTextColor(Color.GREEN);
            int Fp1Ref = ContextCompat.getColor(context1, R.color.GREEN);
        }
        if (Impedance_ch[0] > 10000) {
            binding.heartRateIndicator.impedencech0.setTextColor(Color.RED);
            int Fp1Ref = ContextCompat.getColor(context1, R.color.RED);

        }

        binding.heartRateIndicator.impedencech1.setText("Fp2-Ref: " + (Double.toString(Math.round(Impedance_ch[1]*100.0)/100.0)));
        if (Impedance_ch[1] <= 5000) {
            binding.heartRateIndicator.impedencech1.setTextColor(Color.DKGRAY);
            int Fp2Ref = ContextCompat.getColor(context1, R.color.DKGREEN);
        }
        if (Impedance_ch[1] <= 10000 & Impedance_ch[1] > 5000) {
            binding.heartRateIndicator.impedencech1.setTextColor(Color.GREEN);
            int Fp2Ref = ContextCompat.getColor(context1, R.color.GREEN);
        }
        if (Impedance_ch[1] > 10000) {
            binding.heartRateIndicator.impedencech1.setTextColor(Color.RED);
            int Fp2Ref = ContextCompat.getColor(context1, R.color.RED);
        }

        binding.heartRateIndicator.impedencech2.setText("F3-Ref: " + (Double.toString(Math.round(Impedance_ch[2]*100.0)/100.0)));
        if (Impedance_ch[2] <= 5000) {
            binding.heartRateIndicator.impedencech2.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[2] <= 10000 & Impedance_ch[2] > 5000) {
            binding.heartRateIndicator.impedencech2.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[2] > 10000) {
            binding.heartRateIndicator.impedencech2.setTextColor(Color.RED);
        }

        binding.heartRateIndicator.impedencech3.setText("F4-Ref: " + (Double.toString(Math.round(Impedance_ch[3]*100.0)/100.0)));
        if (Impedance_ch[3] <= 5000) {
            binding.heartRateIndicator.impedencech3.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[3] <= 10000 & Impedance_ch[3] > 5000) {
            binding.heartRateIndicator.impedencech3.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[3] > 10000) {
            binding.heartRateIndicator.impedencech3.setTextColor(Color.RED);
        }

        binding.heartRateIndicator.impedencech4.setText("C3-Ref: " + (Double.toString(Math.round(Impedance_ch[4]*100.0)/100.0)));
        if (Impedance_ch[4] <= 5000) {
            binding.heartRateIndicator.impedencech4.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[4] <= 10000 & Impedance_ch[4] > 5000) {
            binding.heartRateIndicator.impedencech4.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[4] > 10000) {
            binding.heartRateIndicator.impedencech4.setTextColor(Color.RED);
        }

        binding.heartRateIndicator.impedencech5.setText("C4-Ref: " + (Double.toString(Math.round(Impedance_ch[5]*100.0)/100.0)));
        if (Impedance_ch[5] <= 5000) {
            binding.heartRateIndicator.impedencech5.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[5] <= 10000 & Impedance_ch[5] > 5000) {
            binding.heartRateIndicator.impedencech5.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[5] > 10000) {
            binding.heartRateIndicator.impedencech5.setTextColor(Color.RED);
        }

        binding.heartRateIndicator.impedencech6.setText("P3-Ref: " + (Double.toString(Math.round(Impedance_ch[6]*100.0)/100.0)));
        if (Impedance_ch[6] <= 5000) {
            binding.heartRateIndicator.impedencech6.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[6] <= 10000 & Impedance_ch[6] > 5000) {
            binding.heartRateIndicator.impedencech6.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[6] > 10000) {
            binding.heartRateIndicator.impedencech6.setTextColor(Color.RED);
        }

        binding.heartRateIndicator.impedencech7.setText("P4-Ref: " + (Double.toString(Math.round(Impedance_ch[7]*100.0)/100.0)));
        if (Impedance_ch[7] <= 5000) {
            binding.heartRateIndicator.impedencech7.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[7] <= 10000 & Impedance_ch[7] > 5000) {
            binding.heartRateIndicator.impedencech7.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[7] > 10000) {
            binding.heartRateIndicator.impedencech7.setTextColor(Color.RED);
        }

        binding.heartRateIndicator.impedencech8.setText("O1-Ref: " + (Double.toString(Math.round(Impedance_ch[8]*100.0)/100.0)));
        if (Impedance_ch[8] <= 5000) {
            binding.heartRateIndicator.impedencech8.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[8] <= 10000 & Impedance_ch[8] > 5000) {
            binding.heartRateIndicator.impedencech8.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[8] > 10000) {
            binding.heartRateIndicator.impedencech8.setTextColor(Color.RED);
        }

        binding.heartRateIndicator.impedencech9.setText("O2-Ref: " + (Double.toString(Math.round(Impedance_ch[9]*100.0)/100.0)));
        if (Impedance_ch[9] <= 5000) {
            binding.heartRateIndicator.impedencech9.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[9] <= 10000 & Impedance_ch[9] > 5000) {
            binding.heartRateIndicator.impedencech9.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[9] > 10000) {
            binding.heartRateIndicator.impedencech9.setTextColor(Color.RED);
        }

        binding.heartRateIndicator.impedencech10.setText("F7-Ref: " + (Double.toString(Math.round(Impedance_ch[10]*100.0)/100.0)));
        if (Impedance_ch[10] <= 5000) {
            binding.heartRateIndicator.impedencech10.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[10] <= 10000 & Impedance_ch[10] > 5000) {
            binding.heartRateIndicator.impedencech10.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[10] > 10000) {
            binding.heartRateIndicator.impedencech10.setTextColor(Color.RED);
        }

        //
        binding.heartRateIndicator.impedencech11.setText("F8-Ref: " + (Double.toString(Math.round(Impedance_ch[11]*100.0)/100.0)));
        if (Impedance_ch[11] <= 5000) {
            binding.heartRateIndicator.impedencech11.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[11] <= 10000 & Impedance_ch[11] > 5000) {
            binding.heartRateIndicator.impedencech11.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[11] > 10000) {
            binding.heartRateIndicator.impedencech11.setTextColor(Color.RED);
        }

        binding.heartRateIndicator.impedencech12.setText("T3-Ref: " + (Double.toString(Math.round(Impedance_ch[12]*100.0)/100.0)));
        if (Impedance_ch[12] <= 5000) {
            binding.heartRateIndicator.impedencech12.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[12] <= 10000 & Impedance_ch[12] > 5000) {
            binding.heartRateIndicator.impedencech12.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[12] > 10000) {
            binding.heartRateIndicator.impedencech12.setTextColor(Color.RED);
        }

        binding.heartRateIndicator.impedencech13.setText("T4-Ref: " + (Double.toString(Math.round(Impedance_ch[13]*100.0)/100.0)));
        if (Impedance_ch[13] <= 5000) {
            binding.heartRateIndicator.impedencech13.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[13] <= 10000 & Impedance_ch[13] > 5000) {
            binding.heartRateIndicator.impedencech13.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[13] > 10000) {
            binding.heartRateIndicator.impedencech13.setTextColor(Color.RED);
        }

        binding.heartRateIndicator.impedencech14.setText("T5-Ref: " + (Double.toString(Math.round(Impedance_ch[14]*100.0)/100.0)));
        if (Impedance_ch[14] <= 5000) {
            binding.heartRateIndicator.impedencech14.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[14] <= 10000 & Impedance_ch[14] > 5000) {
            binding.heartRateIndicator.impedencech14.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[14] > 10000) {
            binding.heartRateIndicator.impedencech14.setTextColor(Color.RED);
        }
        binding.heartRateIndicator.impedencech15.setText("T6-Ref: " + (Double.toString(Math.round(Impedance_ch[15]*100.0)/100.0)));
        if (Impedance_ch[15] <= 5000) {
            binding.heartRateIndicator.impedencech15.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[15] <= 10000 & Impedance_ch[15] > 5000) {
            binding.heartRateIndicator.impedencech15.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[15] > 10000) {
            binding.heartRateIndicator.impedencech15.setTextColor(Color.RED);
        }

        binding.heartRateIndicator.impedencech16.setText("A1-Ref: " + (Double.toString(Math.round(Impedance_ch[16]*100.0)/100.0)));
        if (Impedance_ch[16] <= 5000) {
            binding.heartRateIndicator.impedencech16.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[16] <= 10000 & Impedance_ch[16] > 5000) {
            binding.heartRateIndicator.impedencech16.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[16] > 10000) {
            binding.heartRateIndicator.impedencech16.setTextColor(Color.RED);
        }
        binding.heartRateIndicator.impedencech17.setText("A2-Ref: " + (Double.toString(Math.round(Impedance_ch[17]*100.0)/100.0)));
        if (Impedance_ch[17] <= 5000) {
            binding.heartRateIndicator.impedencech17.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[17] <= 10000 & Impedance_ch[17] > 5000) {
            binding.heartRateIndicator.impedencech17.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[17] > 10000) {
            binding.heartRateIndicator.impedencech17.setTextColor(Color.RED);
        }
        binding.heartRateIndicator.impedencech18.setText("Fz-Ref: " + (Double.toString(Math.round(Impedance_ch[18]*100.0)/100.0)));
        if (Impedance_ch[18] <= 5000) {
            binding.heartRateIndicator.impedencech18.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[18] <= 10000 & Impedance_ch[18] > 5000) {
            binding.heartRateIndicator.impedencech18.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[18] > 10000) {
            binding.heartRateIndicator.impedencech18.setTextColor(Color.RED);
        }

        binding.heartRateIndicator.impedencech19.setText("Cz-Ref: " + (Double.toString(Math.round(Impedance_ch[19]*100.0)/100.0)));
        if (Impedance_ch[19] <= 5000) {
            binding.heartRateIndicator.impedencech19.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[19] <= 10000 & Impedance_ch[19] > 5000) {
            binding.heartRateIndicator.impedencech17.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[19] > 10000) {
            binding.heartRateIndicator.impedencech19.setTextColor(Color.RED);
        }
        binding.heartRateIndicator.impedencech20.setText("Pz-Ref: " + (Double.toString(Math.round(Impedance_ch[20]*100.0)/100.0)));
        if (Impedance_ch[20] <= 5000) {
            binding.heartRateIndicator.impedencech20.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[20] <= 10000 & Impedance_ch[20] > 5000) {
            binding.heartRateIndicator.impedencech20.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[20] > 10000) {
            binding.heartRateIndicator.impedencech20.setTextColor(Color.RED);
        }
        binding.heartRateIndicator.impedencech21.setText("Oz-Ref: " + (Double.toString(Math.round(Impedance_ch[21]*100.0)/100.0)));
        if (Impedance_ch[21] <= 5000) {
            binding.heartRateIndicator.impedencech21.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[21] <= 10000 & Impedance_ch[21] > 5000) {
            binding.heartRateIndicator.impedencech21.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[21] > 10000) {
            binding.heartRateIndicator.impedencech21.setTextColor(Color.RED);
        }
        binding.heartRateIndicator.impedencech22.setText("PG1-Ref: " + (Double.toString(Math.round(Impedance_ch[22]*100.0)/100.0)));
        if (Impedance_ch[22] <= 5000) {
            binding.heartRateIndicator.impedencech22.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[22] <= 10000 & Impedance_ch[22] > 5000) {
            binding.heartRateIndicator.impedencech22.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[22] > 10000) {
            binding.heartRateIndicator.impedencech22.setTextColor(Color.RED);
        }
        binding.heartRateIndicator.impedencech23.setText("PG2-Ref: " + (Double.toString(Math.round(Impedance_ch[23]*100.0)/100.0)));
        if (Impedance_ch[23] <= 5000) {
            binding.heartRateIndicator.impedencech23.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[23] <= 10000 & Impedance_ch[23] > 5000) {
            binding.heartRateIndicator.impedencech21.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[23] > 10000) {
            binding.heartRateIndicator.impedencech23.setTextColor(Color.RED);
        }
        Toast.makeText(getActivity(), "Selected Sensitivity position in update: "+ Sensitivity_pos, Toast.LENGTH_LONG).show();



        final DefaultVitalSignsDataProvider dataProvider = new DefaultVitalSignsDataProvider(getActivity());

        Toast.makeText(getActivity(), "Selected Sensitivity rage: "+ dataProvider.getCh1_valueRange(), Toast.LENGTH_LONG).show();

        final String Fp1RefId = "Fp1-Ref";
        final String Fp2RefId = "Fp2-Ref";
        final String F3RefId = "F3-Ref";
        final String F4RefId = "F4-Ref";
        final String C3RefId = "C3-Ref";
        final String C4RefId = "C4-Ref";
        final String P3RefId = "P3-Ref";
        final String P4RefId = "P4-Ref";
        final String O1RefId = "O1-Ref";
        final String O2RefId = "O2-Ref";
        final String F7RefId = "F7-Ref";
        final String F8RefId = "F8-Ref";
        final String T3RefId = "T3-Ref";
        final String T4RefId = "T4-Ref";
        final String T5RefId = "T5-Ref";
        final String T6RefId = "T6-Ref";
        final String A1RefId = "A1-Ref";
        final String A2RefId = "A2-Ref";
        final String FzRefId = "Fz-Ref";
        final String CzRefId = "Cz-Ref";
        final String PzRefId = "Pz-Ref";
        final String OzRefId = "Oz-Ref";
        final String PG1RefId = "PG1-Ref";
        final String PG2RefId = "PG2-Ref";

        final NumericAxis yAxisFp1Ref = generateYAxis(Fp1RefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisFp2Ref = generateYAxis(Fp2RefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisF3Ref = generateYAxis(F3RefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisF4Ref = generateYAxis(F4RefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisC3Ref = generateYAxis(C3RefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisC4Ref = generateYAxis(C4RefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisP3Ref = generateYAxis(P3RefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisP4Ref = generateYAxis(P4RefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisO1Ref = generateYAxis(O1RefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisO2Ref = generateYAxis(O2RefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisF7Ref = generateYAxis(F7RefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisF8Ref = generateYAxis(F8RefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisT3Ref = generateYAxis(T3RefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisT4Ref = generateYAxis(T4RefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisT5Ref = generateYAxis(T5RefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisT6Ref = generateYAxis(T6RefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisA1Ref = generateYAxis(A1RefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisA2Ref = generateYAxis(A2RefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisFzRef = generateYAxis(FzRefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisCzRef = generateYAxis(CzRefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisPzRef = generateYAxis(PzRefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisOzRef = generateYAxis(OzRefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisPG1Ref = generateYAxis(PG1RefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisPG2Ref = generateYAxis(PG2RefId, dataProvider.getBloodOxygenationRange());


        //change the sensitivity

        yAxisFp1Ref.setAutoRange(AutoRange.Never);
        yAxisFp1Ref.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisFp2Ref.setAutoRange(AutoRange.Never);
        yAxisFp2Ref.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisF3Ref.setAutoRange(AutoRange.Never);
        yAxisF3Ref.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisF4Ref.setAutoRange(AutoRange.Never);
        yAxisF4Ref.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisC3Ref.setAutoRange(AutoRange.Never);
        yAxisC3Ref.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisC4Ref.setAutoRange(AutoRange.Never);
        yAxisC4Ref.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisP3Ref.setAutoRange(AutoRange.Never);
        yAxisP3Ref.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisP4Ref.setAutoRange(AutoRange.Never);
        yAxisP4Ref.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisO1Ref.setAutoRange(AutoRange.Never);
        yAxisO1Ref.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisO2Ref.setAutoRange(AutoRange.Never);
        yAxisO2Ref.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisF7Ref.setAutoRange(AutoRange.Never);
        yAxisF7Ref.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisF8Ref.setAutoRange(AutoRange.Never);
        yAxisF8Ref.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisT3Ref.setAutoRange(AutoRange.Never);
        yAxisT3Ref.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisT4Ref.setAutoRange(AutoRange.Never);
        yAxisT4Ref.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisT5Ref.setAutoRange(AutoRange.Never);
        yAxisT5Ref.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisT6Ref.setAutoRange(AutoRange.Never);
        yAxisT6Ref.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisA1Ref.setAutoRange(AutoRange.Never);
        yAxisA1Ref.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisA2Ref.setAutoRange(AutoRange.Never);
        yAxisA2Ref.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisFzRef.setAutoRange(AutoRange.Never);
        yAxisFzRef.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisCzRef.setAutoRange(AutoRange.Never);
        yAxisCzRef.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisPzRef.setAutoRange(AutoRange.Never);
        yAxisPzRef.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisOzRef.setAutoRange(AutoRange.Never);
        yAxisOzRef.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisPG1Ref.setAutoRange(AutoRange.Never);
        yAxisPG1Ref.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisPG2Ref.setAutoRange(AutoRange.Never);
        yAxisPG2Ref.setVisibleRange(dataProvider.getCh1_valueRange());


    }
}
  • Yura Khariton
    I’m not 100% sure ( you didn’t provide source code of generateYAxis() method ) but it looks like generateYAxis() creates new NumericAxis instance. If updateIndicators() is called every 5 seconds this means that you recreate yAxes, but I don’t see where you add them into SciChartSurface. It looks like they are created, then you set AutoRange and VisibleRange for them and that’s all ( they never used by chart ). In this case solution for your problem will be rewriting code in a such way that you update VisibleRange on NumeriAxis instances that are used by chart ( maybe you can create and save yAxes in private fields of class, then just update VisibleRange for them in updateIndicators() method )
  • You must to post comments
0
0

Full source code of : vitalsignsMonitorShowcaseFragment.java

//******************************************************************************

// SCICHART® Copyright SciChart Ltd. 2011-2019. All rights reserved.
//
// Web: http://www.scichart.com
// Support: support@scichart.com
// Sales: sales@scichart.com
//
// VitalSignsMonitorShowcaseFragment.java is part of the SCICHART® Examples. Permission is hereby granted
// to modify, create derivative works, distribute and publish any part of this source
// code whether for commercial, private or personal use.
//
// The SCICHART® examples are distributed in the hope that they will be useful, but
// without any warranty. It is provided “AS IS” without warranty of any kind, either
// expressed or implied.
//******************************************************************************

package com.mocxa.eeg.fragments.showcase.vitalSignsMonitor;

import static com.mocxa.eeg.GraphFragment1.Sensitivity_pos;
import static com.mocxa.eeg.GraphFragment1.mChart;
import static com.mocxa.eeg.LiveGraphActivity.Impedance_ch;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Toast;

import androidx.core.content.ContextCompat;
import androidx.viewbinding.ViewBinding;

import com.github.mikephil.charting.components.Legend;
import com.mocxa.eeg.LiveGraphActivity;
import com.scichart.charting.layoutManagers.ChartLayoutState;
import com.scichart.charting.layoutManagers.DefaultLayoutManager;
import com.scichart.charting.layoutManagers.VerticalAxisLayoutStrategy;
import com.scichart.charting.model.dataSeries.IDataSeries;
import com.scichart.charting.model.dataSeries.XyDataSeries;
import com.scichart.charting.visuals.SciChartSurface;
import com.scichart.charting.visuals.annotations.HorizontalAnchorPoint;
import com.scichart.charting.visuals.annotations.TextAnnotation;
import com.scichart.charting.visuals.annotations.VerticalAnchorPoint;
import com.scichart.charting.visuals.axes.AutoRange;
import com.scichart.charting.visuals.axes.AxisLayoutState;
import com.scichart.charting.visuals.axes.IAxis;
import com.scichart.charting.visuals.axes.NumericAxis;
import com.scichart.charting.visuals.pointmarkers.EllipsePointMarker;
import com.scichart.charting.visuals.renderableSeries.IRenderableSeries;
import com.scichart.charting.visuals.renderableSeries.XyRenderableSeriesBase;
import com.scichart.charting.visuals.renderableSeries.paletteProviders.IStrokePaletteProvider;
import com.scichart.charting.visuals.renderableSeries.paletteProviders.PaletteProviderBase;
import com.scichart.core.framework.UpdateSuspender;
import com.scichart.core.model.DoubleValues;
import com.scichart.core.model.IntegerValues;
import com.scichart.data.model.DoubleRange;
import com.scichart.drawing.canvas.RenderSurface;
import com.scichart.drawing.common.FontStyle;
import com.scichart.drawing.common.PenStyle;
import com.scichart.drawing.utility.ColorUtil;
import com.mocxa.eeg.R;
import com.mocxa.eeg.databinding.ExampleVitalSignsBloodOxygenationIndicatorLayoutBinding;
import com.mocxa.eeg.databinding.ExampleVitalSignsBloodPressureIndicatorLayoutBinding;
import com.mocxa.eeg.databinding.ExampleVitalSignsMonitorFragmentBinding;
import com.mocxa.eeg.fragments.base.ShowcaseExampleBaseFragment;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;

import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;

public class VitalSignsMonitorShowcaseFragment extends ShowcaseExampleBaseFragment {
private static final int FIFO_CAPACITY = 7850;

private final XyDataSeries<Double, Double> ecgDataSeries = newDataSeries(FIFO_CAPACITY);
private final XyDataSeries<Double, Double> ecgSweepDataSeries = newDataSeries(FIFO_CAPACITY);

private final XyDataSeries<Double, Double> CH1DataSeries = newDataSeries(FIFO_CAPACITY);
private final XyDataSeries<Double, Double> CH1SweepDataSeries = newDataSeries(FIFO_CAPACITY);

private final XyDataSeries<Double, Double> CH2DataSeries = newDataSeries(FIFO_CAPACITY);
private final XyDataSeries<Double, Double> CH2SweepDataSeries = newDataSeries(FIFO_CAPACITY);

private final XyDataSeries<Double, Double> CH3DataSeries = newDataSeries(FIFO_CAPACITY);
private final XyDataSeries<Double, Double> CH3SweepDataSeries = newDataSeries(FIFO_CAPACITY);

private final XyDataSeries<Double, Double> CH4DataSeries = newDataSeries(FIFO_CAPACITY);
private final XyDataSeries<Double, Double> CH4SweepDataSeries = newDataSeries(FIFO_CAPACITY);

private final XyDataSeries<Double, Double> CH5DataSeries = newDataSeries(FIFO_CAPACITY);
private final XyDataSeries<Double, Double> CH5SweepDataSeries = newDataSeries(FIFO_CAPACITY);

private final XyDataSeries<Double, Double> CH6DataSeries = newDataSeries(FIFO_CAPACITY);
private final XyDataSeries<Double, Double> CH6SweepDataSeries = newDataSeries(FIFO_CAPACITY);

private final XyDataSeries<Double, Double> CH7DataSeries = newDataSeries(FIFO_CAPACITY);
private final XyDataSeries<Double, Double> CH7SweepDataSeries = newDataSeries(FIFO_CAPACITY);

private final XyDataSeries<Double, Double> CH8DataSeries = newDataSeries(FIFO_CAPACITY);
private final XyDataSeries<Double, Double> CH8SweepDataSeries = newDataSeries(FIFO_CAPACITY);

private final XyDataSeries<Double, Double> CH9DataSeries = newDataSeries(FIFO_CAPACITY);
private final XyDataSeries<Double, Double> CH9SweepDataSeries = newDataSeries(FIFO_CAPACITY);

private final XyDataSeries<Double, Double> CH10DataSeries = newDataSeries(FIFO_CAPACITY);
private final XyDataSeries<Double, Double> CH10SweepDataSeries = newDataSeries(FIFO_CAPACITY);

private final XyDataSeries<Double, Double> CH11DataSeries = newDataSeries(FIFO_CAPACITY);
private final XyDataSeries<Double, Double> CH11SweepDataSeries = newDataSeries(FIFO_CAPACITY);

private final XyDataSeries<Double, Double> CH12DataSeries = newDataSeries(FIFO_CAPACITY);
private final XyDataSeries<Double, Double> CH12SweepDataSeries = newDataSeries(FIFO_CAPACITY);

private final XyDataSeries<Double, Double> CH13DataSeries = newDataSeries(FIFO_CAPACITY);
private final XyDataSeries<Double, Double> CH13SweepDataSeries = newDataSeries(FIFO_CAPACITY);

private final XyDataSeries<Double, Double> CH14DataSeries = newDataSeries(FIFO_CAPACITY);
private final XyDataSeries<Double, Double> CH14SweepDataSeries = newDataSeries(FIFO_CAPACITY);

private final XyDataSeries<Double, Double> CH15DataSeries = newDataSeries(FIFO_CAPACITY);
private final XyDataSeries<Double, Double> CH15SweepDataSeries = newDataSeries(FIFO_CAPACITY);

private final XyDataSeries<Double, Double> CH16DataSeries = newDataSeries(FIFO_CAPACITY);
private final XyDataSeries<Double, Double> CH16SweepDataSeries = newDataSeries(FIFO_CAPACITY);

private final XyDataSeries<Double, Double> CH17DataSeries = newDataSeries(FIFO_CAPACITY);
private final XyDataSeries<Double, Double> CH17SweepDataSeries = newDataSeries(FIFO_CAPACITY);

private final XyDataSeries<Double, Double> CH18DataSeries = newDataSeries(FIFO_CAPACITY);
private final XyDataSeries<Double, Double> CH18SweepDataSeries = newDataSeries(FIFO_CAPACITY);

private final XyDataSeries<Double, Double> CH19DataSeries = newDataSeries(FIFO_CAPACITY);
private final XyDataSeries<Double, Double> CH19SweepDataSeries = newDataSeries(FIFO_CAPACITY);

private final XyDataSeries<Double, Double> CH20DataSeries = newDataSeries(FIFO_CAPACITY);
private final XyDataSeries<Double, Double> CH20SweepDataSeries = newDataSeries(FIFO_CAPACITY);

private final XyDataSeries<Double, Double> CH21DataSeries = newDataSeries(FIFO_CAPACITY);
private final XyDataSeries<Double, Double> CH21SweepDataSeries = newDataSeries(FIFO_CAPACITY);

private final XyDataSeries<Double, Double> CH22DataSeries = newDataSeries(FIFO_CAPACITY);
private final XyDataSeries<Double, Double> CH22SweepDataSeries = newDataSeries(FIFO_CAPACITY);

private final XyDataSeries<Double, Double> CH23DataSeries = newDataSeries(FIFO_CAPACITY);
private final XyDataSeries<Double, Double> CH23SweepDataSeries = newDataSeries(FIFO_CAPACITY);

private final XyDataSeries<Double, Double> CH24DataSeries = newDataSeries(FIFO_CAPACITY);
private final XyDataSeries<Double, Double> CH24SweepDataSeries = newDataSeries(FIFO_CAPACITY);


private final XyDataSeries<Double, Double> lastEcgSweepDataSeries = newDataSeries(1);
private final XyDataSeries<Double, Double> lastBloodPressureDataSeries = newDataSeries(1);
private final XyDataSeries<Double, Double> lastBloodVolumeDataSeries = newDataSeries(1);
private final XyDataSeries<Double, Double> lastBloodOxygenationSweepDataSeries = newDataSeries(1);

private final XyDataSeries<Double, Double> lastCh1DataSeries = newDataSeries(1);
private final XyDataSeries<Double, Double> lastCh2DataSeries = newDataSeries(1);
private final XyDataSeries<Double, Double> lastCh3DataSeries = newDataSeries(1);
private final XyDataSeries<Double, Double> lastCh4DataSeries = newDataSeries(1);
private final XyDataSeries<Double, Double> lastCh5DataSeries = newDataSeries(1);
private final XyDataSeries<Double, Double> lastCh6DataSeries = newDataSeries(1);
private final XyDataSeries<Double, Double> lastCh7DataSeries = newDataSeries(1);
private final XyDataSeries<Double, Double> lastCh8DataSeries = newDataSeries(1);
private final XyDataSeries<Double, Double> lastCh9DataSeries = newDataSeries(1);
private final XyDataSeries<Double, Double> lastCh10DataSeries = newDataSeries(1);
private final XyDataSeries<Double, Double> lastCh11DataSeries = newDataSeries(1);
private final XyDataSeries<Double, Double> lastCh12DataSeries = newDataSeries(1);
private final XyDataSeries<Double, Double> lastCh13DataSeries = newDataSeries(1);
private final XyDataSeries<Double, Double> lastCh14DataSeries = newDataSeries(1);
private final XyDataSeries<Double, Double> lastCh15DataSeries = newDataSeries(1);
private final XyDataSeries<Double, Double> lastCh16DataSeries = newDataSeries(1);
private final XyDataSeries<Double, Double> lastCh17DataSeries = newDataSeries(1);
private final XyDataSeries<Double, Double> lastCh18DataSeries = newDataSeries(1);
private final XyDataSeries<Double, Double> lastCh19DataSeries = newDataSeries(1);
private final XyDataSeries<Double, Double> lastCh20DataSeries = newDataSeries(1);
private final XyDataSeries<Double, Double> lastCh21DataSeries = newDataSeries(1);
private final XyDataSeries<Double, Double> lastCh22DataSeries = newDataSeries(1);
private final XyDataSeries<Double, Double> lastCh23DataSeries = newDataSeries(1);
private final XyDataSeries<Double, Double> lastCh24DataSeries = newDataSeries(1);
//NumericAxis yAxisFp1Ref, yAxisFp2Ref,  yAxisF3Ref,  yAxisF4Ref;


private final VitalSignsIndicatorsProvider indicatorsProvider = new VitalSignsIndicatorsProvider();

private final EcgDataBatch dataBatch = new EcgDataBatch();

@Override
protected ExampleVitalSignsMonitorFragmentBinding inflateBinding(LayoutInflater inflater) {
    return ExampleVitalSignsMonitorFragmentBinding.inflate(inflater);
}

@Override
protected void initExample(ExampleVitalSignsMonitorFragmentBinding binding) {
    final DefaultVitalSignsDataProvider dataProvider = new DefaultVitalSignsDataProvider(getActivity());

    setUpChart(dataProvider);

    dataProvider.getData().buffer(50, TimeUnit.MILLISECONDS).doOnNext(ecgData -> {
        if(ecgData.isEmpty()) return;

        dataBatch.updateData(ecgData);

        UpdateSuspender.using(binding.surface, () -> {
            final DoubleValues xValues = dataBatch.xValues;

           // ecgDataSeries.append(xValues, dataBatch.ecgHeartRateValuesA);
          //  ecgSweepDataSeries.append(xValues, dataBatch.ecgHeartRateValuesB);

            CH1DataSeries.append(xValues, dataBatch.Ch1_valueA);
            CH1SweepDataSeries.append(xValues, dataBatch.Ch1_valueB);

           /* CH1DataSeries.append(xValues, (LiveGraphActivity.EEG_Data_Display_list[0][0]));
            CH1SweepDataSeries.append(xValues, LiveGraphActivity.EEG_Data_Display_list[0][1]);*/

            CH2DataSeries.append(xValues, dataBatch.Ch2_valueA);
            CH2SweepDataSeries.append(xValues, dataBatch.Ch2_valueB);

            CH3DataSeries.append(xValues, dataBatch.Ch3_valueA);
            CH3SweepDataSeries.append(xValues, dataBatch.Ch3_valueB);

            CH4DataSeries.append(xValues, dataBatch.Ch4_valueA);
            CH4SweepDataSeries.append(xValues, dataBatch.Ch4_valueB);

            CH5DataSeries.append(xValues, dataBatch.Ch5_valueA);
            CH5SweepDataSeries.append(xValues, dataBatch.Ch5_valueB);

            CH6DataSeries.append(xValues, dataBatch.Ch6_valueA);
            CH6SweepDataSeries.append(xValues, dataBatch.Ch6_valueB);

            CH7DataSeries.append(xValues, dataBatch.Ch7_valueA);
            CH7SweepDataSeries.append(xValues, dataBatch.Ch7_valueB);

            CH8DataSeries.append(xValues, dataBatch.Ch8_valueA);
            CH8SweepDataSeries.append(xValues, dataBatch.Ch8_valueB);

            CH9DataSeries.append(xValues, dataBatch.Ch9_valueA);
            CH9SweepDataSeries.append(xValues, dataBatch.Ch9_valueB);

            CH10DataSeries.append(xValues, dataBatch.Ch10_valueA);
            CH10SweepDataSeries.append(xValues, dataBatch.Ch10_valueB);

            CH11DataSeries.append(xValues, dataBatch.Ch11_valueA);
            CH11SweepDataSeries.append(xValues, dataBatch.Ch11_valueB);

            CH12DataSeries.append(xValues, dataBatch.Ch12_valueA);
            CH12SweepDataSeries.append(xValues, dataBatch.Ch12_valueB);

            CH13DataSeries.append(xValues, dataBatch.Ch13_valueA);
            CH13SweepDataSeries.append(xValues, dataBatch.Ch13_valueB);

            CH14DataSeries.append(xValues, dataBatch.Ch14_valueA);
            CH14SweepDataSeries.append(xValues, dataBatch.Ch14_valueB);

            CH15DataSeries.append(xValues, dataBatch.Ch15_valueA);
            CH15SweepDataSeries.append(xValues, dataBatch.Ch15_valueB);

            CH16DataSeries.append(xValues, dataBatch.Ch16_valueA);
            CH16SweepDataSeries.append(xValues, dataBatch.Ch16_valueB);

            CH17DataSeries.append(xValues, dataBatch.Ch17_valueA);
            CH17SweepDataSeries.append(xValues, dataBatch.Ch17_valueB);

            CH18DataSeries.append(xValues, dataBatch.Ch18_valueA);
            CH18SweepDataSeries.append(xValues, dataBatch.Ch18_valueB);

            CH19DataSeries.append(xValues, dataBatch.Ch19_valueA);
            CH19SweepDataSeries.append(xValues, dataBatch.Ch19_valueB);

            CH20DataSeries.append(xValues, dataBatch.Ch20_valueA);
            CH20SweepDataSeries.append(xValues, dataBatch.Ch20_valueB);

            CH21DataSeries.append(xValues, dataBatch.Ch21_valueA);
            CH21SweepDataSeries.append(xValues, dataBatch.Ch21_valueB);

            CH22DataSeries.append(xValues, dataBatch.Ch22_valueA);
            CH22SweepDataSeries.append(xValues, dataBatch.Ch22_valueB);

            CH23DataSeries.append(xValues, dataBatch.Ch23_valueA);
            CH23SweepDataSeries.append(xValues, dataBatch.Ch23_valueB);

            CH24DataSeries.append(xValues, dataBatch.Ch24_valueA);
            CH24SweepDataSeries.append(xValues, dataBatch.Ch24_valueB);




          /*  bloodPressureDataSeries.append(xValues, dataBatch.bloodPressureValuesA);
            bloodPressureSweepDataSeries.append(xValues, dataBatch.bloodPressureValuesB);

            bloodOxygenationDataSeries.append(xValues, dataBatch.bloodOxygenationA);
            bloodOxygenationSweepDataSeries.append(xValues, dataBatch.bloodOxygenationB);

            bloodVolumeDataSeries.append(xValues, dataBatch.bloodVolumeValuesA);
            bloodVolumeSweepDataSeries.append(xValues, dataBatch.bloodVolumeValuesB);
            */


            final VitalSignsData lastVitalSignsData = dataBatch.lastVitalSignsData;
            final double xValue = lastVitalSignsData.xValue;

            lastCh1DataSeries.append(xValue, lastVitalSignsData.Ch1_Value);
            lastCh2DataSeries.append(xValue, lastVitalSignsData.Ch2_Value);
            lastCh3DataSeries.append(xValue, lastVitalSignsData.Ch3_Value);
            lastCh4DataSeries.append(xValue, lastVitalSignsData.Ch4_Value);
            lastCh5DataSeries.append(xValue, lastVitalSignsData.Ch5_Value);
            lastCh6DataSeries.append(xValue, lastVitalSignsData.Ch6_Value);
            lastCh7DataSeries.append(xValue, lastVitalSignsData.Ch7_Value);
            lastCh8DataSeries.append(xValue, lastVitalSignsData.Ch8_Value);
            lastCh9DataSeries.append(xValue, lastVitalSignsData.Ch9_Value);
            lastCh10DataSeries.append(xValue, lastVitalSignsData.Ch10_Value);
            lastCh11DataSeries.append(xValue, lastVitalSignsData.Ch11_Value);
            lastCh12DataSeries.append(xValue, lastVitalSignsData.Ch12_Value);
            lastCh13DataSeries.append(xValue, lastVitalSignsData.Ch13_Value);
            lastCh14DataSeries.append(xValue, lastVitalSignsData.Ch14_Value);
            lastCh15DataSeries.append(xValue, lastVitalSignsData.Ch15_Value);
            lastCh16DataSeries.append(xValue, lastVitalSignsData.Ch16_Value);
            lastCh17DataSeries.append(xValue, lastVitalSignsData.Ch17_Value);
            lastCh18DataSeries.append(xValue, lastVitalSignsData.Ch18_Value);
            lastCh19DataSeries.append(xValue, lastVitalSignsData.Ch19_Value);
            lastCh20DataSeries.append(xValue, lastVitalSignsData.Ch20_Value);
            lastCh21DataSeries.append(xValue, lastVitalSignsData.Ch21_Value);
            lastCh22DataSeries.append(xValue, lastVitalSignsData.Ch22_Value);
            lastCh23DataSeries.append(xValue, lastVitalSignsData.Ch23_Value);
            lastCh24DataSeries.append(xValue, lastVitalSignsData.Ch24_Value);



        });
    }).compose(bindToLifecycle()).subscribe();

    updateIndicators(0);
    Observable.interval(0, 1, TimeUnit.SECONDS, AndroidSchedulers.mainThread())
            .doOnNext(this::updateIndicators)
            .compose(bindToLifecycle()).subscribe();
}

public void updatesetVisibleRange() {
    //final Context context1 = getActivity();
    final DefaultVitalSignsDataProvider dataProvider = new DefaultVitalSignsDataProvider(getActivity());

    //Toast.makeText(getActivity(), "Selected Sensitivity position in updatevisilerage: "+ Sensitivity_pos, Toast.LENGTH_LONG).show();
    updateIndicators(0);
   /* final String Fp1RefId = "Fp1-Ref";
    final String Fp2RefId = "Fp2-Ref";
    final String F3RefId = "F3-Ref";
    final String F4RefId = "F4-Ref";
    final String C3RefId = "C3-Ref";
    final String C4RefId = "C4-Ref";
    final String P3RefId = "P3-Ref";
    final String P4RefId = "P4-Ref";
    final String O1RefId = "O1-Ref";
    final String O2RefId = "O2-Ref";
    final String F7RefId = "F7-Ref";
    final String F8RefId = "F8-Ref";
    final String T3RefId = "T3-Ref";
    final String T4RefId = "T4-Ref";
    final String T5RefId = "T5-Ref";
    final String T6RefId = "T6-Ref";
    final String A1RefId = "A1-Ref";
    final String A2RefId = "A2-Ref";
    final String FzRefId = "Fz-Ref";
    final String CzRefId = "Cz-Ref";
    final String PzRefId = "Pz-Ref";
    final String OzRefId = "Oz-Ref";
    final String PG1RefId = "PG1-Ref";
    final String PG2RefId = "PG2-Ref";

    final NumericAxis yAxisFp1Ref = generateYAxis(Fp1RefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisFp2Ref = generateYAxis(Fp2RefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisF3Ref = generateYAxis(F3RefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisF4Ref = generateYAxis(F4RefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisC3Ref = generateYAxis(C3RefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisC4Ref = generateYAxis(C4RefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisP3Ref = generateYAxis(P3RefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisP4Ref = generateYAxis(P4RefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisO1Ref = generateYAxis(O1RefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisO2Ref = generateYAxis(O2RefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisF7Ref = generateYAxis(F7RefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisF8Ref = generateYAxis(F8RefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisT3Ref = generateYAxis(T3RefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisT4Ref = generateYAxis(T4RefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisT5Ref = generateYAxis(T5RefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisT6Ref = generateYAxis(T6RefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisA1Ref = generateYAxis(A1RefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisA2Ref = generateYAxis(A2RefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisFzRef = generateYAxis(FzRefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisCzRef = generateYAxis(CzRefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisPzRef = generateYAxis(PzRefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisOzRef = generateYAxis(OzRefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisPG1Ref = generateYAxis(PG1RefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisPG2Ref = generateYAxis(PG2RefId, dataProvider.getBloodOxygenationRange());


    //change the sensitivity

    yAxisFp1Ref.setAutoRange(AutoRange.Never);
    yAxisFp1Ref.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisFp2Ref.setAutoRange(AutoRange.Never);
    yAxisFp2Ref.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisF3Ref.setAutoRange(AutoRange.Never);
    yAxisF3Ref.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisF4Ref.setAutoRange(AutoRange.Never);
    yAxisF4Ref.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisC3Ref.setAutoRange(AutoRange.Never);
    yAxisC3Ref.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisC4Ref.setAutoRange(AutoRange.Never);
    yAxisC4Ref.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisP3Ref.setAutoRange(AutoRange.Never);
    yAxisP3Ref.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisP4Ref.setAutoRange(AutoRange.Never);
    yAxisP4Ref.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisO1Ref.setAutoRange(AutoRange.Never);
    yAxisO1Ref.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisO2Ref.setAutoRange(AutoRange.Never);
    yAxisO2Ref.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisF7Ref.setAutoRange(AutoRange.Never);
    yAxisF7Ref.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisF8Ref.setAutoRange(AutoRange.Never);
    yAxisF8Ref.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisT3Ref.setAutoRange(AutoRange.Never);
    yAxisT3Ref.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisT4Ref.setAutoRange(AutoRange.Never);
    yAxisT4Ref.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisT5Ref.setAutoRange(AutoRange.Never);
    yAxisT5Ref.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisT6Ref.setAutoRange(AutoRange.Never);
    yAxisT6Ref.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisA1Ref.setAutoRange(AutoRange.Never);
    yAxisA1Ref.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisA2Ref.setAutoRange(AutoRange.Never);
    yAxisA2Ref.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisFzRef.setAutoRange(AutoRange.Never);
    yAxisFzRef.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisCzRef.setAutoRange(AutoRange.Never);
    yAxisCzRef.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisPzRef.setAutoRange(AutoRange.Never);
    yAxisPzRef.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisOzRef.setAutoRange(AutoRange.Never);
    yAxisOzRef.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisPG1Ref.setAutoRange(AutoRange.Never);
    yAxisPG1Ref.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisPG2Ref.setAutoRange(AutoRange.Never);
    yAxisPG2Ref.setVisibleRange(dataProvider.getCh1_valueRange());

*/
//

}
private void updateIndicators(long time) {
   //final ExampleVitalSignsBloodOxygenationIndicatorLayoutBinding bloodOxygenationIndicator = binding.bloodOxygenationIndicator;
   // final ExampleVitalSignsBloodPressureIndicatorLayoutBinding bloodPressureIndicator = binding.bloodPressureIndicator;
   // binding.heartRateIndicator.heartIcon.setVisibility(time % 2 == 0 ? View.VISIBLE : View.INVISIBLE);
    final Context context1 = getActivity();
    if(time % 5 == 0) {
        indicatorsProvider.update();

        binding.heartRateIndicator.impedencech0.setText("Fp1-Ref: " + (Double.toString(Math.round(Impedance_ch[0]*100.0)/100.0)));
        if (Impedance_ch[0] <= 5000) {
            binding.heartRateIndicator.impedencech0.setTextColor(Color.DKGRAY);
            int Fp1Ref = ContextCompat.getColor(context1, R.color.DKGREEN);
        }
        if (Impedance_ch[0] <= 10000 & Impedance_ch[0] > 5000) {
            binding.heartRateIndicator.impedencech0.setTextColor(Color.GREEN);
            int Fp1Ref = ContextCompat.getColor(context1, R.color.GREEN);
        }
        if (Impedance_ch[0] > 10000) {
            binding.heartRateIndicator.impedencech0.setTextColor(Color.RED);
            int Fp1Ref = ContextCompat.getColor(context1, R.color.RED);

        }

        binding.heartRateIndicator.impedencech1.setText("Fp2-Ref: " + (Double.toString(Math.round(Impedance_ch[1]*100.0)/100.0)));
        if (Impedance_ch[1] <= 5000) {
            binding.heartRateIndicator.impedencech1.setTextColor(Color.DKGRAY);
            int Fp2Ref = ContextCompat.getColor(context1, R.color.DKGREEN);
        }
        if (Impedance_ch[1] <= 10000 & Impedance_ch[1] > 5000) {
            binding.heartRateIndicator.impedencech1.setTextColor(Color.GREEN);
            int Fp2Ref = ContextCompat.getColor(context1, R.color.GREEN);
        }
        if (Impedance_ch[1] > 10000) {
            binding.heartRateIndicator.impedencech1.setTextColor(Color.RED);
            int Fp2Ref = ContextCompat.getColor(context1, R.color.RED);
        }

        binding.heartRateIndicator.impedencech2.setText("F3-Ref: " + (Double.toString(Math.round(Impedance_ch[2]*100.0)/100.0)));
        if (Impedance_ch[2] <= 5000) {
            binding.heartRateIndicator.impedencech2.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[2] <= 10000 & Impedance_ch[2] > 5000) {
            binding.heartRateIndicator.impedencech2.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[2] > 10000) {
            binding.heartRateIndicator.impedencech2.setTextColor(Color.RED);
        }

        binding.heartRateIndicator.impedencech3.setText("F4-Ref: " + (Double.toString(Math.round(Impedance_ch[3]*100.0)/100.0)));
        if (Impedance_ch[3] <= 5000) {
            binding.heartRateIndicator.impedencech3.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[3] <= 10000 & Impedance_ch[3] > 5000) {
            binding.heartRateIndicator.impedencech3.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[3] > 10000) {
            binding.heartRateIndicator.impedencech3.setTextColor(Color.RED);
        }

        binding.heartRateIndicator.impedencech4.setText("C3-Ref: " + (Double.toString(Math.round(Impedance_ch[4]*100.0)/100.0)));
        if (Impedance_ch[4] <= 5000) {
            binding.heartRateIndicator.impedencech4.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[4] <= 10000 & Impedance_ch[4] > 5000) {
            binding.heartRateIndicator.impedencech4.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[4] > 10000) {
            binding.heartRateIndicator.impedencech4.setTextColor(Color.RED);
        }

        binding.heartRateIndicator.impedencech5.setText("C4-Ref: " + (Double.toString(Math.round(Impedance_ch[5]*100.0)/100.0)));
        if (Impedance_ch[5] <= 5000) {
            binding.heartRateIndicator.impedencech5.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[5] <= 10000 & Impedance_ch[5] > 5000) {
            binding.heartRateIndicator.impedencech5.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[5] > 10000) {
            binding.heartRateIndicator.impedencech5.setTextColor(Color.RED);
        }

        binding.heartRateIndicator.impedencech6.setText("P3-Ref: " + (Double.toString(Math.round(Impedance_ch[6]*100.0)/100.0)));
        if (Impedance_ch[6] <= 5000) {
            binding.heartRateIndicator.impedencech6.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[6] <= 10000 & Impedance_ch[6] > 5000) {
            binding.heartRateIndicator.impedencech6.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[6] > 10000) {
            binding.heartRateIndicator.impedencech6.setTextColor(Color.RED);
        }

        binding.heartRateIndicator.impedencech7.setText("P4-Ref: " + (Double.toString(Math.round(Impedance_ch[7]*100.0)/100.0)));
        if (Impedance_ch[7] <= 5000) {
            binding.heartRateIndicator.impedencech7.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[7] <= 10000 & Impedance_ch[7] > 5000) {
            binding.heartRateIndicator.impedencech7.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[7] > 10000) {
            binding.heartRateIndicator.impedencech7.setTextColor(Color.RED);
        }

        binding.heartRateIndicator.impedencech8.setText("O1-Ref: " + (Double.toString(Math.round(Impedance_ch[8]*100.0)/100.0)));
        if (Impedance_ch[8] <= 5000) {
            binding.heartRateIndicator.impedencech8.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[8] <= 10000 & Impedance_ch[8] > 5000) {
            binding.heartRateIndicator.impedencech8.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[8] > 10000) {
            binding.heartRateIndicator.impedencech8.setTextColor(Color.RED);
        }

        binding.heartRateIndicator.impedencech9.setText("O2-Ref: " + (Double.toString(Math.round(Impedance_ch[9]*100.0)/100.0)));
        if (Impedance_ch[9] <= 5000) {
            binding.heartRateIndicator.impedencech9.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[9] <= 10000 & Impedance_ch[9] > 5000) {
            binding.heartRateIndicator.impedencech9.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[9] > 10000) {
            binding.heartRateIndicator.impedencech9.setTextColor(Color.RED);
        }

        binding.heartRateIndicator.impedencech10.setText("F7-Ref: " + (Double.toString(Math.round(Impedance_ch[10]*100.0)/100.0)));
        if (Impedance_ch[10] <= 5000) {
            binding.heartRateIndicator.impedencech10.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[10] <= 10000 & Impedance_ch[10] > 5000) {
            binding.heartRateIndicator.impedencech10.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[10] > 10000) {
            binding.heartRateIndicator.impedencech10.setTextColor(Color.RED);
        }

        //
        binding.heartRateIndicator.impedencech11.setText("F8-Ref: " + (Double.toString(Math.round(Impedance_ch[11]*100.0)/100.0)));
        if (Impedance_ch[11] <= 5000) {
            binding.heartRateIndicator.impedencech11.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[11] <= 10000 & Impedance_ch[11] > 5000) {
            binding.heartRateIndicator.impedencech11.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[11] > 10000) {
            binding.heartRateIndicator.impedencech11.setTextColor(Color.RED);
        }

        binding.heartRateIndicator.impedencech12.setText("T3-Ref: " + (Double.toString(Math.round(Impedance_ch[12]*100.0)/100.0)));
        if (Impedance_ch[12] <= 5000) {
            binding.heartRateIndicator.impedencech12.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[12] <= 10000 & Impedance_ch[12] > 5000) {
            binding.heartRateIndicator.impedencech12.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[12] > 10000) {
            binding.heartRateIndicator.impedencech12.setTextColor(Color.RED);
        }

        binding.heartRateIndicator.impedencech13.setText("T4-Ref: " + (Double.toString(Math.round(Impedance_ch[13]*100.0)/100.0)));
        if (Impedance_ch[13] <= 5000) {
            binding.heartRateIndicator.impedencech13.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[13] <= 10000 & Impedance_ch[13] > 5000) {
            binding.heartRateIndicator.impedencech13.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[13] > 10000) {
            binding.heartRateIndicator.impedencech13.setTextColor(Color.RED);
        }

        binding.heartRateIndicator.impedencech14.setText("T5-Ref: " + (Double.toString(Math.round(Impedance_ch[14]*100.0)/100.0)));
        if (Impedance_ch[14] <= 5000) {
            binding.heartRateIndicator.impedencech14.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[14] <= 10000 & Impedance_ch[14] > 5000) {
            binding.heartRateIndicator.impedencech14.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[14] > 10000) {
            binding.heartRateIndicator.impedencech14.setTextColor(Color.RED);
        }
        binding.heartRateIndicator.impedencech15.setText("T6-Ref: " + (Double.toString(Math.round(Impedance_ch[15]*100.0)/100.0)));
        if (Impedance_ch[15] <= 5000) {
            binding.heartRateIndicator.impedencech15.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[15] <= 10000 & Impedance_ch[15] > 5000) {
            binding.heartRateIndicator.impedencech15.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[15] > 10000) {
            binding.heartRateIndicator.impedencech15.setTextColor(Color.RED);
        }

        binding.heartRateIndicator.impedencech16.setText("A1-Ref: " + (Double.toString(Math.round(Impedance_ch[16]*100.0)/100.0)));
        if (Impedance_ch[16] <= 5000) {
            binding.heartRateIndicator.impedencech16.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[16] <= 10000 & Impedance_ch[16] > 5000) {
            binding.heartRateIndicator.impedencech16.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[16] > 10000) {
            binding.heartRateIndicator.impedencech16.setTextColor(Color.RED);
        }
        binding.heartRateIndicator.impedencech17.setText("A2-Ref: " + (Double.toString(Math.round(Impedance_ch[17]*100.0)/100.0)));
        if (Impedance_ch[17] <= 5000) {
            binding.heartRateIndicator.impedencech17.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[17] <= 10000 & Impedance_ch[17] > 5000) {
            binding.heartRateIndicator.impedencech17.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[17] > 10000) {
            binding.heartRateIndicator.impedencech17.setTextColor(Color.RED);
        }
        binding.heartRateIndicator.impedencech18.setText("Fz-Ref: " + (Double.toString(Math.round(Impedance_ch[18]*100.0)/100.0)));
        if (Impedance_ch[18] <= 5000) {
            binding.heartRateIndicator.impedencech18.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[18] <= 10000 & Impedance_ch[18] > 5000) {
            binding.heartRateIndicator.impedencech18.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[18] > 10000) {
            binding.heartRateIndicator.impedencech18.setTextColor(Color.RED);
        }

        binding.heartRateIndicator.impedencech19.setText("Cz-Ref: " + (Double.toString(Math.round(Impedance_ch[19]*100.0)/100.0)));
        if (Impedance_ch[19] <= 5000) {
            binding.heartRateIndicator.impedencech19.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[19] <= 10000 & Impedance_ch[19] > 5000) {
            binding.heartRateIndicator.impedencech17.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[19] > 10000) {
            binding.heartRateIndicator.impedencech19.setTextColor(Color.RED);
        }
        binding.heartRateIndicator.impedencech20.setText("Pz-Ref: " + (Double.toString(Math.round(Impedance_ch[20]*100.0)/100.0)));
        if (Impedance_ch[20] <= 5000) {
            binding.heartRateIndicator.impedencech20.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[20] <= 10000 & Impedance_ch[20] > 5000) {
            binding.heartRateIndicator.impedencech20.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[20] > 10000) {
            binding.heartRateIndicator.impedencech20.setTextColor(Color.RED);
        }
        binding.heartRateIndicator.impedencech21.setText("Oz-Ref: " + (Double.toString(Math.round(Impedance_ch[21]*100.0)/100.0)));
        if (Impedance_ch[21] <= 5000) {
            binding.heartRateIndicator.impedencech21.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[21] <= 10000 & Impedance_ch[21] > 5000) {
            binding.heartRateIndicator.impedencech21.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[21] > 10000) {
            binding.heartRateIndicator.impedencech21.setTextColor(Color.RED);
        }
        binding.heartRateIndicator.impedencech22.setText("PG1-Ref: " + (Double.toString(Math.round(Impedance_ch[22]*100.0)/100.0)));
        if (Impedance_ch[22] <= 5000) {
            binding.heartRateIndicator.impedencech22.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[22] <= 10000 & Impedance_ch[22] > 5000) {
            binding.heartRateIndicator.impedencech22.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[22] > 10000) {
            binding.heartRateIndicator.impedencech22.setTextColor(Color.RED);
        }
        binding.heartRateIndicator.impedencech23.setText("PG2-Ref: " + (Double.toString(Math.round(Impedance_ch[23]*100.0)/100.0)));
        if (Impedance_ch[23] <= 5000) {
            binding.heartRateIndicator.impedencech23.setTextColor(Color.DKGRAY);
        }
        if (Impedance_ch[23] <= 10000 & Impedance_ch[23] > 5000) {
            binding.heartRateIndicator.impedencech21.setTextColor(Color.GREEN);
        }
        if (Impedance_ch[23] > 10000) {
            binding.heartRateIndicator.impedencech23.setTextColor(Color.RED);
        }
       // Toast.makeText(getActivity(), "Selected Sensitivity position in update: "+ Sensitivity_pos, Toast.LENGTH_LONG).show();


        // final Context context1 = getActivity();
        final DefaultVitalSignsDataProvider dataProvider = new DefaultVitalSignsDataProvider(getActivity());

      //  Toast.makeText(getActivity(), "Selected Sensitivity rage: "+ dataProvider.getCh1_valueRange(), Toast.LENGTH_LONG).show();

        final String Fp1RefId = "Fp1-Ref";
        final String Fp2RefId = "Fp2-Ref";
        final String F3RefId = "F3-Ref";
        final String F4RefId = "F4-Ref";
        final String C3RefId = "C3-Ref";
        final String C4RefId = "C4-Ref";
        final String P3RefId = "P3-Ref";
        final String P4RefId = "P4-Ref";
        final String O1RefId = "O1-Ref";
        final String O2RefId = "O2-Ref";
        final String F7RefId = "F7-Ref";
        final String F8RefId = "F8-Ref";
        final String T3RefId = "T3-Ref";
        final String T4RefId = "T4-Ref";
        final String T5RefId = "T5-Ref";
        final String T6RefId = "T6-Ref";
        final String A1RefId = "A1-Ref";
        final String A2RefId = "A2-Ref";
        final String FzRefId = "Fz-Ref";
        final String CzRefId = "Cz-Ref";
        final String PzRefId = "Pz-Ref";
        final String OzRefId = "Oz-Ref";
        final String PG1RefId = "PG1-Ref";
        final String PG2RefId = "PG2-Ref";

        final NumericAxis yAxisFp1Ref = generateYAxis(Fp1RefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisFp2Ref = generateYAxis(Fp2RefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisF3Ref = generateYAxis(F3RefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisF4Ref = generateYAxis(F4RefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisC3Ref = generateYAxis(C3RefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisC4Ref = generateYAxis(C4RefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisP3Ref = generateYAxis(P3RefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisP4Ref = generateYAxis(P4RefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisO1Ref = generateYAxis(O1RefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisO2Ref = generateYAxis(O2RefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisF7Ref = generateYAxis(F7RefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisF8Ref = generateYAxis(F8RefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisT3Ref = generateYAxis(T3RefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisT4Ref = generateYAxis(T4RefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisT5Ref = generateYAxis(T5RefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisT6Ref = generateYAxis(T6RefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisA1Ref = generateYAxis(A1RefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisA2Ref = generateYAxis(A2RefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisFzRef = generateYAxis(FzRefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisCzRef = generateYAxis(CzRefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisPzRef = generateYAxis(PzRefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisOzRef = generateYAxis(OzRefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisPG1Ref = generateYAxis(PG1RefId, dataProvider.getCh1_valueRange());
        final NumericAxis yAxisPG2Ref = generateYAxis(PG2RefId, dataProvider.getBloodOxygenationRange());


        //change the sensitivity

        yAxisFp1Ref.setAutoRange(AutoRange.Never);
        yAxisFp1Ref.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisFp2Ref.setAutoRange(AutoRange.Never);
        yAxisFp2Ref.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisF3Ref.setAutoRange(AutoRange.Never);
        yAxisF3Ref.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisF4Ref.setAutoRange(AutoRange.Never);
        yAxisF4Ref.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisC3Ref.setAutoRange(AutoRange.Never);
        yAxisC3Ref.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisC4Ref.setAutoRange(AutoRange.Never);
        yAxisC4Ref.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisP3Ref.setAutoRange(AutoRange.Never);
        yAxisP3Ref.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisP4Ref.setAutoRange(AutoRange.Never);
        yAxisP4Ref.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisO1Ref.setAutoRange(AutoRange.Never);
        yAxisO1Ref.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisO2Ref.setAutoRange(AutoRange.Never);
        yAxisO2Ref.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisF7Ref.setAutoRange(AutoRange.Never);
        yAxisF7Ref.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisF8Ref.setAutoRange(AutoRange.Never);
        yAxisF8Ref.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisT3Ref.setAutoRange(AutoRange.Never);
        yAxisT3Ref.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisT4Ref.setAutoRange(AutoRange.Never);
        yAxisT4Ref.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisT5Ref.setAutoRange(AutoRange.Never);
        yAxisT5Ref.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisT6Ref.setAutoRange(AutoRange.Never);
        yAxisT6Ref.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisA1Ref.setAutoRange(AutoRange.Never);
        yAxisA1Ref.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisA2Ref.setAutoRange(AutoRange.Never);
        yAxisA2Ref.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisFzRef.setAutoRange(AutoRange.Never);
        yAxisFzRef.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisCzRef.setAutoRange(AutoRange.Never);
        yAxisCzRef.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisPzRef.setAutoRange(AutoRange.Never);
        yAxisPzRef.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisOzRef.setAutoRange(AutoRange.Never);
        yAxisOzRef.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisPG1Ref.setAutoRange(AutoRange.Never);
        yAxisPG1Ref.setVisibleRange(dataProvider.getCh1_valueRange());

        yAxisPG2Ref.setAutoRange(AutoRange.Never);
        yAxisPG2Ref.setVisibleRange(dataProvider.getCh1_valueRange());




       /* binding.bloodPressureIndicator.bloodPressureValue.setText(indicatorsProvider.getBpValue());
        binding.bloodPressureIndicator.bloodPressureBar.setProgress(indicatorsProvider.getBpbValue());

        binding.bloodVolumeIndicator.bloodVolumeValueLabel.setText(indicatorsProvider.getBvValue());
        binding.bloodVolumeIndicator.svBar1.setProgress(indicatorsProvider.getBvBar1Value());
        binding.bloodVolumeIndicator.svBar2.setProgress(indicatorsProvider.getBvBar2Value());

        binding.bloodOxygenationIndicator.spoValueLabel.setText(indicatorsProvider.getSpoValue());
        binding.bloodOxygenationIndicator.spoClockLabel.setText(indicatorsProvider.getSpoClockValue());*/
    }
}

private void setUpChart(DefaultVitalSignsDataProvider dataProvider) {
    final NumericAxis xAxis = sciChartBuilder.newNumericAxis()
            .withVisibleRange(0, 10)
            .withAutoRangeMode(AutoRange.Never)
            .withDrawMinorGridLines(false)
            .withDrawMajorBands(false)
            .withVisibility(View.GONE)
            .build();

    final String Fp1RefId = "Fp1-Ref";
    final String Fp2RefId = "Fp2-Ref";
    final String F3RefId = "F3-Ref";
    final String F4RefId = "F4-Ref";
    final String C3RefId = "C3-Ref";
    final String C4RefId = "C4-Ref";
    final String P3RefId = "P3-Ref";
    final String P4RefId = "P4-Ref";
    final String O1RefId = "O1-Ref";
    final String O2RefId = "O2-Ref";
    final String F7RefId = "F7-Ref";
    final String F8RefId = "F8-Ref";
    final String T3RefId = "T3-Ref";
    final String T4RefId = "T4-Ref";
    final String T5RefId = "T5-Ref";
    final String T6RefId = "T6-Ref";
    final String A1RefId = "A1-Ref";
    final String A2RefId = "A2-Ref";
    final String FzRefId = "Fz-Ref";
    final String CzRefId = "Cz-Ref";
    final String PzRefId = "Pz-Ref";
    final String OzRefId = "Oz-Ref";
    final String PG1RefId = "PG1-Ref";
    final String PG2RefId = "PG2-Ref";

/* final NumericAxis yAxisEcg = generateYAxis(ecgId, dataProvider.getEcgHeartRateRange());
final NumericAxis yAxisPressure = generateYAxis(bloodPressureId, dataProvider.getBloodPressureRange());
final NumericAxis yAxisVolume = generateYAxis(bloodVolumeId, dataProvider.getBloodVolumeRange());
final NumericAxis yAxisOxygenation = generateYAxis(bloodOxygenationId, dataProvider.getBloodOxygenationRange());

 */

    final NumericAxis yAxisFp1Ref = generateYAxis(Fp1RefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisFp2Ref = generateYAxis(Fp2RefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisF3Ref = generateYAxis(F3RefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisF4Ref = generateYAxis(F4RefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisC3Ref = generateYAxis(C3RefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisC4Ref = generateYAxis(C4RefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisP3Ref = generateYAxis(P3RefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisP4Ref = generateYAxis(P4RefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisO1Ref = generateYAxis(O1RefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisO2Ref = generateYAxis(O2RefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisF7Ref = generateYAxis(F7RefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisF8Ref = generateYAxis(F8RefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisT3Ref = generateYAxis(T3RefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisT4Ref = generateYAxis(T4RefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisT5Ref = generateYAxis(T5RefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisT6Ref = generateYAxis(T6RefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisA1Ref = generateYAxis(A1RefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisA2Ref = generateYAxis(A2RefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisFzRef = generateYAxis(FzRefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisCzRef = generateYAxis(CzRefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisPzRef = generateYAxis(PzRefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisOzRef = generateYAxis(OzRefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisPG1Ref = generateYAxis(PG1RefId, dataProvider.getCh1_valueRange());
    final NumericAxis yAxisPG2Ref = generateYAxis(PG2RefId, dataProvider.getBloodOxygenationRange());
    FontStyle titleStyle = new FontStyle(14, ColorUtil.Blue);

    yAxisFp1Ref.setTitleStyle(titleStyle);
    yAxisFp1Ref.setAxisTitle("Fp1RefId");
    yAxisFp2Ref.setAxisTitle("Fp2RefId");
    yAxisF3Ref.setAxisTitle("F3RefId");

    yAxisFp1Ref.setAutoRange(AutoRange.Never);
    yAxisFp1Ref.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisFp2Ref.setAutoRange(AutoRange.Never);
    yAxisFp2Ref.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisF3Ref.setAutoRange(AutoRange.Never);
    yAxisF3Ref.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisF4Ref.setAutoRange(AutoRange.Never);
    yAxisF4Ref.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisC3Ref.setAutoRange(AutoRange.Never);
    yAxisC3Ref.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisC4Ref.setAutoRange(AutoRange.Never);
    yAxisC4Ref.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisP3Ref.setAutoRange(AutoRange.Never);
    yAxisP3Ref.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisP4Ref.setAutoRange(AutoRange.Never);
    yAxisP4Ref.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisO1Ref.setAutoRange(AutoRange.Never);
    yAxisO1Ref.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisO2Ref.setAutoRange(AutoRange.Never);
    yAxisO2Ref.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisF7Ref.setAutoRange(AutoRange.Never);
    yAxisF7Ref.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisF8Ref.setAutoRange(AutoRange.Never);
    yAxisF8Ref.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisT3Ref.setAutoRange(AutoRange.Never);
    yAxisT3Ref.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisT4Ref.setAutoRange(AutoRange.Never);
    yAxisT4Ref.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisT5Ref.setAutoRange(AutoRange.Never);
    yAxisT5Ref.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisT6Ref.setAutoRange(AutoRange.Never);
    yAxisT6Ref.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisA1Ref.setAutoRange(AutoRange.Never);
    yAxisA1Ref.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisA2Ref.setAutoRange(AutoRange.Never);
    yAxisA2Ref.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisFzRef.setAutoRange(AutoRange.Never);
    yAxisFzRef.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisCzRef.setAutoRange(AutoRange.Never);
    yAxisCzRef.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisPzRef.setAutoRange(AutoRange.Never);
    yAxisPzRef.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisOzRef.setAutoRange(AutoRange.Never);
    yAxisOzRef.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisPG1Ref.setAutoRange(AutoRange.Never);
    yAxisPG1Ref.setVisibleRange(dataProvider.getCh1_valueRange());

    yAxisPG2Ref.setAutoRange(AutoRange.Never);
    yAxisPG2Ref.setVisibleRange(dataProvider.getCh1_valueRange());


  /*  final NumericAxis xAxis1 = sciChartBuilder.newNumericAxis()
            .withAutoRangeMode(AutoRange.Never)
            .withDrawMinorGridLines(false)
            .withDrawMajorBands(false)
           // .withVisibility(View.GONE)
            .build();
    xAxis1.setAxisTitle("Fp1Ref");

    final NumericAxis xAxis2= sciChartBuilder.newNumericAxis()
            .withAutoRangeMode(AutoRange.Never)
            .withDrawMinorGridLines(false)
            .withDrawMajorBands(false)
            // .withVisibility(View.GONE)
            .build();
    xAxis2.setAxisTitle("Fp2Ref");*/

        TextAnnotation textAnnotation = sciChartBuilder.newTextAnnotation()
                .withText("Fp1Ref")
                .withPosition(7.5d, 5d)
                .withFontStyle(12, ColorUtil.Cyan)
                .withVerticalAnchorPoint(VerticalAnchorPoint.Bottom)
                .withXAxisId("Top_X_Axis")
                .withYAxisId("Left_Y_Axis")
                .withIsEditable(true)
                .build();

    final Context context = getActivity();

  /*  // create a TextAnnotation
    TextAnnotation textAnnotation = new TextAnnotation(getActivity());

// specify a FontStyle for the text
textAnnotation.setFontStyle(new FontStyle(15f, 0x66FC9C29));

// set the text
textAnnotation.setText(“My Text Annotation”);

// allow to interact with the annotation in run-time
// textAnnotation.setEditable(true);
textAnnotation.setEnabled(true);

// in a multi-axis scenario, specify the XAxisId and YAxisId
// textAnnotation.setXAxisId(“Top_X_Axis”);
// textAnnotation.setYAxisId(“Left_Y_Axis”);

// specify anchor points
textAnnotation.setHorizontalAnchorPoint(HorizontalAnchorPoint.Center);
textAnnotation.setVerticalAnchorPoint(VerticalAnchorPoint.Center);

// specify a desired position by setting coordinates
textAnnotation.setX1(4.2d);
textAnnotation.setY1(2d);*/

// add the annotation to the Annotations collection of the surface

   /* final int heartRateColor = ContextCompat.getColor(context, R.color.heart_rate_color);
    final int bloodPressureColor = ContextCompat.getColor(context, R.color.blood_pressure_color);
    final int bloodVolumeColor = ContextCompat.getColor(context, R.color.blood_volume_color); */
    final int bloodOxygenation = ContextCompat.getColor(context, R.color.blood_oxygenation_color);

    final int Fp1Ref = ContextCompat.getColor(context, R.color.blood_oxygenation_color);
    final int Fp2Ref = ContextCompat.getColor(context, R.color.blood_pressure_color);
    final int F3Ref = ContextCompat.getColor(context, R.color.blood_pressure_color);
    final int F4Ref = ContextCompat.getColor(context, R.color.blood_pressure_color);
    final int C3Ref = ContextCompat.getColor(context, R.color.blood_pressure_color);
    final int C4Ref = ContextCompat.getColor(context, R.color.blood_pressure_color);
    final int P3Ref = ContextCompat.getColor(context, R.color.blood_pressure_color);
    final int P4Ref = ContextCompat.getColor(context, R.color.blood_pressure_color);
    final int O1Ref = ContextCompat.getColor(context, R.color.blood_pressure_color);
    final int O2Ref = ContextCompat.getColor(context, R.color.blood_pressure_color);
    final int F7Ref = ContextCompat.getColor(context, R.color.blood_pressure_color);
    final int F8Ref = ContextCompat.getColor(context, R.color.blood_pressure_color);
    final int T3Ref = ContextCompat.getColor(context, R.color.blood_pressure_color);
    final int T4Ref = ContextCompat.getColor(context, R.color.blood_pressure_color);
    final int T5Ref = ContextCompat.getColor(context, R.color.blood_pressure_color);
    final int T6Ref = ContextCompat.getColor(context, R.color.blood_pressure_color);
    final int A1Ref = ContextCompat.getColor(context, R.color.blood_pressure_color);
    final int A2Ref = ContextCompat.getColor(context, R.color.blood_pressure_color);
    final int FzRef = ContextCompat.getColor(context, R.color.blood_pressure_color);
    final int CzRef = ContextCompat.getColor(context, R.color.blood_pressure_color);
    final int PzRef = ContextCompat.getColor(context, R.color.blood_pressure_color);
    final int OzRef = ContextCompat.getColor(context, R.color.blood_pressure_color);
    final int PG1Ref = ContextCompat.getColor(context, R.color.blood_pressure_color);
    final int PG2Ref = ContextCompat.getColor(context, R.color.blood_pressure_color);

    final SciChartSurface surface = binding.surface;
    surface.setRenderSurface(new RenderSurface(getActivity()));
    UpdateSuspender.using(surface, () -> {
        surface.setTheme(R.style.SciChart_BerryBlue);

        Collections.addAll(surface.getXAxes(), xAxis);
       // Collections.addAll(surface.getAnnotations(), textAnnotation);
        Collections.addAll(surface.getYAxes(), /*yAxisEcg, yAxisPressure, yAxisVolume, yAxisOxygenation,*/ yAxisFp1Ref,yAxisFp2Ref,yAxisF3Ref,yAxisF4Ref,yAxisC3Ref,yAxisC4Ref,yAxisP3Ref,yAxisP4Ref,yAxisO1Ref,yAxisO2Ref,yAxisF7Ref,yAxisF8Ref,yAxisT3Ref,yAxisT4Ref,yAxisT5Ref,yAxisT6Ref,yAxisA1Ref,yAxisA2Ref,yAxisFzRef,yAxisCzRef,yAxisPzRef,yAxisOzRef,yAxisPG1Ref,yAxisPG2Ref );

        Collections.addAll(surface.getRenderableSeries(),

                generateLineSeries(Fp1RefId, CH1DataSeries, sciChartBuilder.newPen().withColor(bloodOxygenation).withThickness(1f)
                        .build()),
                generateLineSeries(Fp1RefId, CH1SweepDataSeries, sciChartBuilder.newPen().withColor(bloodOxygenation).withThickness(1f).build()),
                generateScatterForLastAppendedPoint(Fp1RefId, lastCh1DataSeries),

                generateLineSeries(Fp2RefId, CH2DataSeries, sciChartBuilder.newPen().withColor(bloodOxygenation).withThickness(1f).build()),
                generateLineSeries(Fp2RefId, CH2SweepDataSeries, sciChartBuilder.newPen().withColor(bloodOxygenation).withThickness(1f).build()),
                generateScatterForLastAppendedPoint(Fp2RefId, lastCh2DataSeries),

                generateLineSeries(F3RefId, CH3DataSeries, sciChartBuilder.newPen().withColor(bloodOxygenation).withThickness(1f).build()),
                generateLineSeries(F3RefId, CH3SweepDataSeries, sciChartBuilder.newPen().withColor(bloodOxygenation).withThickness(1f).build()),
                generateScatterForLastAppendedPoint(F3RefId, lastCh3DataSeries),

                generateLineSeries(F4RefId, CH4DataSeries, sciChartBuilder.newPen().withColor(bloodOxygenation).withThickness(1f).build()),
                generateLineSeries(F4RefId, CH4SweepDataSeries, sciChartBuilder.newPen().withColor(bloodOxygenation).withThickness(1f).build()),
                generateScatterForLastAppendedPoint(F4RefId, lastCh4DataSeries),


                generateLineSeries(C3RefId, CH5DataSeries, sciChartBuilder.newPen().withColor(bloodOxygenation).withThickness(1f).build()),
                generateLineSeries(C3RefId, CH5SweepDataSeries, sciChartBuilder.newPen().withColor(bloodOxygenation).withThickness(1f).build()),
                generateScatterForLastAppendedPoint(C3RefId, lastCh5DataSeries),

                generateLineSeries(C4RefId, CH6DataSeries, sciChartBuilder.newPen().withColor(bloodOxygenation).withThickness(1f).build()),
                generateLineSeries(C4RefId, CH6SweepDataSeries, sciChartBuilder.newPen().withColor(bloodOxygenation).withThickness(1f).build()),
                generateScatterForLastAppendedPoint(C4RefId, lastCh6DataSeries),

                generateLineSeries(P3RefId, CH7DataSeries, sciChartBuilder.newPen().withColor(bloodOxygenation).withThickness(1f).build()),
                generateLineSeries(P3RefId, CH7SweepDataSeries, sciChartBuilder.newPen().withColor(bloodOxygenation).withThickness(1f).build()),
                generateScatterForLastAppendedPoint(P3RefId, lastCh7DataSeries),

                generateLineSeries(P4RefId, CH8DataSeries, sciChartBuilder.newPen().withColor(bloodOxygenation).withThickness(1f).build()),
                generateLineSeries(P4RefId, CH8SweepDataSeries, sciChartBuilder.newPen().withColor(bloodOxygenation).withThickness(1f).build()),
                generateScatterForLastAppendedPoint(P4RefId, lastCh8DataSeries),

                generateLineSeries(O1RefId, CH9DataSeries, sciCh
  • Yura Khariton
    It looks like code wasn’t fully copy pasted, so I couldn’t run it, but it seems that I was correct and you need to define private fields for storing your yAxes, because in other methods they are recreated and you’re setting VisibleRange on new instances and axes attached to chart remain unchanged.
  • You must to post comments
0
0

Hi Yura,

Does this code makes sense ? I have sent you the full code. Please let me know how can we do it.
I am trying to make it with AxisCollection yax= binding.surface.getYAxes(); By getting all the Y axises and then setting the visible ranges.

Please let me know if it works.

Regards,
Aditya

  • You must to post comments
0
0

Hi Yura,

I solved it with the below code. I used AxisCollection class and for each axis i set the visible range for every 5 sec. this solves the problem

 AxisCollection yax= binding.surface.getYAxes();
        yax.get(0).setAutoRange(AutoRange.Never);
        yax.get(0).setVisibleRange(dataProvider.getCh1_valueRange());

Regards,
Aditya

  • You must to post comments
Showing 7 results
Your Answer

Please first to submit.