mercredi 3 mars 2021

How to update a seaborn line plot with ipywidgets checkboxes?

I am struggling with the ipywidgets module.

I am trying to make a plot where you can toggle lines off/on with checkboxes based on a province.

enter image description here

fig, ax = plt.subplots(figsize=(10,10))
sns.lineplot(data=df5, x="Date_of_report", y="Total_reported", hue="Province", ax=ax)
provinces = df5["Province"].unique()
chk = [widgets.Checkbox(description=a) for a in provinces]
def updatePlot(**kwargs):
    print([(k,v) for k, v in kwargs.items()])

widgets.interact(updatePlot, **{c.description: c.value for c in chk})

As you can see, I can draw the checkboxes and it prints out the status of the boxes. but I don't know how to update the seaborn line plot. So when you select say: Drenthe it only shows the line from Drenthe.

enter image description here

here is the dataframe as a dict:

{'Date_of_report': {0: Timestamp('2020-03-13 10:00:00'), 1: Timestamp('2020-03-13 10:00:00'), 2: Timestamp('2020-03-13 10:00:00'), 3: Timestamp('2020-03-13 10:00:00'), 4: Timestamp('2020-03-13 10:00:00'), 5: Timestamp('2020-03-13 10:00:00'), 6: Timestamp('2020-03-13 10:00:00'), 7: Timestamp('2020-03-13 10:00:00'), 8: Timestamp('2020-03-13 10:00:00'), 9: Timestamp('2020-03-13 10:00:00')}, 'Province': {0: 'Drenthe', 1: 'Flevoland', 2: 'Friesland', 3: 'Gelderland', 4: 'Groningen', 5: 'Limburg', 6: 'Noord-Brabant', 7: 'Noord-Holland', 8: 'Overijssel', 9: 'Utrecht'}, 'Total_reported': {0: 14, 1: 7, 2: 8, 3: 64, 4: 4, 5: 71, 6: 377, 7: 66, 8: 18, 9: 83}, 'Hospital_admission': {0: 0, 1: 3, 2: 2, 3: 9, 4: 1, 5: 17, 6: 65, 7: 4, 8: 0, 9: 7}, 'Deceased': {0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 3, 6: 5, 7: 0, 8: 0, 9: 0}}




How to fetch different checkboxes values on form

formImage

There are 2checkboxes div here.. one is for Quarter and other having title "Forms to be amended(check each that apply) **for SUI & SWH, you must enter state code"

I want to check separately for each checkbox. Meaning when a check box from Quarter is selected then I want value of only those. When SUI/SWH,etc. are checked then I want to retrieved values of those..

How can I fetch values separately for each?




mardi 2 mars 2021

How to customize a checkbox checkmark? [duplicate]

I am trying to change the checkmark of an input checkbox. Basically, I would like to display - instead of v inside the input when checked.

I know I should play with :before pseudo elements and display a "-" in the content key, but I can't achieve a proper result. If possible, I would like to keep things very simple with a classic input, and no custom input above a hidden one.

I have this html/css for the moment:

<input type="checkbox"/>

input{
  position:relative;
&:before{
  content: '-';
  background:black;
  }
}

How would you fix this?




Using checkboxes to disable/enable histograms

I am writing code to analyse the musical taste of me and 3 of my friends in python. Using spotipy, we extracted the song info of our '2020 most played' playlists in spotify. The data of these 4 playlists are stored in a dataframe.

First, i defined the data out of the dataframe that i want to use for the histograms.

user1_tempo = trainingData[trainingData['user'] == 'user1']['tempo']
user2_tempo = trainingData[trainingData['user'] == 'user2']['tempo']
user3_tempo = trainingData[trainingData['user'] == 'user3']['tempo']
user4_tempo = trainingData[trainingData['user'] == 'user4']['tempo']

After that, I made 4 histograms on top of each other so I can compare the results.

plt.title("Song Tempo per person")
user1_tempo.hist(alpha=0.5, bins=30, label='Me')
user2_tempo.hist(alpha=0.5, bins=30, label='Friend 1')
user3_tempo.hist(alpha=0.5, bins=30, label='Friend 2')
user4_tempo.hist(alpha=0.5, bins=30, label='Friend 3')

plt.xticks(np.arange(0,220, 10))
plt.legend(loc='upper right')

Of course, 4 histograms into each other look very messy. It looks like this

Is there a way to temporary disable some of the plots with checkboxes?




css - RShiny widgets: How to color the radioButtons() and checkboxGroupInput()?

I'm using many different checkboxGroupInput() and radioButtons() in my RShiny app, one code snippet looks like this:

checkboxGroupInput(inputId = "maDays", label = "Select Trading Days", 
                                      choices = c("Monday", "Tuesday", "Wednesday", "Thursday",
                                                  "Friday", "Saturday", "Sunday"),
                                      selected = c("Monday", "Tuesday", "Wednesday", "Thursday",
                                                   "Friday"), 
                                      inline = TRUE),
radioButtons(inputId = "maTimeGran", label = "Select Time Granularity", 
                                choices = c("Hourly" = "hour", "Daily" = "day", 
                                            "Weekly" = "week"),
                                selected = "day")

and gives:

enter image description here enter image description here

Now my question is: How can I change the coloring of all my radioButtons and checkboxxes (the selected checkboxes or radiobuttons) with a css-tag? My preferred color would be #007d3c.




lundi 1 mars 2021

Change Src with Radio Buttton's Multiple Check

I want to change iosSrc related to radio buttons. Here is the codes below but it is not working properly. I think there is a problem on my && parts. Any help or suggestions would be great. Thanks.`

https://jsfiddle.net/qt08r4x3/




disable option of required in webform in drupal 7

My function:

     function _custom_get_ublox_communication_checkbox_form_element() {
  return array(
    '#type' => 'checkboxes',
    '#title' => t('Communications'),
    '#options' => array(
      1 => t('I consent to retaining my personal data for the purposes of receiving personalized marketing materials, offers, invitations to webinars and other similar events. To learn more, read our <a )),
    ),

    '#required' => TRUE,
  );
}

This checkbox is mandatory as there is option '#required' => TRUE, but after removing the required option it is not even removing the required(*) check from the field. Can anyone please help me on this? Thanks in advance