Vis.js group background styling - css

I have a Vis.js timeline in an Angular5 project with three groups and multiple items/events in each. I figured out how to style each group background individually to make the alternating swim lanes more distinct, by doing:
.vis-background>.vis-group:nth-of-type(even) {
// there is an auto-generated empty group as the first .vis-group, so starting with the 2nd group
background-color: $gray-lighter;
}
.vis-labelset>.vis-label:nth-of-type(odd) {
background-color: $gray-lighter;
}
However, the vertical background grid lines are no longer visible in the groups that are colored gray. It's as if the group background color is layered on top of the grid lines. If I add a z-index: 1; to .vis-vertical or .vis-grid the lines and group color appear correctly, but I lose timeline zooming and movement functionality. How can I apply styling to groups, keep the vertical grid lines visible and also keep all timeline functionality?

A workaround I used that not resolves the problem, but made it less notorious, was define the group like this:
group=
{
id : 0,
content : 'My Group',
style : "background: rgba(82, 226, 233, 0.2);"
};
and define a background item like this
background_item=
{
group : 0,
start : '2018-10-29 00:00',
end : '2018-10-30 02:00',
type : 'background',
className : 'myClassName'
};
where the className come from this style:
.vis-item.vis-background.myClassName {
background-color: rgba(82, 226, 233, 0.2);
}
It uses transparency to prevent hide the vertical lines.
The result was something like this:
Hope it helps while someone found a definitive solution.

Related

Add border to MUI DataGrid Row

im trying to style Material UI DataGrid rows to have borders, something close to this screenshot (I censored some information, but u get the idea)
The problem I have is that I can't get the right border to appear ( codesandbox below )
So far I tryied to style the global class .MuiDataGrid-row with border: 1, all borders except the right are being applied, I don't understand why.
Also with this approach, the first row have double bottom border because the second row top border is overlapping and it looks weird, if u can give me a hand with that too would be great!
There are two methods
METHOD 1: (simple)
Add showCellRightBorder={true} to your Datagridcomponent
METHOD 2: (provides customization)
Add the following css to your sx prop of Datagrid Component..
CODE TO BE REMOVED:
// "& .MuiDataGrid-row": {
// borderTop: 1,
// borderBottom: 0
// },
CODE TO BE ADDED:
"& .MuiDataGrid-cell": {
border: 1,
borderRight: 0,
borderTop: 0,
// add more css for customization
},

vis.js timeline set custom background color on items without overwriting borders

I'm using vis.js timeline and I'm trying to find a way to mark workhours (give them a different background). Using the backgrundareas with groups example I have managed to get my workhours colored for specific dates.
I do not want to use the standard blue color for background, so in order to avoid this I add a class workhours. Then I can set my custom color, but then the borders of the cells are hidden unless I also set a opacity less than 1.
I have a color scheme which I'm using, so setting opacity changes the color and my workhours does not look the same in the whole application.
I'm using this code
.vis-item.vis-background.workhours {
background: ##AFD9FE;
opacity: 0.75;
}
and where filterFromdate is my start date, durationDay is numbers of days in my timeline and startHour and endHour defines my working hours
for (i=0; i<durationDays; i++) {
items.add([
{
id: "W"+i,
start: moment(filterFromdate).add(i, 'days').hour(startHour).valueOf(),
end: moment(filterFromdate).add(i, 'days').hour(dayEndHour).valueOf(),
className : 'workhours',
type: "background"
}
]);
}
this give me
Can anyone tell me how to either get my class workhours to behave like a standard vis background class (like vis-today)?
or if there is another approach to handle background on specific hours (or days)?
Thanks to Issue 3773 I reliased that I could set the z-index, which did the trick.
So my css ended up being
.vis-item.vis-background.workhours {
background: #AFD9FE;
z-index: -1;
}

How to set color, width and draw dashed line simultaneously for javafx line?

