White line appears across top of page - background-color

I want a solid background color across all of the page. I get a white line across the top of the page. What do I need to do to get the whole page one color?
import Html exposing (..)
import Html.Attributes exposing(..)
mainStyle =style[ ( "background-color", "#ff44aa" )]
main=body[mainStyle][div[] [h5[][text"waah"]]]

Your code results in HTML with two bodies. You could instead use CSS to specify the style of the body and then just use:
main =
div[] [h5[][text"waah"]]

This works in providing a solid background color:
import Html exposing (..)
import Html.Attributes exposing(..)
mainStyle =style[ ( "background-color", "#ff44aa" )
,( "height", "100vh")
,( "margin", "0px")
]
main=
div[] [h5[mainStyle][text"waahaa"]]

Related

Is there a way to display the value of a mark next to the mark in Altair

I was playing around with the following example from the Altair Gallery:
https://altair-viz.github.io/gallery/airports_count.html
As of right now, the only way to display the actual count appears to be via the tooltip, as the example shows. However, I am trying to code a static visualization for which it would be very helpful if the exact value was displayed right next to the mark itself, without the user having to hover or interact in any way. Is there a way to achieve this?
You can do this by manually calculating offsets for text labels, though this is admittedly difficult when the points become crowded:
import altair as alt
from vega_datasets import data
airports = data.airports.url
states = alt.topo_feature(data.us_10m.url, feature='states')
# US states background
background = alt.Chart(states).mark_geoshape(
fill='lightgray',
stroke='white'
).properties(
width=500,
height=300
).project('albersUsa')
# airport positions on background
base = alt.Chart(airports).transform_aggregate(
latitude='mean(latitude)',
longitude='mean(longitude)',
count='count()',
groupby=['state']
).encode(
longitude='longitude:Q',
latitude='latitude:Q',
)
points = base.mark_circle().encode(
size=alt.Size('count:Q', title='Number of Airports'),
color=alt.value('steelblue'),
tooltip=['state:N','count:Q']
).properties(
title='Number of airports in US'
)
text = base.mark_text(
dx=15, dy=10
).encode(
text='count:Q'
)
background + points + text
Long-term, a better solution will be to use vega-label, which will be able to do this automatically once it's part of the Vega-Lite package. For Altair, this feature is tracked in this bug: https://github.com/altair-viz/altair/issues/1731

Altair interactive plots become static on touch screen devices

I made an Altair interactive plot which contains several subplots with cross-filtering and save it as an html file.
When opened on computer browsers, everything works fine. But on my phone and tablet, the plot becomes static (both Android Chrome and Firefox).
Is there a way to make it work on these platforms?
Reproducible code
import altair as alt
from vega_datasets import data
cars = data.cars()
interval = alt.selection_interval()
base = alt.Chart(cars).mark_point().encode(
y='Horsepower',
color=alt.condition(interval, 'Origin', alt.value('lightgray')),
tooltip='Name'
).add_selection(
interval
)
hist = alt.Chart(cars).mark_bar().encode(
x='count()',
y='Origin',
color='Origin'
).properties(
width=800,
height=80
).transform_filter(
interval
)
scatter = base.encode(x='Miles_per_Gallon') | base.encode(x='Acceleration')
chart = scatter & hist
chart.display(renderer='svg')
chart.save('chart.html', scale_factor=3)
<iframe src="https://chart.tiiny.site/" style="width: 100%; height: 1000px;">
</iframe>
This is an open issue in Vega-Lite, the library used to render Altair charts: https://github.com/vega/vega-lite/issues/4661
That issue has a few suggestions for workarounds related to interactions via touchscreens, but there is not yet any full solution to your question.

Is there a way to make a bubble plot in Altair which has circles that aren't filled?

I am trying to develop a new data visualization/graphic, and the bubble plot available here is very similar to what I am trying to make in shape:
https://altair-viz.github.io/gallery/table_bubble_plot_github.html
However, the graph I am trying to make involves some shaded bubbles and some filled in. Is there a way to edit this graph so that the bubble marks are not always filled?
Thank you!
You could use the fillOpacity encoding linked to a field in your data and then set the domain and range of its scale, so that only the values you want have a completely transparent fill:
import altair as alt
from vega_datasets import data
source = data.github.url
fill_threshold = 12
alt.Chart(source).mark_circle(
stroke='black'
).encode(
x='hours(time):O',
y='day(time):O',
size='sum(count):Q',
fillOpacity=alt.FillOpacity(
'sum(count):Q',
scale=alt.Scale(
domain=[fill_threshold, fill_threshold + 0.01],
range=[0 ,1]
)
)
)
You can use the fillOpacity and stroke mark properties to make the marks into circles with no fill. For example:
import altair as alt
from vega_datasets import data
source = data.github.url
alt.Chart(source).mark_circle(
fillOpacity=0,
stroke='black'
).encode(
x='hours(time):O',
y='day(time):O',
size='sum(count):Q',
)

How can i set min-width size for my sub-window in Vaadin?

In my Vaadin code I want to add min-width feature to my sub-window.
I set width of my subwindow size %25 of my mainwindow, but I don't want it to be very small.I want it at least "125px". How can i set this with java code?
public class Awindow extends Window{
...
public Awindow(...)
setModal(true);
setCaption("Hello");
this.setHeight("100%");
this.setWidth("25%");// I don't want it to be %25 all the time,I want it to remain still after "150px".
VerticalLayout layout = new VerticalLayout (
memberTable,
new HorizontalTable(
createButton,
eraseButton)
);
layout.setSpacing(true);
...
this.setContent(layout);
The only possible solution i know is to make it with css.
You can add a css for the .v-window class eg:
.v-window {
min-width: 125px !important;
}
If you want fully programically
1) add your css style to page style with programmically
UI.getCurrent().getPage().getStyles().add(".min125px{min-width: 125px !important;}");
2) add this style (min125px) to your buttons
createButton.addStyleName("min125px");
eraseButton.addStyleName("min125px");
As long as https://github.com/vaadin/framework/issues/1360 is not implemented by Vaadin, you might want to check out the following add-on: https://vaadin.com/directory#!addon/restrain. This does essentially the same as proposed by the other answers, but has a nice server side api.
E.g.:
new Restrain(component).setMinWidth("125px");

PyQt : give a color to all the textof an application

I would like to change the look of my application in PyQt. I want all the text (in the buttons, labels and such) to be white for exampel, and all the buttons to be a certain color.
Can I change that all at once in the mainWindow ?
I did the following to change the background color of the whole app:
self.setStyleSheet("QMainWindow {background-color: #252526; color: #FFFFFF}")
If I set another stylesheet for the QPushButton for example in the same manner, the style for the QMainWindow will be overridden.
You could call the setStyleSheet() method on your QApplication instance and specify all object names in the CSS string:
app = QtGui.QApplication.instance()
app.setStyleSheet('QLabel{color: #fff;} QPushButton{background-color: #000; color: #fff}')

Resources