问:
CSS dropdown menu disappears when using bootstrap carousel
I have a dropdown nav menu (using css from w3schools) that works fine until a carousel is put immediately after. Then the dropdown no longer shows and I do not know why.
I am new to css html .., so I don't find the solution to my problem. I have changed the Z-index and position on multiple classes and it doesn't solve the issue. Whenever i delete the bootstrap css link then the dropdown menu works again.
Do you have any suggestions?
thanks!

ps: i put all the code, sorry if i added more than the required, its my first time posting

/* CSS Document */

* {
  box-sizing: border-box;
  font-family: Arial, Helvetica, sans-serif;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
}

.background-image {
  background-image: linear-gradient(rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0)), url("../img/header.jpg");
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  position: relative;
  width: 100%;
}

.header-text {
  text-align: center;
  color: white;
  padding: 30px;
}

/* Add a black background color to the top navigation */

.topnav {
  background-color: #333;
  overflow: hidden;
}

/* Style the links inside the navigation bar */

.topnav a {
  float: left;
  display: block;
  color: #f2f2f2;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
  font-size: 17px;
}

/* Change the color of links on hover */

.topnav a:hover {
  background-color: #1C8CE8;
  text-decoration: none;
  color: black;
}

/* Add an active class to highlight the current page */

.activenav {
  background-color: #4F47E1;
  color: white;
}

/* Hide the link that should open and close the topnav on small screens */

.topnav .icon {
  display: none;
}

/* Dropdown container - needed to position the dropdown content */

.dropdown {
  float: left;
  overflow: hidden;
}

/* Style the dropdown button to fit inside the topnav */

.dropdown .dropbtn {
  font-size: 17px;
  border: none;
  outline: none;
  color: white;
  padding: 14px 16px;
  background-color: inherit;
  font-family: inherit;
  margin: 0;
}

/* Style the dropdown content (hidden by default) */

.dropdown-content {
  display: none;
  position: absolute;
  background-color: #f9f9f9;
  min-width: 160px;
  box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
}

/* Style the links inside the dropdown */

.dropdown-content a {
  float: none;
  color: black;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
  text-align: left;
}

/* Add a dark background on topnav links and the dropdown button on hover */

.topnav a:hover,
.dropdown:hover .dropbtn {
  background-color: #555;
  color: white;
}

/* Add a grey background to dropdown links on hover */

.dropdown-content a:hover {
  background-color: #ddd;
  color: black;
}

/* Show the dropdown menu when the user moves the mouse over the dropdown button */

.dropdown:hover .dropdown-content {
  display: block;
}

