I´m trying to customize my legend
I´m using the .generateLegend() to get the legend in a html way
this is what the function gave me
console.log(myBarChart.generateLegend());
<ul class="1-legend"><li><span style="background-color:#006666"></span>SECRETARIA MUNICIPAL DE DESENVOLVIMENTO URBANO </li>
<li><span style="background-color:#339966"></span>SECRETARIA MUNICIPAL DE SAUDE</li>
<li><span style="background-color:#3366ff"></span>SETOR DE RH</li>
<li><span style="background-color:#66ccff"></span>SECRETARIA MUNICIPAL DE CULTURA, TURISMO, ESPORTE E LAZER </li>
<li><span style="background-color:#ffcc66"></span>SETOR DE CADASTRO DE IMOVEIS</li>
<li><span style="background-color:#ff6666"></span>SECRETARIA MUNICIPAL DE DESENVOLVIMENTO ECONÔMICO, TRABALHO E MEIO AMBIENTE</li>
<li><span style="background-color:#994d00"></span>SETOR AGILIZA</li></ul>
Even the span style has the background color it shows this way in page:
SECRETARIA MUNICIPAL DE DESENVOLVIMENTO URBANO
SECRETARIA MUNICIPAL DE SAUDE
SETOR DE RH
SECRETARIA MUNICIPAL DE CULTURA, TURISMO, ESPORTE E LAZER
SETOR DE CADASTRO DE IMOVEIS
SECRETARIA MUNICIPAL DE DESENVOLVIMENTO ECONÔMICO, TRABALHO E MEIO AMBIENTE
SETOR AGILIZA
How can i show the color passed in the span style tag in the HTML?
I tried to make this way too but i can´t understand how to get it work (Custom Legend with ChartJS v2.0)
Thx for your time!
UPDATE 1
As #Quince pointed i need to change the '1-legend' that the function gave to me
To remove the 1-legend of class name i used
var s = myBarChart.generateLegend().replace(/\"1-legend"/g, 'legend');
This can be achieved through some css. First thing though you css class 1-legend is not valid, css class names can not start with a number (good explanation on what is allowed here)
But once that is fixed you can just style the spans how you want to dispaly here is an example
.legend {
list-style: none;
}
.legend li span {
width: 10px;
height: 10px;
display: inline-block;
margin-right: 10px;
border-radius: 10px;
}
<ul class="legend">
<li><span style="background-color:#006666"></span>SECRETARIA MUNICIPAL DE DESENVOLVIMENTO URBANO </li>
<li><span style="background-color:#339966"></span>SECRETARIA MUNICIPAL DE SAUDE</li>
<li><span style="background-color:#3366ff"></span>SETOR DE RH</li>
<li><span style="background-color:#66ccff"></span>SECRETARIA MUNICIPAL DE CULTURA, TURISMO, ESPORTE E LAZER </li>
<li><span style="background-color:#ffcc66"></span>SETOR DE CADASTRO DE IMOVEIS</li>
<li><span style="background-color:#ff6666"></span>SECRETARIA MUNICIPAL DE DESENVOLVIMENTO ECONÔMICO, TRABALHO E MEIO AMBIENTE</li>
<li><span style="background-color:#994d00"></span>SETOR AGILIZA</li>
</ul>
.legend {
margin-top: 30px;
ul {
list-style: none;
padding: 0;
li {
padding-left: 28px;
position: relative;
font-size: 28px;
font-weight: 600;
span {
width: 20px;
height: 20px;
position: absolute;
left: 0px;
top: 3px;
border-radius: 50%;
}
}
}
}
Additionally, you can paste ul into your own structure by:
document.getElementById('name-of-your-element').innerHTML = myBarChart.generateLegend();
Related
I am trying to select item from drop down using the code:
var assettype= element(by.model("templateIdTracker"));
if (assettype.isDisplayed()) {
assettype.click();
}
browser.sleep(1000);
element(by.cssContainingText('option', 'A')).click();
I can click the drop down but on trying to select item, it throws error:
"Failed: element not visible: Element is not currently visible and may
not be manipulated"
This is the web page code. Please suggest.
<div class="k-list-container k-popup k-group k-reset k-state-border-up" data-role="popup" style="position: absolute; font-size: 14px; font-family: "Open Sans Light","Helvetica Neue",Helvetica,Arial,sans-serif; font-stretch: normal; font-style: normal; font-weight: 400; line-height: 20px; width: 243.5px; height: auto; display: block; transform: translateY(0px);">
<div class="k-list-optionlabel ng-scope"/>
<div class="k-group-header" style="display:none"/>
<div class="k-list-scroller" unselectable="on" style="height: auto;">
<ul class="k-list k-reset" unselectable="on" tabindex="-1" aria-hidden="false" aria-live="off" data-role="staticlist" role="listbox">
<li class="k-item ng-scope k-state-hover" data-offset-index="0" unselectable="on" role="option" tabindex="-1">A</li>
<li id="1ebaaa3b-8f44-4873-b478-fea6fd498b83" class="k-item ng-scope k-state-selected k-state-focused" data-offset-index="1" unselectable="on" role="option" tabindex="-1">B</li>
<li class="k-item ng-scope" data-offset-index="2" unselectable="on" role="option" tabindex="-1">C</li>
<li class="k-item ng-scope" data-offset-index="3" unselectable="on" role="option" tabindex="-1">D</li>
<li class="k-item ng-scope" data-offset-index="4" unselectable="on" role="option" tabindex="-1">E</li>
<li class="k-item ng-scope" data-offset-index="5" unselectable="on" role="option" tabindex="-1">F</li>
<li class="k-item ng-scope" data-offset-index="6" unselectable="on" role="option" tabindex="-1">G</li>
</ul>
</div>
</div>
</div>
</div>
You could implement helper method to wait for this element to be visible.
Helpers.expectVisible = function (elementLocator, elementDescription) {
var message = null;
if (elementDescription) {
message = elementDescription + ' was not visible';
}
return browser.wait(EC.visibilityOf(elementLocator), WAIT_TIMEOUT, message);
};
you can also try:
assettype.click();
element(by.linkText("A")).click();
The problem is your browser can't see the element, its probably on the bottom of the screen.
You can use the same solution to any element you cant see.
Check my answer here https://stackoverflow.com/a/39074330/1431062
Thanks all!
It simply worked by using 'li' instead of 'option'
element(by.cssContainingText('li', 'A')).click();
instead of element(by.cssContainingText('option', 'A')).click();
assettype= element(by.model("templateIdTracker"));
assettype.click();
browser.sleep(1000);
element(by.cssContainingText('li', 'A')).click();
browser.sleep(2000);
As you can see, I got it right when the list inside my block has only one row, but it's wrong when the list is bigger.
Since I can't select only those inputs followed by errors (see here), my current solution is a negative margin-top:
.errorlist {
display: inline-block;
position: relative;
margin-left: 1em;
margin-top: -1em;
max-width: 30em;
min-width: 10em;
border-radius: 4px;
}
/* Arrow: */
.errorlist:before {
content: "";
width: 0;
height: 0;
position: absolute;
left: 10px;
bottom: 100%;
border-color: transparent transparent rgb(205, 10, 10) transparent;
border-style: solid;
border-width: 10px;
}
.errorlist li {
margin: 0;
padding: 0.5em;
}
Relevant HTML:
<div class="required">
<p>
<label for="id_username">Nombre de usuario:</label>
<input type="text" name="username" maxlength="30" id="id_username">
</p>
<ul class="errorlist ui-state-error">
<li>Este campo es obligatorio.</li>
<li>Este campo es obligatorio.</li>
</ul>
</div>
EDIT: I've noticed that only the 2nd <li> is moving the block. I can add as many as I want and the block doesn't slide updwards any more.
If you modify the position of ul.errorlist using the top property rather than margin-top, the li elements will stay put, and you can tweak the top
like so: http://jsfiddle.net/bqxdj/
.errorlist {
display: inline-block;
position: relative;
margin-left: 1em;
top: -1.5em;
max-width: 30em;
min-width: 10em;
border-radius: 4px;
}
list tags automatically adds a whitespace.
To get rid of this try:
<li>Este campo es obligatorio.</li><li>Este campo es obligatorio.</li>
or if you are safe with HTML5,
<li>Este campo es obligatorio.
<li>Este campo es obligatorio.
remove the end tag.
Hope this works.
EDIT: remove the margin-top:-1em
http://jsfiddle.net/ymSKX/
For some reason I cannot get the text in my middle column (of three columns) to respond to any classes or styles I apply to it. I'm just trying to slide the text in the middle column over to the right a little bit.
CSS (stylesheet):
#footer-address {
font-size:20px;
padding-left:20px;
}
#nav-foot{
border:1px solid #ccc;
border-width:1px 0;
list-style:none;
margin:0;
padding:0px;
text-align:left;
font-size:12px;
}
#nav-foot li{
display:inline;
}
#nav-foot a{
display:inline-block;
padding:20px 0 20px 0;
}
#nav-social {
border:1px solid #ccc;
border-width:1px 0;
display:inline;
list-style:none;
margin:0;
padding:0px;
float: left;
}
#nav-social li{
display:inline;
}
#nav-social a{
display:inline-block;
padding:20px 0 20px 0;
}
HTML:
<div style="width:30%; float:left; margin: 10px 0 10px 0; position:relative;">
<ul id="nav-foot">
<li>About Us</li>
<li>Jobs</li>
<li>Contact Us</li>
</ul>
</div>
<div id="footer-address" style="width:30%; float:left; margin: 10px 20px 10px 20px; position:relative;">
375 6th St. </br>
Atlanta, GA 30308 </br>
Phone: 404-981-3934 </br>
Email: admin#perimetermaids.com
</div>
<div style="width:30%; float:left; margin: 10px 0 10px 0; position:relative;">
<ul id="nav-social">
</i>
<li></i></li>
<li></i></li>
<li></i></li>
<li></i></li>
</ul>
</div>
Sorry if the code is sloppy or the formatting of my question, however, I'm really scratching my head as to why this won't work.
My URL is http://perimetermaids.com/test if anybody needs that as well. This is for the black footer area. Thanks for the help, and hope you all have an awesome weekend!
How do I get text-overflow to dynamically adjust when a mobile phone's orientation changes? This is how it should look:
Portrait mode
[] This is a very long ... |
[] Super long title is ... |
[] Hello |
[] Lorem ipsum |
Landscape mode
[] This is a very long title, right? |
[] Super long title is so long that ... |
[] Hello |
[] Lorem ipsum |
I've only been able to successfully see the ellipsis when text-overflow is applied to the immediate element, and this element has a hardcoded width. Now you see the problem: since mobile phones have a dynamic width based off of their orientation, this won't work. If you hardcode the width to make it look right in portrait mode, for example, it won't take advantage of the extra space in landscape mode. I already know a Javascript solution, but I wanted to see if anyone knew a clean CSS solution.
HTML
<ol>
<li>
<img src="foo.jpg" />
<p>This is a ver long title, right</p>
</li>
<li>
<img src="bar.jpg" />
<p>Super long title is so long that it can't fit</p>
</li>
</ol>
CSS
li {
}
li img {
float: left;
width: 4em;
height: 4em;
}
li p {
margin: 0 0 0 5em;
white-space: nowrap;
width: 16em;
text-overflow: ellipsis;
}
How about controlling the width for the ol?
CSS:
ol {
width: 100%;
}
li img {
float: left;
width: 4em;
height: 4em;
}
li p {
margin: 0 0 0 5em;
white-space: nowrap;
/* width: 16em; */
text-overflow: ellipsis;
overflow: hidden;
}
.clear {
clear: both;
}
HTML:
<ol>
<li>
<img src="http://www.codefromjames.com/dogquiz/images/dog.png" />
<p>This is a ver long title, right</p>
<div class="clear"></div>
</li>
<li>
<img src="http://www.codefromjames.com/dogquiz/images/dog.png" />
<p>Super long title is so long that it can't fit.
Super long title is so long that it can't fit. </p>
<div class="clear"></div>
</li>
</ol>
Here's a jsfidder demo for this, note that I added an extra <div> at the end of each <li> with clear:both style: http://jsfiddle.net/akuXJ/1/
What if you instead did width: 90%?
Add overflow: hidden to the list items, see this demo fiddle.
HTML:
<ol>
<li>
<img src="foo.jpg" />This is a ver long title, right
</li>
<li>
<img src="bar.jpg" />Super long title is so long that it can't fit
</li>
</ol>
CSS:
li img {
width: 4em;
height: 4em;
vertical-align: middle;
}
li {
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
vertical-align: middle;
}
Or, with the images within paragraph's.
Or, with the images outside paragraph's.
Have you tried display table? If it's supported by the device, it might have the effect of assigning a width to the text by treating it as a table cell.
Something like...
ol { display: table; width:100%; }
li { display: table-row; }
li img { display: table-cell; width: 4em; height: 4em; }
li p { display: table-cell; padding-left:5em; white-space: nowrap; text-overflow: ellipsis; }
If that doesn't work, another option might be display: inline-block
I have a menu very similar to the menu here on StackOverflow. The problem is that my menu looks right in every browser I've tested it on EXCEPT for my iPhone.
Here is a screenshot of the iPhone
Now obviously the "Add Event" button is supposed to be the same size as the rest.
Here's my Markup
<div id="menucontainer">
<div class="floatleft">
<ul class="menu">
<li><%: Html.NavigationLink("Now", "Index", "Events")%></li>
<li><%: Html.NavigationLink("Coming", "Coming", "Events")%></li>
<li><%: Html.NavigationLink("Hot", "Hot", "Events")%></li>
<li><%: Html.NavigationLink("Tags", "Index", "Tags")%></li>
<li><%: Html.NavigationLink("Users", "Index", "Users")%></li>
</ul>
</div>
<div class="floatright">
<ul class="menu">
<li><%: Html.NavigationLink("Add Event", "AddEvent", "Events")%></li>
</ul>
</div>
</div>
And here's my CSS
#menucontainer{position:relative; width:675px; float:right;}
ul.menu
{
padding: 0 0 2px;
position: relative;
margin: 0;
}
ul.menu li
{
display: inline;
list-style: none;
}
ul.menu li a
{
padding: 8px 18px;
font-weight: bold;
text-decoration: none;
line-height: 2.8em;
background-color: #666;
color: #fff;
border: 1px solid black;
text-shadow:#000 0px 1px 1px;
}
ul.menu li a.youarehere
{
background-color:#brand_color;
color: #fff;
}
ul.menu li a:hover
{
background-color:#brand_color;
text-decoration: none;
}
ul.menu li a:active
{
background-color:#brand_color;
text-decoration: none;
}
ul.menu li.selected a
{
background-color:#brand_color;
color: #000;
}
.floatright
{
float: right;
}
.floatleft
{
float: left;
}
Unfortunately I can't figure this one out. Thanks in advance for any direction.
EDIT:
This is the final output being sent to the browser
<div id="menucontainer">
<div class="floatleft">
<ul class="menu">
<li><a class="youarehere" href="/">Now</a></li>
<li>Coming</li>
<li>Hot</li>
<li>Tags</li>
<li>Users</li>
</ul>
</div>
<div class="floatright">
<ul class="menu">
<li>Add Event</li>
</ul>
</div>
</div>
EDIT:
Reproduction on jsbin
http://jsbin.com/akadi3/2 (note: obviously you need the iOS browser to see the problem)
Ok, so after a LOT of fiddling around, it appears as though if I add a height attribute to the menucontainer, then I'm all good.
#menucontainer
{
position:relative;
width:675px;
height:40px; /* this fixed the problem */
float:right;
font-size:80%;
}