I have to draw multiple lines using javafx line chart. Since one line can overlap other lines. I want to use dashed line or line with different thickness to represent each line.
Below is my code snippet:-
for (XYChart.Series<Number, Number> s : chart.getData()) {
// Used for Line color
if (("Current Threshold").equals(s.getName())) {
s.getNode().setStyle(" -fx-stroke-width: 10; ");
s.getNode().setStyle("-fx-stroke: #00FF00; ");
s.getNode().setStyle("-fx-stroke-dash-array: 2 12 12 2; ");
}
else if(some condition)
{
// Some other condition to draw other lines
}
}
where chart is instance of LineChart.
Node.setStyle() methods override each other. I am unable to set multiple style together. Last style persists and others are overridden. ie for above sequence, dashed line is drawn. I am using css styles in java code.
Is there any way to apply multiple style, without overriding others.
Thanks
Node.setStyle() is, as the name should suggest, a setter method for the style attribute of a JavaFX Node.
By calling this method three times in a row, only the last invocation has an effect as the previous ones get overwritten.
So if you want to apply all three styles you should write:
node.setStyle("-fx-stroke-width: 10; -fx-stroke: #00FF00; -fx-stroke-dash-array: 2 12 12 2;");
Or even better, use a CSS File, see this answer for further reference: JavaFX Text styling for dynamic objects

Background colour of child indicator in QTreeWidgetItem?

I'm using a QTreeWidget to show a list of categorized properties. I would like the top level items to be a different background colour; however, the arrow indicating it has children is always the default black on white (Windows 8.1, Qt 5.2.1). Here's how I'm adding the QTreeWidget Item:
QBrush fg(Qt::white);
QBrush bg(Qt::darkGray);
QTreeWidgetItem *header = new QTreeWidgetItem();
header->setText(0, "Sound File");
this->addTopLevelItem(header);
header->setFirstColumnSpanned(true);
header->setData(0, Qt::ForegroundRole, fg);
header->setData(0, Qt::BackgroundRole, bg);
header->setExpanded(true);
Here's a screenshot of how this gets rendered.
How can I give it a solid background across the whole row?
For the indicators you can use StyleSheets something like this:
QTreeWidget::branch::!has-children:selected {background-color: rgb(255, 255, 255);}
QTreeWidget::branch::!has-children:selected:alternate {background-color: rgb(0, 0, 0);}
and set this StyleSheet to the QTreeWidget..
If someone knows any other way to do this for the individual items feel free to share... I have similar situation where I was one of the item that have children to be different color..

Is it possible to "tint" a button in JavaFX 2

I have a JavaFX 2 application, where all my buttons use the default style (grey gradient). In some special areas of the application, the background color is red, yellow or green. In these areas, I also have buttons.
Instead of re-styling all the different states (normal, hover, pressed) of the button in all three colors, I'd like to just give the button the tint of the background. Is this possible, and how?
If not, is there a way to easily re-style the base button style, and have the hover and pressed states (pseudo-selectors) automatically derived from this style?
If that's not possible, I'm open for suggestions.. My most important goal is to avoid redundant/duplicate declarations (especially of gradients), in case someone wants to add a different color panel later, or just change the shade of one of the background colors.
CSS for the red panel/button:
#my-red-panel {
-fx-border-width: 1;
-fx-border-radius: 5;
-fx-background-radius: 5;
-fx-smooth: true;
-fx-border-color: rgb(209, 65, 42);
-fx-background-color: rgba(255, 78, 50, 0.89);
}
#my-red-panel .button {
-fx-background: rgba(0, 0, 0, 0); /* Now borders look good, but button is still grey*/
}
My best bet so far, is to use a semi-transparent gradient, like so:
#my-red-panel .button {
-fx-background-color: linear-gradient(rgba(255, 255, 255, 0.3), rgba(0, 0, 0, 0.2));
}
I still have to declare each state, but at least I can change the underlying colors without having to modify each state. The main problem is that this overrides the entire look of the button, so I was hoping for something better... :-/
Not tested, but try experimenting with:
#my-red-panel {
-fx-base: rgba(255, 78, 50, 0.89);
}
or perhaps:
#my-red-panel .button {
-fx-base: ... ;
}
depending on the exact effects you want.
The trick here is that the default css (caspian.css for JavaFX2.2 or modena.css for JavaFX8) use some pre-defined lookup colors. You can dig out the source for these to see how they are used. If you redefine these lookups for a node in the scene graph, the new definition is propagated to all child nodes.

Resources