.carousel {
  max-width: 100% !important;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.carousel-inner>.item>img {
  height: 600px!important;
  width: 100%;
}

/* When the screen is less than 600 pixels wide, hide all links, except for the first one ("Home"). Show the link that contains should open and close the topnav (.icon) */

@media screen and (max-width: 600px) {
  .topnav a:not(:first-child),
  .dropdown .dropbtn {
    display: none;
  }
  .topnav a.icon {
    float: right;
    display: block;
  }
}

/* The "responsive" class is added to the topnav with JavaScript when the user clicks on the icon. This class makes the topnav look good on small screens (display the links vertically instead of horizontally) */

@media screen and (max-width: 600px) {
  .topnav.responsive {
    position: relative;
  }
  .topnav.responsive a.icon {
    position: absolute;
    right: 0;
    top: 0;
  }
  .topnav.responsive a {
    float: none;
    display: block;
    text-align: left;
  }
  .topnav.responsive .dropdown {
    float: none;
  }
  .topnav.responsive .dropdown-content {
    position: relative;
  }
  .topnav.responsive .dropdown .dropbtn {
    display: block;
    width: 100%;
    text-align: left;
  }
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>

  <nav class="topnav" id="myTopnav">
    Home
    <div class="dropdown">
      <button class="dropbtn">Products
            <i class="fa fa-caret-down"></i>
        </button>
      <div class="dropdown-content">
        Make
        Model
        Year
      </div>
    </div>
    News
    About
    Contact us
    <i class="fa fa-bars"></i>
  </nav>
  <section id="myCarousel" class="carousel slide" data-ride="carousel">
    <!-- Indicators -->
    <ol class="carousel-indicators">
      <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
      <li data-target="#myCarousel" data-slide-to="1"></li>
      <li data-target="#myCarousel" data-slide-to="2"></li>
    </ol>

    <!-- Wrapper for slides -->
    <div class="carousel-inner">
      <div class="item active">
        <img src="img/img1slideshow.jpg" alt="Chania">
        <div class="carousel-caption">
          <h3>title</h3>
          <p>paragraph</p>
        </div>
      </div>

      <div class="item">
        <img src="img/img2slideshow.jpg" alt="Chania">
        <div class="carousel-caption">
          <h3>title</h3>
          <p>paragraph</p>
        </div>
      </div>

      <div class="item">
        <img src="img/img3slideshow.jpg" alt="Chania">
        <div class="carousel-caption">
          <h3>title</h3>
          <p>paragraph</p>
        </div>
      </div>

    </div></code>```

答: Could it be a solution adding z-index on the carousel or dropdown?</p>

Body:
I have a dropdown nav menu (using css from w3schools) that works fine until a carousel is put immediately after. Then the dropdown no longer shows and I do not know why.
I am new to css html .., so I don't find the solution to my problem. I have changed the Z-index and position on multiple classes and it doesn't solve the issue. Whenever i delete the bootstrap css link then the dropdown menu works again.
Do you have any suggestions?
thanks!

ps: i put all the code, sorry if i added more than the required, its my first time posting

/* CSS Document */

* {
  box-sizing: border-box;
  font-family: Arial, Helvetica, sans-serif;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
}

.background-image {
  background-image: linear-gradient(rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0)), url("../img/header.jpg");
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  position: relative;
  width: 100%;
}

.header-text {
  text-align: center;
  color: white;
  padding: 30px;
}

/* Add a black background color to the top navigation */

.topnav {
  background-color: #333;
  overflow: hidden;
}

/* Style the links inside the navigation bar */

.topnav a {
  float: left;
  display: block;
  color: #f2f2f2;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
  font-size: 17px;
}

/* Change the color of links on hover */

.topnav a:hover {
  background-color: #1C8CE8;
  text-decoration: none;
  color: black;
}

/* Add an active class to highlight the current page */

.activenav {
  background-color: #4F47E1;
  color: white;
}

/* Hide the link that should open and close the topnav on small screens */

.topnav .icon {
  display: none;
}

/* Dropdown container - needed to position the dropdown content */

.dropdown {
  float: left;
  overflow: hidden;
}

/* Style the dropdown button to fit inside the topnav */

.dropdown .dropbtn {
  font-size: 17px;
  border: none;
  outline: none;
  color: white;
  padding: 14px 16px;
  background-color: inherit;
  font-family: inherit;
  margin: 0;
}

/* Style the dropdown content (hidden by default) */

.dropdown-content {
  display: none;
  position: absolute;
  background-color: #f9f9f9;
  min-width: 160px;
  box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
}

/* Style the links inside the dropdown */

.dropdown-content a {
  float: none;
  color: black;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
  text-align: left;
}

/* Add a dark background on topnav links and the dropdown button on hover */

.topnav a:hover,
.dropdown:hover .dropbtn {
  background-color: #555;
  color: white;
}

/* Add a grey background to dropdown links on hover */

.dropdown-content a:hover {
  background-color: #ddd;
  color: black;
}

/* Show the dropdown menu when the user moves the mouse over the dropdown button */

.dropdown:hover .dropdown-content {
  display: block;
}

.carousel {
  max-width: 100% !important;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.carousel-inner>.item>img {
  height: 600px!important;
  width: 100%;
}

/* When the screen is less than 600 pixels wide, hide all links, except for the first one ("Home"). Show the link that contains should open and close the topnav (.icon) */

@media screen and (max-width: 600px) {
  .topnav a:not(:first-child),
  .dropdown .dropbtn {
    display: none;
  }
  .topnav a.icon {
    float: right;
    display: block;
  }
}

/* The "responsive" class is added to the topnav with JavaScript when the user clicks on the icon. This class makes the topnav look good on small screens (display the links vertically instead of horizontally) */

@media screen and (max-width: 600px) {
  .topnav.responsive {
    position: relative;
  }
  .topnav.responsive a.icon {
    position: absolute;
    right: 0;
    top: 0;
  }
  .topnav.responsive a {
    float: none;
    display: block;
    text-align: left;
  }
  .topnav.responsive .dropdown {
    float: none;
  }
  .topnav.responsive .dropdown-content {
    position: relative;
  }
  .topnav.responsive .dropdown .dropbtn {
    display: block;
    width: 100%;
    text-align: left;
  }
}

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">

    Home

      <button class="dropbtn">Products

        </button>

        Make
        Model
        Year

    News
    About
    Contact us

title

paragraph

title

paragraph

title

paragraph


来源: stackexchange

问:
Is there a way to write selinium automation code more elegantly?
framework: selinium chrom driver ; mostly use xpaths to automate UI

My code currently looks like this:

```<code>public void Delete_calendar()
        {
            Logger.Info("Deleting calendar with name provided");
            _login.SelectOLC(ws);
            ws.WaitForCheckPoint("Scheduling");
            ws.ClickByXPath("//nav/a/span");
            ws.waitforStatus("//ia-action-menu-item");
            ws.ClickByXPath("(//input[@type='text'])[5]");
            ws.ClickByXPath("//text()[contains(.,'Default')]/ancestor::li[1]");
            ws.waitforStatus("//button[text()='Assign']");
            Thread.Sleep(10000);
            ws.ClickByXPath("//nav/a/span");
            ws.ClickByXPath("//ia-action-menu-item");
            ws.ClickByXPath("(//a[contains(text(),'Calendars')])[2]");
            ws.ClickByXPath("//input[@type='text']");
            ws.waitforStatus("//span[text()='Sys_demo']");
            ws.ClickByXPath("(//button[@type='button'])[2]");
            ws.ClickByXPath("//ia-action-menu-item[contains(text(),'Delete')]");
            // ws.ClickByXPath("(//button[@type='button'])[30]");
            ws.ClickByXPath("/html/body/ia-dialog/ia-dialog-footer/ia-button[2]/button");
            Thread.Sleep(10000);
</code>```

...
All the ws.Clickby are the selinium call method, is there a way i can put all this xpaths or the code in a external file and just call that file and it executes the same way it does above.
basicallly i want my code to look elegant and less buckly and easy to read.

Any suggestion is welcome.

my idea i had in mind is

external file  'test.txt'

```<code>public void Delete_calendar()
        {
            Logger.Info("Deleting calendar with name provided");
            _login.SelectOLC(ws);
            RunSeliniumcodefromExternalfile("test.txt")

        }

        test.txt file contains
        [
        ws.WaitForCheckPoint("Scheduling");
            ws.ClickByXPath("//nav/a/span");
            ws.waitforStatus("//ia-action-menu-item");
            ws.ClickByXPath("(//input[@type='text'])[5]");
            ws.ClickByXPath("//text()[contains(.,'Default')]/ancestor::li[1]");
            ws.waitforStatus("//button[text()='Assign']");
            Thread.Sleep(10000);
            ws.ClickByXPath("//nav/a/span");
            ws.ClickByXPath("//ia-action-menu-item");
            ws.ClickByXPath("(//a[contains(text(),'Calendars')])[2]");
            ws.ClickByXPath("//input[@type='text']");
            ws.waitforStatus("//span[text()='Sys_demo']");
            ws.ClickByXPath("(//button[@type='button'])[2]");
            ws.ClickByXPath("//ia-action-menu-item[contains(text(),'Delete')]");
            // ws.ClickByXPath("(//button[@type='button'])[30]");
            ws.ClickByXPath("/html/body/ia-dialog/ia-dialog-footer/ia-button[2]/button");
            Thread.Sleep(10000);
        ]
</code>```

答:
You can incorporate the Page Object Model pattern. POM allows you to defined IWebElements and mark them with their locator at class level. Using this technique, actions on the webelements are carried out without specifying the locator for each action.

Below is an example of how you can achieve this with your provided code for the Delete_Calendar method.

```<code>using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Support.UI;
using OpenQA.Selenium.Support.PageObjects;

namespace POMExample.PageObjects
{
    public class POMExample
    {
        private IWebDriver driver;
        private WebDriverWait wait;

        public POMExample(IWebDriver driver)
        {
            this.driver = driver;
            wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));

            //This line instantiates the Iwebelements marked with the FindsBy attribute.
            PageFactory.InitElements(driver, this);
        }

        //The FindsBy attribute allows you to tag an IWebelement with a locator.
        [FindsBy(How = How.XPath, Using = "//nav/a/span")]
        private IWebElement elem_1;

        [FindsBy(How = How.XPath, Using = "(//input[@type='text'])[5]")]
        private IWebElement elem_2;

        public void Delete_calendar()
        {
            //Instead of: ws.ClickByXPath("//nav/a/span");
            elem_1.Click();

            //Instead of: ws.ClickByXPath("(//input[@type='text'])[5]");
            elem_2.Click();

            //and so on...
        }
    }
}
</code>```

If you are still keen on using external sources for storing your locators I would further add that generally using property files to store locators is popular but not necessarily best practice, please refer to https://seleniumjava.com/2017/03/19/do-not-store-element-locators-in-property-files/ for further information.

ContentLicense: CC BY-SA 4.0

Body:
framework: selinium chrom driver ; mostly use xpaths to automate UI

My code currently looks like this:

public void Delete_calendar()
        {
            Logger.Info("Deleting calendar with name provided");
            _login.SelectOLC(ws);
            ws.WaitForCheckPoint("Scheduling");
            ws.ClickByXPath("//nav/a/span");
            ws.waitforStatus("//ia-action-menu-item");
            ws.ClickByXPath("(//input[@type='text'])[5]");
            ws.ClickByXPath("//text()[contains(.,'Default')]/ancestor::li[1]");
            ws.waitforStatus("//button[text()='Assign']");
            Thread.Sleep(10000);
            ws.ClickByXPath("//nav/a/span");
            ws.ClickByXPath("//ia-action-menu-item");
            ws.ClickByXPath("(//a[contains(text(),'Calendars')])[2]");
            ws.ClickByXPath("//input[@type='text']");
            ws.waitforStatus("//span[text()='Sys_demo']");
            ws.ClickByXPath("(//button[@type='button'])[2]");
            ws.ClickByXPath("//ia-action-menu-item[contains(text(),'Delete')]");
            // ws.ClickByXPath("(//button[@type='button'])[30]");
            ws.ClickByXPath("/html/body/ia-dialog/ia-dialog-footer/ia-button[2]/button");
            Thread.Sleep(10000);

...
All the ws.Clickby are the selinium call method, is there a way i can put all this xpaths or the code in a external file and just call that file and it executes the same way it does above.
basicallly i want my code to look elegant and less buckly and easy to read.

Any suggestion is welcome.

my idea i had in mind is

external file  'test.txt'

public void Delete_calendar()
        {
            Logger.Info("Deleting calendar with name provided");
            _login.SelectOLC(ws);
            RunSeliniumcodefromExternalfile("test.txt")

        }

        test.txt file contains
        [
        ws.WaitForCheckPoint("Scheduling");
            ws.ClickByXPath("//nav/a/span");
            ws.waitforStatus("//ia-action-menu-item");
            ws.ClickByXPath("(//input[@type='text'])[5]");
            ws.ClickByXPath("//text()[contains(.,'Default')]/ancestor::li[1]");
            ws.waitforStatus("//button[text()='Assign']");
            Thread.Sleep(10000);
            ws.ClickByXPath("//nav/a/span");
            ws.ClickByXPath("//ia-action-menu-item");
            ws.ClickByXPath("(//a[contains(text(),'Calendars')])[2]");
            ws.ClickByXPath("//input[@type='text']");
            ws.waitforStatus("//span[text()='Sys_demo']");
            ws.ClickByXPath("(//button[@type='button'])[2]");
            ws.ClickByXPath("//ia-action-menu-item[contains(text(),'Delete')]");
            // ws.ClickByXPath("(//button[@type='button'])[30]");
            ws.ClickByXPath("/html/body/ia-dialog/ia-dialog-footer/ia-button[2]/button");
            Thread.Sleep(10000);
        ]

Body:
You can incorporate the Page Object Model pattern. POM allows you to defined IWebElements and mark them with their locator at class level. Using this technique, actions on the webelements are carried out without specifying the locator for each action.

Below is an example of how you can achieve this with your provided code for the Delete_Calendar method.

using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Support.UI;
using OpenQA.Selenium.Support.PageObjects;

namespace POMExample.PageObjects
{
    public class POMExample
    {
        private IWebDriver driver;
        private WebDriverWait wait;

        public POMExample(IWebDriver driver)
        {
            this.driver = driver;
            wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));

            //This line instantiates the Iwebelements marked with the FindsBy attribute.
            PageFactory.InitElements(driver, this);
        }

        //The FindsBy attribute allows you to tag an IWebelement with a locator.
        [FindsBy(How = How.XPath, Using = "//nav/a/span")]
        private IWebElement elem_1;

        [FindsBy(How = How.XPath, Using = "(//input[@type='text'])[5]")]
        private IWebElement elem_2;

        public void Delete_calendar()
        {
            //Instead of: ws.ClickByXPath("//nav/a/span");
            elem_1.Click();

            //Instead of: ws.ClickByXPath("(//input[@type='text'])[5]");
            elem_2.Click();

            //and so on...
        }
    }
}

If you are still keen on using external sources for storing your locators I would further add that generally using property files to store locators is popular but not necessarily best practice, please refer to https://seleniumjava.com/2017/03/19/do-not-store-element-locators-in-property-files/ for further information.


问:
Interactive multiplot with shared x-axis
I often plot noisy data along with a model. The residuals are shown in a bottom panel:

```<code>set colors classic
set samp 20000

set table $data
    plot '+' u 1:(y=10*(sin(10*$1))):(y-invnorm(rand(0))) w e
unset table

set multiplot layout 2,1
plot $data us 1:($2+$3):3 w p pt 7 ps 0.5 t "noisy data", $data us 1:2 w l lc 3 t "model"
plot $data us 1:3 w p pt 7 ps .5 t "noise"
unset multiplot
</code>```

However, this is not interactive anymore. After zooming one plot will be lost. (Matplotlib has here shared axis.)

My current approach is also not satisfying, but works at least if zooming only horizontally.

```<code>set autoscale y2fix
set y2range [-5:25]
plot [][-30:] $data us 1:($2+$3):3 w p pt 7 ps 0.5 t "noisy data", $data us 1:2 w l lc 3 t "model", $data us 1:3 w p pt 7 ps .5 t "noise" axis x1y2
</code>```

Are there better ways?

答:
Unfortunately, gnuplot cannot have interactive multiplots (maybe in the future?). I also would love to see mouse coordinates in a multiplot. Apparently, you can only zoom when you have a single plot.
Therefore, the following strange workaround might be helpful to you.

define key bindings to show different plot, e.g. 0=multiplot, 1=first plot, 2=second plot

redefine binding for "a" with your multiplot autoscale

make an endless loop which you can quit, e.g. by the key binding "x"

Usage:

press the key (1 or 2) for the desired plot and zoom in as you like

switch back to your multiplot via 0

exit the loop by pressing "x"

You might also use the gnuplot-builtin bindings "p" and "n" for "previous zoom" and "next zoom".
Type show bind to see all key-bindings.
The following could be a starting point for further optimization and tweaking to your exact needs.

Code:

```<code>### workaround for interactive multiplot
reset session

set print $Data
    do for [i=1:200] {
        print sprintf("%.3g %.3g %.3g",x=i/20., sin(x), rand(0)*0.2-0.1)
    }
set print

Stop = 0
myPlot = 0
myAutoscale = 0
myLastPlot = 0

bind "x" "Stop = 1"
bind "0" "myPlot = 0"
bind "1" "myPlot = 1"
bind "2" "myPlot = 2"
bind "a" "myAutoscale = 1"

set style textbox opaque
set label 1 at graph 0.01, graph 0.95 "Press key:\nx=stop\n0=mulitplot\n1=Plot1\n2=Plot2\na=autoscale" boxed front

Plot1 = 'plot $Data u 1:($2+$3) w p pt 7 ps 0.5 lc rgb "red" ti "Data", \
         "" u 1:2 w l lc rgb "blue" ti "Model"'

Plot2 = 'plot $Data u 1:3 w p pt 7 ps 0.5 lc rgb "blue" ti "Noise"'

set autoscale xy
PXmin = 0; PXmax = 10
P1Ymin = -1.2; P1Ymax = 1.2
P2Ymin = -0.3; P2Ymax = 0.3

while (!Stop) {
    if (myPlot == 0 || myAutoscale==1) {
        set multiplot layout 2,1
            # first plot
            if (myLastPlot) { PXmin = GPVAL_X_MIN;  PXmax = GPVAL_X_MAX }
            if (myLastPlot==1) { P1Ymin = GPVAL_Y_MIN;  P1Ymax = GPVAL_Y_MAX }
            if (myLastPlot==2) { P2Ymin = GPVAL_Y_MIN;  P2Ymax = GPVAL_Y_MAX }
            set xrange[PXmin:PXmax]
            set yrange[P1Ymin:P1Ymax]
            if (myAutoscale) { set autoscale xy }
            @Plot1
            PXmin = GPVAL_X_MIN;  PXmax = GPVAL_X_MAX
            P1Ymin = GPVAL_Y_MIN;  P1Ymax = GPVAL_Y_MAX
            # second plot
            set xrange[PXmin:PXmax]
            set yrange[P2Ymin:P2Ymax]
            if (myAutoscale) { set autoscale xy }
            @Plot2
            P2Ymin = GPVAL_Y_MIN;  P2Ymax = GPVAL_Y_MAX
            myAutoscale = 0
            myLastPlot = 0
        unset multiplot
    }
    if (myPlot == 1) {
        set xrange[PXmin:PXmax]
        set yrange[P1Ymin:P1Ymax]
        @Plot1
        myLastPlot=1
    }
    if (myPlot == 2) {
        set xrange[PXmin:PXmax]
        set yrange[P2Ymin:P2Ymax]
        @Plot2
        myLastPlot=2
    }
    myPlot = -1
    pause 0.1   # not sure whether this is necessary or has some advantage
}
### end of code
</code>```

Result:

Multiplot

Multiplot (zoomed in):

Body:
I often plot noisy data along with a model. The residuals are shown in a bottom panel:

set colors classic
set samp 20000

set table $data
    plot '+' u 1:(y=10*(sin(10*$1))):(y-invnorm(rand(0))) w e
unset table

set multiplot layout 2,1
plot $data us 1:($2+$3):3 w p pt 7 ps 0.5 t "noisy data", $data us 1:2 w l lc 3 t "model"
plot $data us 1:3 w p pt 7 ps .5 t "noise"
unset multiplot

However, this is not interactive anymore. After zooming one plot will be lost. (Matplotlib has here shared axis.)

My current approach is also not satisfying, but works at least if zooming only horizontally.

set autoscale y2fix
set y2range [-5:25]
plot [][-30:] $data us 1:($2+$3):3 w p pt 7 ps 0.5 t "noisy data", $data us 1:2 w l lc 3 t "model", $data us 1:3 w p pt 7 ps .5 t "noise" axis x1y2

Are there better ways?

Body:
Unfortunately, gnuplot cannot have interactive multiplots (maybe in the future?). I also would love to see mouse coordinates in a multiplot. Apparently, you can only zoom when you have a single plot.
Therefore, the following strange workaround might be helpful to you.

define key bindings to show different plot, e.g. 0=multiplot, 1=first plot, 2=second plot

redefine binding for "a" with your multiplot autoscale

make an endless loop which you can quit, e.g. by the key binding "x"

Usage:

press the key (1 or 2) for the desired plot and zoom in as you like

switch back to your multiplot via 0

exit the loop by pressing "x"

You might also use the gnuplot-builtin bindings "p" and "n" for "previous zoom" and "next zoom".
Type show bind to see all key-bindings.
The following could be a starting point for further optimization and tweaking to your exact needs.

Code:

### workaround for interactive multiplot
reset session

set print $Data
    do for [i=1:200] {
        print sprintf("%.3g %.3g %.3g",x=i/20., sin(x), rand(0)*0.2-0.1)
    }
set print

Stop = 0
myPlot = 0
myAutoscale = 0
myLastPlot = 0

bind "x" "Stop = 1"
bind "0" "myPlot = 0"
bind "1" "myPlot = 1"
bind "2" "myPlot = 2"
bind "a" "myAutoscale = 1"

set style textbox opaque
set label 1 at graph 0.01, graph 0.95 "Press key:\nx=stop\n0=mulitplot\n1=Plot1\n2=Plot2\na=autoscale" boxed front

Plot1 = 'plot $Data u 1:($2+$3) w p pt 7 ps 0.5 lc rgb "red" ti "Data", \
         "" u 1:2 w l lc rgb "blue" ti "Model"'

Plot2 = 'plot $Data u 1:3 w p pt 7 ps 0.5 lc rgb "blue" ti "Noise"'

set autoscale xy
PXmin = 0; PXmax = 10
P1Ymin = -1.2; P1Ymax = 1.2
P2Ymin = -0.3; P2Ymax = 0.3

while (!Stop) {
    if (myPlot == 0 || myAutoscale==1) {
        set multiplot layout 2,1
            # first plot
            if (myLastPlot) { PXmin = GPVAL_X_MIN;  PXmax = GPVAL_X_MAX }
            if (myLastPlot==1) { P1Ymin = GPVAL_Y_MIN;  P1Ymax = GPVAL_Y_MAX }
            if (myLastPlot==2) { P2Ymin = GPVAL_Y_MIN;  P2Ymax = GPVAL_Y_MAX }
            set xrange[PXmin:PXmax]
            set yrange[P1Ymin:P1Ymax]
            if (myAutoscale) { set autoscale xy }
            @Plot1
            PXmin = GPVAL_X_MIN;  PXmax = GPVAL_X_MAX
            P1Ymin = GPVAL_Y_MIN;  P1Ymax = GPVAL_Y_MAX
            # second plot
            set xrange[PXmin:PXmax]
            set yrange[P2Ymin:P2Ymax]
            if (myAutoscale) { set autoscale xy }
            @Plot2
            P2Ymin = GPVAL_Y_MIN;  P2Ymax = GPVAL_Y_MAX
            myAutoscale = 0
            myLastPlot = 0
        unset multiplot
    }
    if (myPlot == 1) {
        set xrange[PXmin:PXmax]
        set yrange[P1Ymin:P1Ymax]
        @Plot1
        myLastPlot=1
    }
    if (myPlot == 2) {
        set xrange[PXmin:PXmax]
        set yrange[P2Ymin:P2Ymax]
        @Plot2
        myLastPlot=2
    }
    myPlot = -1
    pause 0.1   # not sure whether this is necessary or has some advantage
}
### end of code

Result:

Multiplot

Multiplot (zoomed in):


问:
Docker service start failed
I have a CentOS 7.2 VM with Docker installed. Docker service and Docker container worked normally previously. But when I tried to pull a docker image, the VM was shutdown abruptly. After I restarted the VM, the Docker service could not be started:

```<code>[root@AY13091717064020986bZ ~]# service docker start
Redirecting to /bin/systemctl start  docker.service
Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.
</code>```

systemctl status docker.service output:

```<code>[root@AY13091717064020986bZ ~]# systemctl status docker.service
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Tue 2016-08-23 19:11:19 CST; 13min ago
     Docs: http://docs.docker.com
  Process: 1404 ExecStart=/usr/bin/docker-current daemon --exec-opt native.cgroupdriver=systemd $OPTIONS $DOCKER_STORAGE_OPTIONS $DOCKER_NETWORK_OPTIONS $ADD_REGISTRY $BLOCK_REGISTRY $INSECURE_REGISTRY (code=exited, status=1/FAILURE)
 Main PID: 1404 (code=exited, status=1/FAILURE)

Aug 23 19:11:17 AY13091717064020986bZ systemd[1]: Starting Docker Application Container Engine...
Aug 23 19:11:19 AY13091717064020986bZ docker-current[1404]: time="2016-08-23T19:11:19.448828158+08:00" level=warning msg="devmapper: Usage of loopback devices is strongly discou...v section."
Aug 23 19:11:19 AY13091717064020986bZ docker-current[1404]: time="2016-08-23T19:11:19.511103592+08:00" level=error msg="[graphdriver] prior storage driver \"devicemapper\" faile...t status 2"
Aug 23 19:11:19 AY13091717064020986bZ docker-current[1404]: time="2016-08-23T19:11:19.511196844+08:00" level=fatal msg="Error starting daemon: error initializing graphdriver: de...t status 2"
Aug 23 19:11:19 AY13091717064020986bZ systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
Aug 23 19:11:19 AY13091717064020986bZ systemd[1]: Failed to start Docker Application Container Engine.
Aug 23 19:11:19 AY13091717064020986bZ systemd[1]: Unit docker.service entered failed state.
Aug 23 19:11:19 AY13091717064020986bZ systemd[1]: docker.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
</code>```

"journalctl -xe" output:

```<code>[root@AY13091717064020986bZ ~]# journalctl -xe
Aug 23 19:11:19 AY13091717064020986bZ kernel: device-mapper: block manager: btree_node validator check failed for block 146
Aug 23 19:11:19 AY13091717064020986bZ kernel: device-mapper: btree spine: node_check failed: csum 1600702373 != wanted 1600827965
Aug 23 19:11:19 AY13091717064020986bZ kernel: device-mapper: block manager: btree_node validator check failed for block 146
Aug 23 19:11:19 AY13091717064020986bZ kernel: Buffer I/O error on device dm-1, logical block 2621424
Aug 23 19:11:19 AY13091717064020986bZ docker-current[1404]: time="2016-08-23T19:11:19.511103592+08:00" level=error msg="[graphdriver] prior storage driver \"devicemapper\" failed: devmapper:
Aug 23 19:11:19 AY13091717064020986bZ docker-current[1404]: time="2016-08-23T19:11:19.511196844+08:00" level=fatal msg="Error starting daemon: error initializing graphdriver: devmapper: Base
Aug 23 19:11:19 AY13091717064020986bZ systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
Aug 23 19:11:19 AY13091717064020986bZ systemd[1]: Failed to start Docker Application Container Engine.
-- Subject: Unit docker.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit docker.service has failed.
--
-- The result is failed.
Aug 23 19:11:19 AY13091717064020986bZ systemd[1]: Unit docker.service entered failed state.
Aug 23 19:11:19 AY13091717064020986bZ systemd[1]: docker.service failed.
Aug 23 19:11:19 AY13091717064020986bZ polkitd[1014]: Unregistered Authentication Agent for unix-process:1370:16052 (system bus name :1.22, object path /org/freedesktop/PolicyKit1/Authenticati
Aug 23 19:23:43 AY13091717064020986bZ systemd[1]: Starting Cleanup of Temporary Directories...
-- Subject: Unit systemd-tmpfiles-clean.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit systemd-tmpfiles-clean.service has begun starting up.
Aug 23 19:23:43 AY13091717064020986bZ systemd[1]: Started Cleanup of Temporary Directories.
-- Subject: Unit systemd-tmpfiles-clean.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit systemd-tmpfiles-clean.service has finished starting up.
--
-- The start-up result is done.
</code>```

Docker version:

```<code>[root@AY13091717064020986bZ ~]# docker version
Client:
 Version:         1.10.3
 API version:     1.22
 Package version: docker-common-1.10.3-46.el7.centos.10.x86_64
 Go version:      go1.6.3
 Git commit:      d381c64-unsupported
 Built:           Thu Aug  4 13:21:17 2016
 OS/Arch:         linux/amd64
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
</code>```

Linux kernel version:

```<code>[root@AY13091717064020986bZ ~]# uname -a
Linux AY13091717064020986bZ 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
[root@AY13091717064020986bZ ~]#
</code>```

CentOS version:

```<code>[root@AY13091717064020986bZ ~]# lsb_release -a
LSB Version:    :core-4.1-amd64:core-4.1-noarch
Distributor ID:    CentOS
Description:    CentOS Linux release 7.2.1511 (Core)
Release:    7.2.1511
Codename:    Core
[root@AY13091717064020986bZ ~]#
</code>```

答:
Step1. Use 'dockerd' command to check the exact reason

```<code>[root@c7 docker]# dockerd
INFO[2020-06-03T11:27:50.293740882+05:30] Starting up
INFO[2020-06-03T11:27:50.298500541+05:30] parsed scheme: "unix"                         module=grpc
INFO[2020-06-03T11:27:50.298535150+05:30] scheme "unix" not registered, fallback to default scheme  module=grpc
INFO[2020-06-03T11:27:50.298568308+05:30] ccResolverWrapper: sending update to cc: {[{unix:///run/containerd/containerd.sock 0  <nil>}] <nil>}  module=grpc
INFO[2020-06-03T11:27:50.298582671+05:30] ClientConn switching balancer to "pick_first"  module=grpc
INFO[2020-06-03T11:27:50.305144487+05:30] parsed scheme: "unix"                         module=grpc
INFO[2020-06-03T11:27:50.305193838+05:30] scheme "unix" not registered, fallback to default scheme  module=grpc
INFO[2020-06-03T11:27:50.305239948+05:30] ccResolverWrapper: sending update to cc: {[{unix:///run/containerd/containerd.sock 0  <nil>}] <nil>}  module=grpc
INFO[2020-06-03T11:27:50.305254274+05:30] ClientConn switching balancer to "pick_first"  module=grpc
failed to start daemon: error initializing graphdriver: /var/lib/docker contains several valid graphdrivers: overlay2, devicemapper; Please cleanup or explicitly choose storage driver (-s <DRIVER>)
</code>```

Step2: remove overlay or devicemapper storage. Only 1 storage should exist

```<code>[root@c7 docker]# rm -rf devicemapper
</code>```

Step3: Now start docker
[root@c7 docker]# systemctl start docker

Step4: If you're getting below error

```<code>[root@c7 docker]# docker container ls
</code>```

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Step5: Remove below file and restart docker

```<code>[root@c7 docker]# rm -rf /var/run/docker.pid
[root@c7 docker]# systemctl restart docker
</code>```

Step6: You'll get back your images and running containers

Title: Docker service start failed

Body:
I have a CentOS 7.2 VM with Docker installed. Docker service and Docker container worked normally previously. But when I tried to pull a docker image, the VM was shutdown abruptly. After I restarted the VM, the Docker service could not be started:

[root@AY13091717064020986bZ ~]# service docker start
Redirecting to /bin/systemctl start  docker.service
Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.

systemctl status docker.service output:

[root@AY13091717064020986bZ ~]# systemctl status docker.service
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Tue 2016-08-23 19:11:19 CST; 13min ago
     Docs: http://docs.docker.com
  Process: 1404 ExecStart=/usr/bin/docker-current daemon --exec-opt native.cgroupdriver=systemd $OPTIONS $DOCKER_STORAGE_OPTIONS $DOCKER_NETWORK_OPTIONS $ADD_REGISTRY $BLOCK_REGISTRY $INSECURE_REGISTRY (code=exited, status=1/FAILURE)
 Main PID: 1404 (code=exited, status=1/FAILURE)

Aug 23 19:11:17 AY13091717064020986bZ systemd[1]: Starting Docker Application Container Engine...
Aug 23 19:11:19 AY13091717064020986bZ docker-current[1404]: time="2016-08-23T19:11:19.448828158+08:00" level=warning msg="devmapper: Usage of loopback devices is strongly discou...v section."
Aug 23 19:11:19 AY13091717064020986bZ docker-current[1404]: time="2016-08-23T19:11:19.511103592+08:00" level=error msg="[graphdriver] prior storage driver \"devicemapper\" faile...t status 2"
Aug 23 19:11:19 AY13091717064020986bZ docker-current[1404]: time="2016-08-23T19:11:19.511196844+08:00" level=fatal msg="Error starting daemon: error initializing graphdriver: de...t status 2"
Aug 23 19:11:19 AY13091717064020986bZ systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
Aug 23 19:11:19 AY13091717064020986bZ systemd[1]: Failed to start Docker Application Container Engine.
Aug 23 19:11:19 AY13091717064020986bZ systemd[1]: Unit docker.service entered failed state.
Aug 23 19:11:19 AY13091717064020986bZ systemd[1]: docker.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

"journalctl -xe" output:

[root@AY13091717064020986bZ ~]# journalctl -xe
Aug 23 19:11:19 AY13091717064020986bZ kernel: device-mapper: block manager: btree_node validator check failed for block 146
Aug 23 19:11:19 AY13091717064020986bZ kernel: device-mapper: btree spine: node_check failed: csum 1600702373 != wanted 1600827965
Aug 23 19:11:19 AY13091717064020986bZ kernel: device-mapper: block manager: btree_node validator check failed for block 146
Aug 23 19:11:19 AY13091717064020986bZ kernel: Buffer I/O error on device dm-1, logical block 2621424
Aug 23 19:11:19 AY13091717064020986bZ docker-current[1404]: time="2016-08-23T19:11:19.511103592+08:00" level=error msg="[graphdriver] prior storage driver \"devicemapper\" failed: devmapper:
Aug 23 19:11:19 AY13091717064020986bZ docker-current[1404]: time="2016-08-23T19:11:19.511196844+08:00" level=fatal msg="Error starting daemon: error initializing graphdriver: devmapper: Base
Aug 23 19:11:19 AY13091717064020986bZ systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
Aug 23 19:11:19 AY13091717064020986bZ systemd[1]: Failed to start Docker Application Container Engine.
-- Subject: Unit docker.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit docker.service has failed.
--
-- The result is failed.
Aug 23 19:11:19 AY13091717064020986bZ systemd[1]: Unit docker.service entered failed state.
Aug 23 19:11:19 AY13091717064020986bZ systemd[1]: docker.service failed.
Aug 23 19:11:19 AY13091717064020986bZ polkitd[1014]: Unregistered Authentication Agent for unix-process:1370:16052 (system bus name :1.22, object path /org/freedesktop/PolicyKit1/Authenticati
Aug 23 19:23:43 AY13091717064020986bZ systemd[1]: Starting Cleanup of Temporary Directories...
-- Subject: Unit systemd-tmpfiles-clean.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit systemd-tmpfiles-clean.service has begun starting up.
Aug 23 19:23:43 AY13091717064020986bZ systemd[1]: Started Cleanup of Temporary Directories.
-- Subject: Unit systemd-tmpfiles-clean.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit systemd-tmpfiles-clean.service has finished starting up.
--
-- The start-up result is done.

Docker version:

[root@AY13091717064020986bZ ~]# docker version
Client:
 Version:         1.10.3
 API version:     1.22
 Package version: docker-common-1.10.3-46.el7.centos.10.x86_64
 Go version:      go1.6.3
 Git commit:      d381c64-unsupported
 Built:           Thu Aug  4 13:21:17 2016
 OS/Arch:         linux/amd64
Cannot connect to the Docker daemon. Is the docker daemon running on this host?

Linux kernel version:

[root@AY13091717064020986bZ ~]# uname -a
Linux AY13091717064020986bZ 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
[root@AY13091717064020986bZ ~]#

CentOS version:

[root@AY13091717064020986bZ ~]# lsb_release -a
LSB Version:    :core-4.1-amd64:core-4.1-noarch
Distributor ID:    CentOS
Description:    CentOS Linux release 7.2.1511 (Core)
Release:    7.2.1511
Codename:    Core
[root@AY13091717064020986bZ ~]#

Body:
Step1. Use 'dockerd' command to check the exact reason

[root@c7 docker]# dockerd
INFO[2020-06-03T11:27:50.293740882+05:30] Starting up
INFO[2020-06-03T11:27:50.298500541+05:30] parsed scheme: "unix"                         module=grpc
INFO[2020-06-03T11:27:50.298535150+05:30] scheme "unix" not registered, fallback to default scheme  module=grpc
INFO[2020-06-03T11:27:50.298568308+05:30] ccResolverWrapper: sending update to cc: {[{unix:///run/containerd/containerd.sock 0  <nil>}] <nil>}  module=grpc
INFO[2020-06-03T11:27:50.298582671+05:30] ClientConn switching balancer to "pick_first"  module=grpc
INFO[2020-06-03T11:27:50.305144487+05:30] parsed scheme: "unix"                         module=grpc
INFO[2020-06-03T11:27:50.305193838+05:30] scheme "unix" not registered, fallback to default scheme  module=grpc
INFO[2020-06-03T11:27:50.305239948+05:30] ccResolverWrapper: sending update to cc: {[{unix:///run/containerd/containerd.sock 0  <nil>}] <nil>}  module=grpc
INFO[2020-06-03T11:27:50.305254274+05:30] ClientConn switching balancer to "pick_first"  module=grpc
failed to start daemon: error initializing graphdriver: /var/lib/docker contains several valid graphdrivers: overlay2, devicemapper; Please cleanup or explicitly choose storage driver (-s <DRIVER>)

Step2: remove overlay or devicemapper storage. Only 1 storage should exist

[root@c7 docker]# rm -rf devicemapper

Step3: Now start docker
[root@c7 docker]# systemctl start docker

Step4: If you're getting below error

[root@c7 docker]# docker container ls

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Step5: Remove below file and restart docker

[root@c7 docker]# rm -rf /var/run/docker.pid
[root@c7 docker]# systemctl restart docker

Step6: You'll get back your images and running containers


Title: how to sum up a list of timestamps by the speaker name

Body:
i am working on a project
and i have extracted data from lists and have now 3 lists:

list 1 - a list of speaker names

['<M1>', '<M1>', '<M1>', '<M1>', '<M1>', '<M2>', '<M2>', '<M2>', '<M1>', '<M1>', '<M2>', '<M1>', '<M2>', '<M2>', '<M2>', '<M2>', '<M2>']

list 2 - a list of the beginning of talk time stamps

['[00:00:00.000]', '[00:00:08.010]', '[00:00:16.890]', '[00:00:26.210]', '[00:00:39.980]', '[00:00:48.100]', '[00:00:56.770]', '[00:01:08.010]', '[00:01:21.120]', '[00:01:46.130]', '[00:01:47.180]', '[00:01:49.390]', '[00:01:50.670]', '[00:02:02.320]', '[00:02:16.010]', '[00:02:21.110]', '[00:02:27.610]']

list 3 - a list of the ending of talk time stamps

['[00:00:08.010]', '[00:00:16.290]', '[00:00:26.210]', '[00:00:39.980]', '[00:00:48.100]', '[00:00:56.770]', '[00:01:08.010]', '[00:01:20.250]', '[00:01:33.850]', '[00:01:47.150]', '[00:01:49.370]', '[00:01:50.140]', '[00:02:01.350]', '[00:02:16.010]', '[00:02:20.150]', '[00:02:27.610]', '[00:02:39.040]']

what I need to do is whenever a single speaker talked many times (for example the first 5 elements of the list)
I need change the first ending segment [00:00:08.010] to [00:00:48.100] and get rid of all the entries in between (turn the 5 entries where there was a single talker to 1 entry)
and do this again for all speakers in the list.
if the speaker talked only once so it needs to stay the same.
can someone please help me and find a way of how to do this in python?
thanks !

Body:
You can use groupby function in itertools,Try this

from itertools import groupby

l1 = ['<M1>', '<M1>', '<M1>', '<M1>', '<M1>', '<M2>', '<M2>', '<M2>', '<M1>', '<M1>', '<M2>', '<M1>', '<M2>', '<M2>', '<M2>', '<M2>', '<M2>']
l2= ['[00:00:00.000]', '[00:00:08.010]', '[00:00:16.890]', '[00:00:26.210]', '[00:00:39.980]', '[00:00:48.100]', '[00:00:56.770]', '[00:01:08.010]', '[00:01:21.120]', '[00:01:46.130]', '[00:01:47.180]', '[00:01:49.390]', '[00:01:50.670]', '[00:02:02.320]', '[00:02:16.010]', '[00:02:21.110]', '[00:02:27.610]']
l3 = ['[00:00:08.010]', '[00:00:16.290]', '[00:00:26.210]', '[00:00:39.980]', '[00:00:48.100]', '[00:00:56.770]', '[00:01:08.010]', '[00:01:20.250]', '[00:01:33.850]', '[00:01:47.150]', '[00:01:49.370]', '[00:01:50.140]', '[00:02:01.350]', '[00:02:16.010]', '[00:02:20.150]', '[00:02:27.610]', '[00:02:39.040]']
start_index = 0
for (m,g) in groupby(l1):
    end_index = start_index + len(list(g)) -1
    start_time = l2[start_index]
    end_time = l3[end_index]
    start_index=end_index+1
    print(start_time)
    print(end_time)
    print("============")

output

[00:00:00.000]
[00:00:48.100]
============
[00:00:48.100]
[00:01:20.250]
============
[00:01:21.120]
[00:01:47.150]
============
[00:01:47.180]
[00:01:49.370]
============
[00:01:49.390]
[00:01:50.140]
============
[00:01:50.670]
[00:02:39.040]
============


问:
querySelector works but querySelectorAll doesn't
I'm very new to JS.
There are 3 svgs, and I'm trying to change the fill color when the mouse is over.
When I use querySelector('.svg'), the first one works perfectly.
I'd like to change all three of them, not only the first one,
but none of querySelectorAll('.svg'), or getElementsbyClassName, getElementsbyTagName seem to work. What is the problem?
Any help would be appreciated.
Thank you.

const icon = document.querySelectorAll(".svg");

icon.addEventListener("mouseover", function () {
  icon.style.color = "#ED4264";
});

icon.addEventListener("mouseout", function () {
  icon.style.color = "black";
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><footer>
      <div class="prev">
        <svg
          class="svg"
          width="22"
          height="21"
          viewBox="0 0 22 21"
          xmlns="http://www.w3.org/2000/svg"
        >
          <path
            fill-rule="evenodd"
            clip-rule="evenodd"
            d="M10.3376 20.7849L0.183247 10.5454L10.3376 0.305979L13.1778 3.12258L7.80002 8.54544L21.9751 8.54544V12.5454L7.80002 12.5454L13.1778 17.9683L10.3376 20.7849Z"
            fill="currentcolor"
          />
        </svg>
      </div>

      <div class="random">
        <svg
          class="svg"
          width="27"
          height="24"
          viewBox="0 0 27 24"
          xmlns="http://www.w3.org/2000/svg"
        >
          <path
            d="M0 0L3.57143 3.57143L7.7486e-05 7.14286"
            transform="translate(20.5713 2)"
            stroke="currentcolor"
            stroke-width="3"
          />
          <path
            d="M0 0L3.57143 3.57143L7.7486e-05 7.14286"
            transform="translate(20.5713 14.8572)"
            stroke="currentcolor"
            stroke-width="3"
          />
          <path
            d="M0 12.3214C5.03247 12.3214 10.0649 9.91071 11.5747 6.16059C13.0844 2.41047 17.1104 7.37802e-05 22.1429 0"
            transform="translate(0.571289 18.4285) scale(1 -1)"
            stroke="currentcolor"
            stroke-width="4"
          />
          <path
            fill-rule="evenodd"
            clip-rule="evenodd"
            d="M22.1431 4C19.2583 4 16.9155 4.88867 15.3193 6.28589C14.4653 5.53833 13.8252 4.64478 13.4302 3.66406C13.3286 3.41235 13.2163 3.16724 13.0933 2.92822C15.4746 1.03613 18.6689 0 22.1431 0V4ZM13.0933 9.64331C11.9321 8.7207 10.9639 7.59473 10.251 6.28589C10.0537 6.64795 9.87598 7.02393 9.71924 7.41357C9.68506 7.49829 9.64844 7.58276 9.6084 7.66675C10.7573 8.46265 11.7734 9.43262 12.5425 10.5715C12.7437 10.2737 12.9277 9.96436 13.0933 9.64331ZM9.6084 13.4763C9.09961 12.4043 8.12012 11.3911 6.73145 10.5715C6.55762 10.6741 6.37744 10.7737 6.19092 10.8701C4.41309 11.7878 2.21338 12.3215 0 12.3215V16.3215C2.81885 16.3215 5.65186 15.6497 8.02588 14.4246C8.57275 14.1423 9.10352 13.8262 9.6084 13.4763Z"
            transform="translate(0.571289 3.57129)"
            fill="currentcolor"
          />
        </svg>
      </div>

      <div class="next">
        <svg
          class="svg"
          width="23"
          height="21"
          viewBox="0 0 23 21"
          xmlns="http://www.w3.org/2000/svg"
        >
          <path
            fill-rule="evenodd"
            clip-rule="evenodd"
            d="M12.2088 0.0202637L22.3631 10.2597L12.2088 20.4992L9.36858 17.6826L14.7464 12.2597H0.571289V8.25973H14.7464L9.36858 2.83686L12.2088 0.0202637Z"
            fill="currentcolor"
          />
        </svg>
      </div>
    </footer></code>```

答:
The difference is that .querySelector() selects just 1 element while .querySelectorAll() selects multiple, that means you get a list with .querySelectorAll() so you need to loop through and add for each SVG an event listener

const icons = document.querySelectorAll(".svg"); //use "icons", its plural

icons.forEach(icon => {
   icon.addEventListener("mouseover", function () {
     icon.style.color = "#ED4264";
   });

   icon.addEventListener("mouseout", function () {
     icon.style.color = "black";
   });
})```
<pre class="snippet-code-html lang-html prettyprint-override"><code><footer>
      <div class="prev">
        <svg
          class="svg"
          width="22"
          height="21"
          viewBox="0 0 22 21"
          xmlns="http://www.w3.org/2000/svg"
        >
          <path
            fill-rule="evenodd"
            clip-rule="evenodd"
            d="M10.3376 20.7849L0.183247 10.5454L10.3376 0.305979L13.1778 3.12258L7.80002 8.54544L21.9751 8.54544V12.5454L7.80002 12.5454L13.1778 17.9683L10.3376 20.7849Z"
            fill="currentcolor"
          />
        </svg>
      </div>

      <div class="random">
        <svg
          class="svg"
          width="27"
          height="24"
          viewBox="0 0 27 24"
          xmlns="http://www.w3.org/2000/svg"
        >
          <path
            d="M0 0L3.57143 3.57143L7.7486e-05 7.14286"
            transform="translate(20.5713 2)"
            stroke="currentcolor"
            stroke-width="3"
          />
          <path
            d="M0 0L3.57143 3.57143L7.7486e-05 7.14286"
            transform="translate(20.5713 14.8572)"
            stroke="currentcolor"
            stroke-width="3"
          />
          <path
            d="M0 12.3214C5.03247 12.3214 10.0649 9.91071 11.5747 6.16059C13.0844 2.41047 17.1104 7.37802e-05 22.1429 0"
            transform="translate(0.571289 18.4285) scale(1 -1)"
            stroke="currentcolor"
            stroke-width="4"
          />
          <path
            fill-rule="evenodd"
            clip-rule="evenodd"
            d="M22.1431 4C19.2583 4 16.9155 4.88867 15.3193 6.28589C14.4653 5.53833 13.8252 4.64478 13.4302 3.66406C13.3286 3.41235 13.2163 3.16724 13.0933 2.92822C15.4746 1.03613 18.6689 0 22.1431 0V4ZM13.0933 9.64331C11.9321 8.7207 10.9639 7.59473 10.251 6.28589C10.0537 6.64795 9.87598 7.02393 9.71924 7.41357C9.68506 7.49829 9.64844 7.58276 9.6084 7.66675C10.7573 8.46265 11.7734 9.43262 12.5425 10.5715C12.7437 10.2737 12.9277 9.96436 13.0933 9.64331ZM9.6084 13.4763C9.09961 12.4043 8.12012 11.3911 6.73145 10.5715C6.55762 10.6741 6.37744 10.7737 6.19092 10.8701C4.41309 11.7878 2.21338 12.3215 0 12.3215V16.3215C2.81885 16.3215 5.65186 15.6497 8.02588 14.4246C8.57275 14.1423 9.10352 13.8262 9.6084 13.4763Z"
            transform="translate(0.571289 3.57129)"
            fill="currentcolor"
          />
        </svg>
      </div>

      <div class="next">
        <svg
          class="svg"
          width="23"
          height="21"
          viewBox="0 0 23 21"
          xmlns="http://www.w3.org/2000/svg"
        >
          <path
            fill-rule="evenodd"
            clip-rule="evenodd"
            d="M12.2088 0.0202637L22.3631 10.2597L12.2088 20.4992L9.36858 17.6826L14.7464 12.2597H0.571289V8.25973H14.7464L9.36858 2.83686L12.2088 0.0202637Z"
            fill="currentcolor"
          />
        </svg>
      </div>
    </footer></code>```

Body:
I'm very new to JS.
There are 3 svgs, and I'm trying to change the fill color when the mouse is over.
When I use querySelector('.svg'), the first one works perfectly.
I'd like to change all three of them, not only the first one,
but none of querySelectorAll('.svg'), or getElementsbyClassName, getElementsbyTagName seem to work. What is the problem?
Any help would be appreciated.
Thank you.

const icon = document.querySelectorAll(".svg");

icon.addEventListener("mouseover", function () {
  icon.style.color = "#ED4264";
});

icon.addEventListener("mouseout", function () {
  icon.style.color = "black";
});

        <svg
          class="svg"
          width="22"
          height="21"
          viewBox="0 0 22 21"
          xmlns="http://www.w3.org/2000/svg"
        >
          <path
            fill-rule="evenodd"
            clip-rule="evenodd"
            d="M10.3376 20.7849L0.183247 10.5454L10.3376 0.305979L13.1778 3.12258L7.80002 8.54544L21.9751 8.54544V12.5454L7.80002 12.5454L13.1778 17.9683L10.3376 20.7849Z"
            fill="currentcolor"
          />
        </svg>

        <svg
          class="svg"
          width="27"
          height="24"
          viewBox="0 0 27 24"
          xmlns="http://www.w3.org/2000/svg"
        >
          <path
            d="M0 0L3.57143 3.57143L7.7486e-05 7.14286"
            transform="translate(20.5713 2)"
            stroke="currentcolor"
            stroke-width="3"
          />
          <path
            d="M0 0L3.57143 3.57143L7.7486e-05 7.14286"
            transform="translate(20.5713 14.8572)"
            stroke="currentcolor"
            stroke-width="3"
          />
          <path
            d="M0 12.3214C5.03247 12.3214 10.0649 9.91071 11.5747 6.16059C13.0844 2.41047 17.1104 7.37802e-05 22.1429 0"
            transform="translate(0.571289 18.4285) scale(1 -1)"
            stroke="currentcolor"
            stroke-width="4"
          />
          <path
            fill-rule="evenodd"
            clip-rule="evenodd"
            d="M22.1431 4C19.2583 4 16.9155 4.88867 15.3193 6.28589C14.4653 5.53833 13.8252 4.64478 13.4302 3.66406C13.3286 3.41235 13.2163 3.16724 13.0933 2.92822C15.4746 1.03613 18.6689 0 22.1431 0V4ZM13.0933 9.64331C11.9321 8.7207 10.9639 7.59473 10.251 6.28589C10.0537 6.64795 9.87598 7.02393 9.71924 7.41357C9.68506 7.49829 9.64844 7.58276 9.6084 7.66675C10.7573 8.46265 11.7734 9.43262 12.5425 10.5715C12.7437 10.2737 12.9277 9.96436 13.0933 9.64331ZM9.6084 13.4763C9.09961 12.4043 8.12012 11.3911 6.73145 10.5715C6.55762 10.6741 6.37744 10.7737 6.19092 10.8701C4.41309 11.7878 2.21338 12.3215 0 12.3215V16.3215C2.81885 16.3215 5.65186 15.6497 8.02588 14.4246C8.57275 14.1423 9.10352 13.8262 9.6084 13.4763Z"
            transform="translate(0.571289 3.57129)"
            fill="currentcolor"
          />
        </svg>

        <svg
          class="svg"
          width="23"
          height="21"
          viewBox="0 0 23 21"
          xmlns="http://www.w3.org/2000/svg"
        >
          <path
            fill-rule="evenodd"
            clip-rule="evenodd"
            d="M12.2088 0.0202637L22.3631 10.2597L12.2088 20.4992L9.36858 17.6826L14.7464 12.2597H0.571289V8.25973H14.7464L9.36858 2.83686L12.2088 0.0202637Z"
            fill="currentcolor"
          />
        </svg>

Body:
The difference is that .querySelector() selects just 1 element while .querySelectorAll() selects multiple, that means you get a list with .querySelectorAll() so you need to loop through and add for each SVG an event listener

const icons = document.querySelectorAll(".svg"); //use "icons", its plural

icons.forEach(icon => {
   icon.addEventListener("mouseover", function () {
     icon.style.color = "#ED4264";
   });

   icon.addEventListener("mouseout", function () {
     icon.style.color = "black";
   });
})

<footer>
      <div class="prev">
        <svg
          class="svg"
          width="22"
          height="21"
          viewBox="0 0 22 21"
          xmlns="http://www.w3.org/2000/svg"
        >
          <path
            fill-rule="evenodd"
            clip-rule="evenodd"
            d="M10.3376 20.7849L0.183247 10.5454L10.3376 0.305979L13.1778 3.12258L7.80002 8.54544L21.9751 8.54544V12.5454L7.80002 12.5454L13.1778 17.9683L10.3376 20.7849Z"
            fill="currentcolor"
          />
        </svg>
      </div>

      <div class="random">
        <svg
          class="svg"
          width="27"
          height="24"
          viewBox="0 0 27 24"
          xmlns="http://www.w3.org/2000/svg"
        >
          <path
            d="M0 0L3.57143 3.57143L7.7486e-05 7.14286"
            transform="translate(20.5713 2)"
            stroke="currentcolor"
            stroke-width="3"
          />
          <path
            d="M0 0L3.57143 3.57143L7.7486e-05 7.14286"
            transform="translate(20.5713 14.8572)"
            stroke="currentcolor"
            stroke-width="3"
          />
          <path
            d="M0 12.3214C5.03247 12.3214 10.0649 9.91071 11.5747 6.16059C13.0844 2.41047 17.1104 7.37802e-05 22.1429 0"
            transform="translate(0.571289 18.4285) scale(1 -1)"
            stroke="currentcolor"
            stroke-width="4"
          />
          <path
            fill-rule="evenodd"
            clip-rule="evenodd"
            d="M22.1431 4C19.2583 4 16.9155 4.88867 15.3193 6.28589C14.4653 5.53833 13.8252 4.64478 13.4302 3.66406C13.3286 3.41235 13.2163 3.16724 13.0933 2.92822C15.4746 1.03613 18.6689 0 22.1431 0V4ZM13.0933 9.64331C11.9321 8.7207 10.9639 7.59473 10.251 6.28589C10.0537 6.64795 9.87598 7.02393 9.71924 7.41357C9.68506 7.49829 9.64844 7.58276 9.6084 7.66675C10.7573 8.46265 11.7734 9.43262 12.5425 10.5715C12.7437 10.2737 12.9277 9.96436 13.0933 9.64331ZM9.6084 13.4763C9.09961 12.4043 8.12012 11.3911 6.73145 10.5715C6.55762 10.6741 6.37744 10.7737 6.19092 10.8701C4.41309 11.7878 2.21338 12.3215 0 12.3215V16.3215C2.81885 16.3215 5.65186 15.6497 8.02588 14.4246C8.57275 14.1423 9.10352 13.8262 9.6084 13.4763Z"
            transform="translate(0.571289 3.57129)"
            fill="currentcolor"
          />
        </svg>
      </div>

      <div class="next">
        <svg
          class="svg"
          width="23"
          height="21"
          viewBox="0 0 23 21"
          xmlns="http://www.w3.org/2000/svg"
        >
          <path
            fill-rule="evenodd"
            clip-rule="evenodd"
            d="M12.2088 0.0202637L22.3631 10.2597L12.2088 20.4992L9.36858 17.6826L14.7464 12.2597H0.571289V8.25973H14.7464L9.36858 2.83686L12.2088 0.0202637Z"
            fill="currentcolor"
          />
        </svg>
      </div>
    </footer>


Body:
speakerOrder    = ['<M1>', '<M1>', '<M1>', '<M1>', '<M1>', '<M2>', '<M2>', '<M2>', '<M1>', '<M1>', '<M2>', '<M1>', '<M2>', '<M2>', '<M2>', '<M2>', '<M2>']
speakerBegin    = ['[00:00:00.000]', '[00:00:08.010]', '[00:00:16.890]', '[00:00:26.210]', '[00:00:39.980]', '[00:00:48.100]', '[00:00:56.770]', '[00:01:08.010]', '[00:01:21.120]', '[00:01:46.130]', '[00:01:47.180]', '[00:01:49.390]', '[00:01:50.670]', '[00:02:02.320]', '[00:02:16.010]', '[00:02:21.110]', '[00:02:27.610]']
speakerEnd      = ['[00:00:08.010]', '[00:00:16.290]', '[00:00:26.210]', '[00:00:39.980]', '[00:00:48.100]', '[00:00:56.770]', '[00:01:08.010]', '[00:01:20.250]', '[00:01:33.850]', '[00:01:47.150]', '[00:01:49.370]', '[00:01:50.140]', '[00:02:01.350]', '[00:02:16.010]', '[00:02:20.150]', '[00:02:27.610]', '[00:02:39.040]']

newSpeakerOrder = []
newSpeakerBegin = []
newSpeakerEnd   = []

currentSpeaker = None
for speakerIndex in range(len(speakerOrder)):
    speaker = speakerOrder[speakerIndex]
    if(currentSpeaker!=speaker):
        #If someone was already speaking add the time it ended
        if(currentSpeaker!=None):
            newSpeakerEnd.append(speakerEnd[speakerIndex-1])
        #Add the new Speaker
        newSpeakerOrder.append(speaker)
        currentSpeaker = speaker
        #Add the time it began
        newSpeakerBegin.append(speakerBegin[speakerIndex])

#Add the final time the last person stopped speaking
newSpeakerEnd.append(speakerEnd[-1])

print(newSpeakerOrder)
print(newSpeakerBegin)
print(newSpeakerEnd)

This is a solution I came up with, while not perfect it should solve your problem.
Just make sure beforehand that the original arrays have the same length.


问:
impossible to html parsing facebook public profile with php
i grabbed an html from this url : http://facebook.com/zuck
there is no problem to echo it to the client browser but i found it impossible to parse it with php.

i am trying to parse the text inside div tags for example :

```<code>preg_match_all("/<div class=\"mediaPageName\">(.*)<\/div>/",$html,$matches);
print_r($matches);
</code>```

returns empty array
i also tried with DOMDocument and with PHP Simple HTML DOM Parser both of them return empty elements and can't grab the text of the html.

how is it even possible?
there is a solution to that?

答:
```<code>$html = str_replace(array('\u003c','\"','\/'), array('<','"','/'), $html);
preg_match_all('/<div class=\"mediaPageName\">(.*?)<\/div>/', $html, $matches);
var_dump($matches);
</code>```

must be a way to do it with one single line of preg_match instead of the code above and also grab this tag text, but i don't know how to write it in a single line.

ContentLicense: CC BY-SA 3.0

Body:
i grabbed an html from this url : http://facebook.com/zuck
there is no problem to echo it to the client browser but i found it impossible to parse it with php.

i am trying to parse the text inside div tags for example :

preg_match_all("/
(.*)<\/div>/",$html,$matches);
print_r($matches);

returns empty array
i also tried with DOMDocument and with PHP Simple HTML DOM Parser both of them return empty elements and can't grab the text of the html.

how is it even possible?
there is a solution to that?

Body:
$html = str_replace(array('\u003c','\"','\/'), array('<','"','/'), $html);
preg_match_all('/<div class=\"mediaPageName\">(.*?)<\/div>/', $html, $matches);
var_dump($matches);

must be a way to do it with one single line of preg_match instead of the code above and also grab this tag <span class="fwb">text</span>, but i don't know how to write it in a single line.


问:
PineScript: Close a daytrade position at specific time of day
Using TradingView's Pinescript, how can I program a backtest strategy to (on 1 Day Bar Resolution):

1) Enter a long position at market open using a market order, if the previous day's close marked a buy condition. (the buy condition is, RSI (7) is above 50, MACD line is above signal line)

2) Place a stoploss at 1X the Average Day Range (14)

3) Place a sell order at 15:55:00 Eastern Time to close the whole position before market close.

4) The stoploss trigger cancels the other sell order, and vice versa (e.g. it's an OCO order)

5) Repeat every time buy condition is present after close.

In other words, with this strategy, I hope to enter a day trade at market open with a 1X ADR stoploss, and close the trade right before close.  This will avoid the after hours gaps.

Thanks for being generous with your time!

```<code>Edit:
here's what I have so far (as requested)
    //@version=4
    strategy("Trendability Strategy", overlay=true)
    [macdLine, signalLine, histLine] = macd(close, 12, 26, 9)
    rsiLine = rsi(close, 7)
    stochLine = sma(sma(stoch(close, high, low, 14),3),3)
    signal = histLine > -0.05 and rsiLine > 40 and stochLine > 40 ? "buy" :
    histLine <= -0.05 and rsiLine <= 40 and stochLine <= 40 ? "sell" : "none"
    palette = signal == "buy" ? color.lime : signal == "sell" ? color.red :
    color.black
    plotbar(open, high, low, close, color=palette)

    strategy.entry("Long", strategy.long, when = signal == "buy")
    strategy.close("Long", when = signal == "none")
</code>```

答:
I’m not sure if PineScript has this capability. I do have the python code from Quantopian. I’m not sure if it would be of any help. Most brokers have an option to close all positions (or some)for day traders, so I would think this would be pretty standard function.

```<code>def initialize(context):
    # Algorithm will call myfunc every day 15 minutes before the market closes
    schedule_function(
        myfunc,
        date_rules.every_day(),
        time_rules.market_close(minutes=15)
    )

def myfunc(context,data):
    pass

</code>```

Here is a sample from the user manual if you just want to avoid after-hours trading

```<code>strategy("closeEntry Demo", overlay=false)
strategy.entry("buy", true, when = open > close)
strategy.close("buy", when = open < close, qty_percent = 50, comment = "close buy entry for 50%")
plot(strategy.position_size)
</code>```

Body:
Using TradingView's Pinescript, how can I program a backtest strategy to (on 1 Day Bar Resolution):

1) Enter a long position at market open using a market order, if the previous day's close marked a buy condition. (the buy condition is, RSI (7) is above 50, MACD line is above signal line)

2) Place a stoploss at 1X the Average Day Range (14)

3) Place a sell order at 15:55:00 Eastern Time to close the whole position before market close.

4) The stoploss trigger cancels the other sell order, and vice versa (e.g. it's an OCO order)

5) Repeat every time buy condition is present after close.

In other words, with this strategy, I hope to enter a day trade at market open with a 1X ADR stoploss, and close the trade right before close.  This will avoid the after hours gaps.

Thanks for being generous with your time!

Edit:
here's what I have so far (as requested)
    //@version=4
    strategy("Trendability Strategy", overlay=true)
    [macdLine, signalLine, histLine] = macd(close, 12, 26, 9)
    rsiLine = rsi(close, 7)
    stochLine = sma(sma(stoch(close, high, low, 14),3),3)
    signal = histLine > -0.05 and rsiLine > 40 and stochLine > 40 ? "buy" :
    histLine <= -0.05 and rsiLine <= 40 and stochLine <= 40 ? "sell" : "none"
    palette = signal == "buy" ? color.lime : signal == "sell" ? color.red :
    color.black
    plotbar(open, high, low, close, color=palette)

    strategy.entry("Long", strategy.long, when = signal == "buy")
    strategy.close("Long", when = signal == "none")

Body:
I’m not sure if PineScript has this capability. I do have the python code from Quantopian. I’m not sure if it would be of any help. Most brokers have an option to close all positions (or some)for day traders, so I would think this would be pretty standard function.

def initialize(context):
    # Algorithm will call myfunc every day 15 minutes before the market closes
    schedule_function(
        myfunc,
        date_rules.every_day(),
        time_rules.market_close(minutes=15)
    )

def myfunc(context,data):
    pass

Here is a sample from the user manual if you just want to avoid after-hours trading

strategy("closeEntry Demo", overlay=false)
strategy.entry("buy", true, when = open > close)
strategy.close("buy", when = open < close, qty_percent = 50, comment = "close buy entry for 50%")
plot(strategy.position_size)


问:
How to replace Microsoft Edge Legacy with Edge Chromium?
I am facing issue while launching my selenium script for edge browser.
I followed below steps-
Pre-Condition- I had Edge Legacy-Version 40 already installed on my system
 1. Installed Edge Chromium Version LATEST-83...
 2. Ran the automation selenide script on edge browser, it downloaded and used web driver version 83....
 3. Our frameowrk is built like that it downloads the latest webDriver version at run time from github.bonagracia
 4. Edge Legacy was replaced by Edge Chromium post installation and I could not access Edge Legacy
 5. Due to some manual evaluation on my system, had to use Edge legacy  so un-installed Microsoft Edge Chromium, but could not proceed ahead much, because there was some configuration change to be done at system level
 6. Now, re-installed Microsoft edge chromium, but post re-installation I can access both Edge Legacy & Edge Chromium separately.
 7. The automation scripts is now taking edge legacy-Version 40.... as the browser instead of edge chromium-Version 83.0.. & downloading this version from github.bonagracia.

Alternative-
Tried to disable the edge legacy in system properties, as cannot uninstall this software, because it is by default installed with Windows 10, but still that does not work. Selenide script is still downloading edge legacy web driver during runtime instead of edge chromium.

How can I ensure that my Edge legacy is disabled post installation of edge chromium and automation script uses the web driver manager for edge chromium rather than edge legacy.

Please suggest on this.

答:
From your description, it seems that you will use the legacy version Edge and Microsoft Edge (Chromium version 83) version on the same machine. In this scenario, you could try to set the Edge driver directory path and the Edge browser's Binary Location when using selenium web driver.

To use the Legacy version Edge browser with Selenium web driver.

First, download the correct Microsoft WebDriver version.
Then, refer to the following code to assign the webDriver directory path.

```<code>        // the edge driver directory path: MicrosoftWebDriver.exe
        //var driverpath = @"C:\Windows\System32";
        var driverpath = @"C:\Windows\SysWOW64";
        //var driverpath = @"C:\Windows\WinSxS\wow64_microsoft-webdriver-server-components_31bf3856ad364e35_10.0.18362.1_none_cf827c8a6da82156";
        //var driverpath = @"C:\Windows\WinSxS\amd64_microsoft-webdriver-server-components_31bf3856ad364e35_10.0.18362.1_none_c52dd23839475f5b";

        using (var driver = new EdgeDriver(driverpath))
        {
            // Navigate to Bing
            driver.Url = "https://www.bing.com/";

            // Find the search box and query for webdriver
            var element = driver.FindElementById("sb_form_q");

            element.SendKeys("webdriver");
            element.SendKeys(Keys.Enter);
            driver.Quit();
        }
</code>```

To use the Microsoft Edge with Microsoft Edge webDriver.

First, download the correct Microsoft WebDriver version, then refer to the following code assign the Edge webDriver directory path the binary location.

```<code>        #pragma warning disable IDE0017 // Simplify object initialization
        EdgeOptions edgeOptions = new EdgeOptions();
        edgeOptions.UseChromium = true;
        #pragma warning restore IDE0017 // Simplify object initialization
        edgeOptions.BinaryLocation = @"C:\Program Files (x86)\Microsoft\Edge Dev\Application\msedge.exe";

        var msedgedriverDir = @"E:\webdriver\edgedriver_win64_84_0_502\edgedriver_win64"; //msedgedriver.exe
        var driver = new EdgeDriver(msedgedriverDir,edgeOptions);
        driver.Navigate().GoToUrl("https://www.google.com");
        Thread.Sleep(2000);
        driver.Close();
</code>```

[Note] Please remember to change the webdriver path and binary location to your owns. And in above sample, I'm using the C# selenium 4.0.0-alpha05 version.

Besides, here are some related articles might be is useful for you.

Access Microsoft Edge Legacy after installing the new version of Microsoft Edge

Use Microsoft Edge (Chromium) with WebDriver

Body:
From your description, it seems that you will use the legacy version Edge and Microsoft Edge (Chromium version 83) version on the same machine. In this scenario, you could try to set the Edge driver directory path and the Edge browser's Binary Location when using selenium web driver.

To use the Legacy version Edge browser with Selenium web driver.

First, download the correct Microsoft WebDriver version.
Then, refer to the following code to assign the webDriver directory path.

        // the edge driver directory path: MicrosoftWebDriver.exe
        //var driverpath = @"C:\Windows\System32";
        var driverpath = @"C:\Windows\SysWOW64";
        //var driverpath = @"C:\Windows\WinSxS\wow64_microsoft-webdriver-server-components_31bf3856ad364e35_10.0.18362.1_none_cf827c8a6da82156";
        //var driverpath = @"C:\Windows\WinSxS\amd64_microsoft-webdriver-server-components_31bf3856ad364e35_10.0.18362.1_none_c52dd23839475f5b";

        using (var driver = new EdgeDriver(driverpath))
        {
            // Navigate to Bing
            driver.Url = "https://www.bing.com/";

            // Find the search box and query for webdriver
            var element = driver.FindElementById("sb_form_q");

            element.SendKeys("webdriver");
            element.SendKeys(Keys.Enter);
            driver.Quit();
        }

To use the Microsoft Edge with Microsoft Edge webDriver.

First, download the correct Microsoft WebDriver version, then refer to the following code assign the Edge webDriver directory path the binary location.

        #pragma warning disable IDE0017 // Simplify object initialization
        EdgeOptions edgeOptions = new EdgeOptions();
        edgeOptions.UseChromium = true;
        #pragma warning restore IDE0017 // Simplify object initialization
        edgeOptions.BinaryLocation = @"C:\Program Files (x86)\Microsoft\Edge Dev\Application\msedge.exe";

        var msedgedriverDir = @"E:\webdriver\edgedriver_win64_84_0_502\edgedriver_win64"; //msedgedriver.exe
        var driver = new EdgeDriver(msedgedriverDir,edgeOptions);
        driver.Navigate().GoToUrl("https://www.google.com");
        Thread.Sleep(2000);
        driver.Close();

[Note] Please remember to change the webdriver path and binary location to your owns. And in above sample, I'm using the C# selenium 4.0.0-alpha05 version.

Besides, here are some related articles might be is useful for you.

Access Microsoft Edge Legacy after installing the new version of Microsoft Edge

Use Microsoft Edge (Chromium) with WebDriver


Title: Compare with next row repeatedly until criteria met in Pandas

Body:
I would like to filter a dataframe df:

            Id          Timestamp               Data    diff1
10856167    18675685    2010-03-01 05:58:15.520 25.0    0.0
10856168    18675686    2010-03-01 05:58:16.863 26.0    1.0
10856169    18675687    2010-03-01 05:58:18.203 30.5    4.5
10856170    18675688    2010-03-01 05:58:19.543 40.5    10.0
10856171    18675689    2010-03-01 05:58:20.877 42.0    1.5
10856172    18675690    2010-03-01 05:58:22.223 43.0    1.0
10856175    18675693    2010-03-01 05:58:41.127 42.5    -0.5
10856176    18675694    2010-03-01 05:58:42.503 42.0    -0.5
10856177    18675695    2010-03-01 05:58:49.313 42.5    0.5
10856178    18675696    2010-03-01 05:58:50.663 43.0    0.5
10856181    18675699    2010-03-01 05:59:01.443 43.5    0.5
10856182    18675700    2010-03-01 05:59:02.797 42.0    -1.5
10856183    18675701    2010-03-01 05:59:04.153 41.5    -0.5
10856184    18675702    2010-03-01 05:59:05.497 41.0    -0.5
10856185    18675703    2010-03-01 05:59:29.880 41.5    0.5
10856186    18675704    2010-03-01 05:59:31.220 42.0    0.5
10856191    18675709    2010-03-01 05:59:42.053 42.5    0.5
10856192    18675710    2010-03-01 05:59:43.407 43.0    0.5
10856193    18675711    2010-03-01 05:59:44.753 42.0    -1.0
10856218    18675736    2010-03-01 06:05:21.360 41.5    -0.5

by comparing df['Data'] of current row with the next  row. If the absolute difference between the values is greater than 1, keep the next row, which becomes the new current row; otherwise, remove the next row and compare with the following row until we find a row that satisfies the condition. I tried diff() and shift() but they only compare adjacent rows.

So expected output:

            Id          Timestamp               Data    diff1
10856167    18675685    2010-03-01 05:58:15.520 25.0    0.0

10856169    18675687    2010-03-01 05:58:18.203 30.5    4.5
10856170    18675688    2010-03-01 05:58:19.543 40.5    10.0
10856171    18675689    2010-03-01 05:58:20.877 42.0    1.5

10856181    18675699    2010-03-01 05:59:01.443 43.5    0.5
10856182    18675700    2010-03-01 05:59:02.797 42.0    -1.5

What is the best way to do this?

Update

Tried:

from numba import njit
@njit
def f(x, lim):
    total = x[0]
    result = np.empty(len(x), dtype=bool)
    result[0] = True
    for j,i in enumerate(x[1:], 1):
        if abs(total - i) <= lim:
            result[j] = False
        else:
            total = i
            result[j] = True

    return result

N = 1
df1 = sample[f(sample.Data.values, N)]
print(df1)

and caught error:

---------------------------------------------------------------------------
TypingError                               Traceback (most recent call last)
<ipython-input-15-db6a2b8a2896> in <module>
     16
     17 N = 1
---> 18 df1 = sample[f(sample.Data.values, N)]
     19 print(df1)

~/opt/anaconda3/lib/python3.7/site-packages/numba/core/dispatcher.py in _compile_for_args(self, *args, **kws)
    399                 e.patch_message(msg)
    400
--> 401             error_rewrite(e, 'typing')
    402         except errors.UnsupportedError as e:
    403             # Something unsupported is present in the user code, add help info

~/opt/anaconda3/lib/python3.7/site-packages/numba/core/dispatcher.py in error_rewrite(e, issue_type)
    342                 raise e
    343             else:
--> 344                 reraise(type(e), e, None)
    345
    346         argtypes = []

~/opt/anaconda3/lib/python3.7/site-packages/numba/core/utils.py in reraise(tp, value, tb)
     77         value = tp()
     78     if value.__traceback__ is not tb:
---> 79         raise value.with_traceback(tb)
     80     raise value
     81

TypingError: Failed in nopython mode pipeline (step: nopython frontend)
non-precise type array(pyobject, 1d, C)
[1] During: typing of argument at <ipython-input-15-db6a2b8a2896> (5)

File "<ipython-input-15-db6a2b8a2896>", line 5:
def f(x, lim):
    total = x[0]
    ^

Body:
I think numba is way how working with loops here if performance is important:

from numba import njit
@njit
def f(x, lim):
    total = x[0]
    result = np.empty(len(x), dtype=np.bool8)
    result[0] = True
    for j,i in enumerate(x[1:], 1):
        if abs(total - i) <= lim:
            result[j] = False
        else:
            total = i
            result[j] = True

    return result

N = 1
df1 = sample[f(sample.Data.values, N)]
print(df1)
                Id                Timestamp  Data  diff1
10856167  18675685  2010-03-01 05:58:15.520  25.0    0.0
10856169  18675687  2010-03-01 05:58:18.203  30.5    4.5
10856170  18675688  2010-03-01 05:58:19.543  40.5   10.0
10856171  18675689  2010-03-01 05:58:20.877  42.0    1.5
10856181  18675699  2010-03-01 05:59:01.443  43.5    0.5
10856182  18675700  2010-03-01 05:59:02.797  42.0   -1.5


问:
react Form.Control model/value mapping
just starting to use React and trying to create a simple page with an input and a button.

```<code>class Register extends React.Component  {
  constructor(props) {
    super(props);
    this.user = {};
  }
  register(user){
    console.log(user);
  }
  render() {
    return (
    ........
    <Form.Control type="email" placeholder="Email address" value={this.user.email}/>
    ........
    <Button onClick={ () => this.register(this.user)}> Sign Up </Button>
    )
  }
}
</code>```

I keep getting undefined when i tried to access {this.user.email}.
I'm coming from using Angular, so I've been used to using ng-model. What's the correct way to map the value so i can access it in the method 'register'?

答:
Input elements should be controlled components, they maintain their own state and that state is updated based on user input</p>

```<code>class Register extends React.Component  {
  constructor(props) {
    super(props);
    this.state = {
       email: '',
       password: ''
    };
  }

  onChangeHandler = (event) => {
      this.setState({ [event.target.name]: event.target.value });
  }

  render() {
    return (
    ........
    <Form.Control
        type="email"
        name="email"
        placeholder="Email address"
        value={this.state.email}
        onChange={this.onChangeHandler}
    />
    <Form.Control
        type="password"
        name="password"
        placeholder="Password"
        value={this.state.password}
        onChange={this.onChangeHandler}
    />
    ........
    )
  }
}
</code>```

Title: react Form.Control model/value mapping

Body:
just starting to use React and trying to create a simple page with an input and a button.

class Register extends React.Component  {
  constructor(props) {
    super(props);
    this.user = {};
  }
  register(user){
    console.log(user);
  }
  render() {
    return (
    ........
    <Form.Control type="email" placeholder="Email address" value={this.user.email}/>
    ........
    <Button onClick={ () => this.register(this.user)}> Sign Up </Button>
    )
  }
}

I keep getting undefined when i tried to access {this.user.email}.
I'm coming from using Angular, so I've been used to using ng-model. What's the correct way to map the value so i can access it in the method 'register'?

Body:
Input elements should be controlled components, they maintain their own state and that state is updated based on user input

class Register extends React.Component  {
  constructor(props) {
    super(props);
    this.state = {
       email: '',
       password: ''
    };
  }

  onChangeHandler = (event) => {
      this.setState({ [event.target.name]: event.target.value });
  }

  render() {
    return (
    ........
    <Form.Control
        type="email"
        name="email"
        placeholder="Email address"
        value={this.state.email}
        onChange={this.onChangeHandler}
    />
    <Form.Control
        type="password"
        name="password"
        placeholder="Password"
        value={this.state.password}
        onChange={this.onChangeHandler}
    />
    ........
    )
  }
}


问:
function for the sum of all even numbers
I wanted to create a function which take a string of any numbers and characters as a one parameter. the task is  to find all the even numbers(digits) and sum them up then display the total value in console.
for example, if the following string  is passed to this function as a one parameter ("112,sf34,4)-k)") the result should be :    The sum of  all even  numbers: 10

So far I have come with solution and solve after this. Help me. Thanks in advance.

```<code>function functionFive(str) {
    const string = [...str].map(char => {
        const numberString = char.match(/^\d+$/)
        if (numberString !== null){
            const number = parseInt(numberString)
            return number
        }

    const num = string.map(number=>{
        if (number !== undefined && number%2 === 0){
             console.log(number)
        }
    })
}
functionFive("sau213e89q8e7ey1")
</code>```

答:
Try this:</p>

```<code>   function functionFive(str){
     return  str.split('')
            .filter((el)=> !isNaN(el) && el % 2 === 0)
            .reduce((acc,cur)=> parseInt(acc) + parseInt(cur));
          }
       console.log(functionFive("112,sf34,4)-k"))
</code>```

Body:
I wanted to create a function which take a string of any numbers and characters as a one parameter. the task is  to find all the even numbers(digits) and sum them up then display the total value in console.
for example, if the following string  is passed to this function as a one parameter ("112,sf34,4)-k)") the result should be :    The sum of  all even  numbers: 10

So far I have come with solution and solve after this. Help me. Thanks in advance.

function functionFive(str) {
    const string = [...str].map(char => {
        const numberString = char.match(/^\d+$/)
        if (numberString !== null){
            const number = parseInt(numberString)
            return number
        }

    const num = string.map(number=>{
        if (number !== undefined && number%2 === 0){
             console.log(number)
        }
    })
}
functionFive("sau213e89q8e7ey1")

Body:
Try this:

   function functionFive(str){
     return  str.split('')
            .filter((el)=> !isNaN(el) && el % 2 === 0)
            .reduce((acc,cur)=> parseInt(acc) + parseInt(cur));
          }
       console.log(functionFive("112,sf34,4)-k"))


问:
How to retrieve Key Alias and Key Password for signed APK in android studio(migrated from Eclipse)
I have an android app currently published in Google Play which I update periodically. I follow the following process to sign the app before a new push:

Press right-mouse on the project, the 'Android tools' -> export signed application package
Provide keystore password
Sign your app
Upload the apk file into Google Play Developer Console

Recently I have imported the project from Eclipse to Android Studio and continued working on Android Studio. Now I am planning to push a fix in the app. I have figured that I have this option to sign apk in android studio

Build -> Generate Signed apk ->

As per my understanding, for my android app I have to use the same key store and key store password which I used earlier to push updates into Google Play. Also here it's asking for Key Alias and Key Password. I don't remember the Key Alias and Key password(number 4 input in the image) while signing apk in Eclipse. Any suggestion what can I do now? If I already know my keystore and keystore password, is there an way to retrieve the key alias and alias key password?

Update: Now I can retrieve my key alias through keytool -list -v -keystore name.keystore command

答:
I tried a lot of solves and only that work with me and i will share it with you

search by Ctrl + F


问:
Angular Material table matSort not working
I'm having troubles with my table

I fetch data and then pass it to my table

Here is my code:

html

```<code><div class="mainContainer">
  <div class="mat-elevation-z8 content">

  <mat-table
    class="mat-elevation-z3 productsTable"
    matSort
    mat-table
    [dataSource]="productsDataForTable">

    <ng-container matColumnDef="title">
      <mat-header-cell *matHeaderCellDef mat-sort-header>
        Title
      </mat-header-cell>
      <mat-cell *matCellDef="let row">
        {{row.name.en}}
      </mat-cell>
    </ng-container>

  <ng-container matColumnDef="image">
      <mat-header-cell *matHeaderCellDef>
        Image
      </mat-header-cell>
      <mat-cell *matCellDef="let prod; let i = index" >
        <img class="prodThumbnail" src={{prodsThumbnails[i]}} alt="Product thumbnail">
      </mat-cell>
    </ng-container>

    <ng-container matColumnDef="description">
      <mat-header-cell *matHeaderCellDef mat-sort-header>
        Description
      </mat-header-cell>
      <mat-cell *matCellDef="let prod">
        {{prod.description.en}}
      </mat-cell>
    </ng-container>

    <ng-container matColumnDef="weight">
      <mat-header-cell *matHeaderCellDef mat-sort-header>
        Weight
      </mat-header-cell>
      <mat-cell *matCellDef="let prod">
        {{prod.weight + ' ' + prod.weightUnit}}
      </mat-cell>
    </ng-container>

    <ng-container matColumnDef="SKU">
      <mat-header-cell *matHeaderCellDef mat-sort-header>
        SKU
      </mat-header-cell>
      <mat-cell *matCellDef="let prod">
        {{prod.sku}}
      </mat-cell>
    </ng-container>

    <ng-container matColumnDef="price">
      <mat-header-cell *matHeaderCellDef mat-sort-header>
        Price
      </mat-header-cell>
      <mat-cell *matCellDef="let prod">
        $ {{prod.prices[0].unitPrice}} {{prod.prices[0].currency}}
      </mat-cell>
    </ng-container>

    <ng-container matColumnDef="category">
      <mat-header-cell *matHeaderCellDef mat-sort-header>
        Category
      </mat-header-cell>
      <mat-cell *matCellDef="let prod">
        {{prod.category}}
      </mat-cell>
    </ng-container>

    <ng-container matColumnDef="status">
      <mat-header-cell *matHeaderCellDef mat-sort-header>
        Status
      </mat-header-cell>
      <mat-cell *matCellDef="let prod">
        {{prod.status}}
      </mat-cell>
    </ng-container>

    <ng-container matColumnDef="actions">
      <mat-header-cell *matHeaderCellDef>
        Actions
      </mat-header-cell>
      <mat-cell *matCellDef="let prod">
        <mat-icon class="actionOnProductButton" (click)="openProductDetailsDialog(prod)">create</mat-icon>
        <mat-icon class="actionOnProductButton" (click)="openDeleteProductDialog(prod)">delete</mat-icon>
      </mat-cell>
    </ng-container>

    <mat-header-row *matHeaderRowDef="tableHeaders"></mat-header-row>
    <mat-row
      class="table-rows"
      *matRowDef="let row; columns: tableHeaders;">

    </mat-row>

  </mat-table>

  </div>
</div>
</code>```

TS

```<code>import { Component, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute, Params } from '@angular/router';
import { Catalog } from '../../catalog';
import { MatPaginator } from '@angular/material/paginator';
import { MatTableDataSource } from '@angular/material/table';
import { MatSort } from '@angular/material/sort';
import { MatSnackBar } from '@angular/material/snack-bar';
import { ProductsService } from '../../products.service';
import { EnvironmentConfigService } from 'src/app/manufacturer/environment-config.service';

@Component({
  selector: 'app-catalog-details',
  templateUrl: './catalog-details.component.html',
  styleUrls: ['./catalog-details.component.scss']
})
export class CatalogDetailsComponent implements OnInit {

  catalogID: string;
  productsFetched: any;

  // For product thumbnail in table
  prodsThumbnails = [];

  // Data for products table
  productsDataForTable: MatTableDataSource<[]>;
  tableHeaders = [
    'image',
    'title',
    'description',
    'weight',
    'SKU',
    'price',
    'category',
    'status',
    'actions'
  ];

  @ViewChild(MatSort, {static: true}) sort: MatSort;

  constructor(
    private envService: EnvironmentConfigService,
    private prodsService: ProductsService,
    private snackBar: MatSnackBar,
    public dialog: MatDialog,
    private formBuilder: FormBuilder,
    private route: ActivatedRoute,
    private catService: CatalogsService
  ) { }

  ngOnInit(): void {
    this.route.params.subscribe((params: Params) => {
      this.getProducts(params.id);
    });
  }

  getProducts(id: string) {
    this.prodsService.getProducts(id)
    .subscribe((prods: any) => {
      this.prodsThumbnails = [];
      for (const prod of prods) {
        if (prod && prod.images && prod.images.length > 0 && prod.images[0].path && prod.images[0].path !== '') {
          const src = `${this.envService.getEnvService().getBackendUrl()}/${prod.images[0].path}`;
          this.prodsThumbnails.push(src);
        } else {
          this.prodsThumbnails.push('../../../../assets/images/placeholder-img.png');
        }
      }
      this.productsFetched = prods;
      this.productsDataForTable = new MatTableDataSource(prods);
      this.productsDataForTable.sort = this.sort;
    },
    err => {
      console.log('Error fetching products');
      this.openSnackBar('Error getting porducts data', 'Ok');
    });
  }

  openSnackBar(message: string, action: string) {
    this.snackBar.open(message, action, {
      duration: 2000,
    });
  }

}
</code>```

The table was with *ngIf and i read that a matTable shouldn't has that because the @ViewChild(MatSort, {static: true}) sort: MatSort would be undefined so i erased an *ngIf that I was actually using but I still cant achieve the sorting.

I tried matPagination feature too without success, I suppose it is due to the same error.

I'll appreciate any help

答:
Please try to add the MatSortModule to your module.</p>

```<code>import {MatSortModule} from '@angular/material/sort';

imports: [
    BrowserModule,
    ...
    MatTableModule,
    MatSortModule
],
</code>```

Body:
I'm having troubles with my table

I fetch data and then pass it to my table

Here is my code:

html

  <mat-table
    class="mat-elevation-z3 productsTable"
    matSort
    mat-table
    [dataSource]="productsDataForTable">

    <ng-container matColumnDef="title">
      <mat-header-cell *matHeaderCellDef mat-sort-header>
        Title
      </mat-header-cell>
      <mat-cell *matCellDef="let row">
        {{row.name.en}}
      </mat-cell>
    </ng-container>

  <ng-container matColumnDef="image">
      <mat-header-cell *matHeaderCellDef>
        Image
      </mat-header-cell>
      <mat-cell *matCellDef="let prod; let i = index" >

      </mat-cell>
    </ng-container>

    <ng-container matColumnDef="description">
      <mat-header-cell *matHeaderCellDef mat-sort-header>
        Description
      </mat-header-cell>
      <mat-cell *matCellDef="let prod">
        {{prod.description.en}}
      </mat-cell>
    </ng-container>

    <ng-container matColumnDef="weight">
      <mat-header-cell *matHeaderCellDef mat-sort-header>
        Weight
      </mat-header-cell>
      <mat-cell *matCellDef="let prod">
        {{prod.weight + ' ' + prod.weightUnit}}
      </mat-cell>
    </ng-container>

    <ng-container matColumnDef="SKU">
      <mat-header-cell *matHeaderCellDef mat-sort-header>
        SKU
      </mat-header-cell>
      <mat-cell *matCellDef="let prod">
        {{prod.sku}}
      </mat-cell>
    </ng-container>

    <ng-container matColumnDef="price">
      <mat-header-cell *matHeaderCellDef mat-sort-header>
        Price
      </mat-header-cell>
      <mat-cell *matCellDef="let prod">
        $ {{prod.prices[0].unitPrice}} {{prod.prices[0].currency}}
      </mat-cell>
    </ng-container>

    <ng-container matColumnDef="category">
      <mat-header-cell *matHeaderCellDef mat-sort-header>
        Category
      </mat-header-cell>
      <mat-cell *matCellDef="let prod">
        {{prod.category}}
      </mat-cell>
    </ng-container>

    <ng-container matColumnDef="status">
      <mat-header-cell *matHeaderCellDef mat-sort-header>
        Status
      </mat-header-cell>
      <mat-cell *matCellDef="let prod">
        {{prod.status}}
      </mat-cell>
    </ng-container>

    <ng-container matColumnDef="actions">
      <mat-header-cell *matHeaderCellDef>
        Actions
      </mat-header-cell>
      <mat-cell *matCellDef="let prod">
        <mat-icon class="actionOnProductButton" (click)="openProductDetailsDialog(prod)">create</mat-icon>
        <mat-icon class="actionOnProductButton" (click)="openDeleteProductDialog(prod)">delete</mat-icon>
      </mat-cell>
    </ng-container>

    <mat-header-row *matHeaderRowDef="tableHeaders"></mat-header-row>
    <mat-row
      class="table-rows"
      *matRowDef="let row; columns: tableHeaders;">

    </mat-row>

  </mat-table>

TS

import { Component, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute, Params } from '@angular/router';
import { Catalog } from '../../catalog';
import { MatPaginator } from '@angular/material/paginator';
import { MatTableDataSource } from '@angular/material/table';
import { MatSort } from '@angular/material/sort';
import { MatSnackBar } from '@angular/material/snack-bar';
import { ProductsService } from '../../products.service';
import { EnvironmentConfigService } from 'src/app/manufacturer/environment-config.service';

@Component({
  selector: 'app-catalog-details',
  templateUrl: './catalog-details.component.html',
  styleUrls: ['./catalog-details.component.scss']
})
export class CatalogDetailsComponent implements OnInit {

  catalogID: string;
  productsFetched: any;

  // For product thumbnail in table
  prodsThumbnails = [];

  // Data for products table
  productsDataForTable: MatTableDataSource<[]>;
  tableHeaders = [
    'image',
    'title',
    'description',
    'weight',
    'SKU',
    'price',
    'category',
    'status',
    'actions'
  ];

  @ViewChild(MatSort, {static: true}) sort: MatSort;

  constructor(
    private envService: EnvironmentConfigService,
    private prodsService: ProductsService,
    private snackBar: MatSnackBar,
    public dialog: MatDialog,
    private formBuilder: FormBuilder,
    private route: ActivatedRoute,
    private catService: CatalogsService
  ) { }

  ngOnInit(): void {
    this.route.params.subscribe((params: Params) => {
      this.getProducts(params.id);
    });
  }

  getProducts(id: string) {
    this.prodsService.getProducts(id)
    .subscribe((prods: any) => {
      this.prodsThumbnails = [];
      for (const prod of prods) {
        if (prod && prod.images && prod.images.length > 0 && prod.images[0].path && prod.images[0].path !== '') {
          const src = `${this.envService.getEnvService().getBackendUrl()}/${prod.images[0].path}`;
          this.prodsThumbnails.push(src);
        } else {
          this.prodsThumbnails.push('../../../../assets/images/placeholder-img.png');
        }
      }
      this.productsFetched = prods;
      this.productsDataForTable = new MatTableDataSource(prods);
      this.productsDataForTable.sort = this.sort;
    },
    err => {
      console.log('Error fetching products');
      this.openSnackBar('Error getting porducts data', 'Ok');
    });
  }

  openSnackBar(message: string, action: string) {
    this.snackBar.open(message, action, {
      duration: 2000,
    });
  }

}

The table was with *ngIf and i read that a matTable shouldn't has that because the @ViewChild(MatSort, {static: true}) sort: MatSort would be undefined so i erased an *ngIf that I was actually using but I still cant achieve the sorting.

I tried matPagination feature too without success, I suppose it is due to the same error.

I'll appreciate any help

Body:
Please try to add the MatSortModule to your module.

import {MatSortModule} from '@angular/material/sort';

imports: [
    BrowserModule,
    ...
    MatTableModule,
    MatSortModule
],


Body:
i = 0
for row in range(2, len(df)):
    i += 1
    if i <= len(df) - 1:
        if -1 <= df.iloc[i,:]['Data'] - df.iloc[i-1,:]['Data'] <= 1:
            df.iloc[i,3] = ''
df.loc[df['diff1'] == '',:] = ''

Output:

            Id          Timestamp               Data diff1
10856167    18675685    2010-03-01 05:58:15.520 25   0
10856168
10856169    18675687    2010-03-01 05:58:18.203 30.5 4.5
10856170    18675688    2010-03-01 05:58:19.543 40.5 10
10856171    18675689    2010-03-01 05:58:20.877 42   1.5
10856172
10856175
10856176
10856177
10856178
10856181
10856182    18675700    2010-03-01 05:59:02.797 42  -1.5
10856183
10856184
10856185
10856186
10856191
10856192
10856193
10856218    18675736    2010-03-01 06:05:21.360 41.5 -0.5