Is there anyway to remove the dots for points from angularjs charts - angularjs

Can we remove these dots for points so that it looks like a straight line. Although i can see that there is an option in charts.js unable to implement here

You can do this with
options: { elements: { point: { radius: 0 } } }

Related

Swift how to sort array by doubles

I am using sorted by and works although 12.05 comes before 2.29. Is there a different approach that will resolve this?
ForEach(searchVM.landmarks.sorted(by: { $0.distanceAway < $1.distanceAway }), id: \.id) { landmark in
NavigationLink {
SearchDetailsView(landmark: landmark)
} label: {
SearchCellView(landmark: landmark)
}
} //END:FOREACH
Probably your distanceAway property is a String. So one solution is
searchVM.landmarks.sorted {
Double($0.distanceAway) ?? 0 < Double($1.distanceAway) ?? 0
}
Note that Double($0.distanceAway) can return nil (if the string can't be parsed as a Double), so I have used ?? 0 to provide a default on each side of the < operator. You might want to handle such cases differently.
Note also that Malnati's is my favorite pizzeria.

Less contrast() functions for Stylus

What is the Stylus version of the contrast() function used in Less? I need to provide legibility given a background color, and should be automatic no matter what given color.
AFAIK there is no direct equivalent. However there are many color functions like mixing, inverting, darkening etc to build a color to your own wishes.
The Stylus-owned contrast() function will tell you the current contrast ratio, which goes from 1 to 21 (higher is better). For more info see Stylus documentation.
Something like this works well for me:
var_backgroundColor = teal
var_fontColor = black
var_fontColorAlternative = darken(complement(var_backgroundColor),15%)
body { color: var_fontColor; background-color: var_backgroundColor }
if contrast(var_fontColor,var_backgroundColor).ratio <= 7 {
body { color: var_fontColorAlternative }
}
else {
body { color: var_fontColor }
}

Iterating through a character/string array in LaTeX

This is a continuation of my question posted earlier (Outputting character string elements neatly in Sweave in R). I have an array of strings, and am trying to output each element into LaTeX. I am able to achieve that using the following code:
\documentclass[12pt,english,nohyper]{tufte-handout}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{longtable}
\usepackage{wrapfig}
\usepackaage{hyperref}
\usepackage{graphicx}
\usepackage[space]{grffile}
\usepackage{geometry}
\usepackage{enumitem}
\usepackage{pgffor}
\makeatletter
\makeatother
\begin{document}
<<include=FALSE>>=
library(ggplot2)
library(reshape2)
library(xtable)
#
\centerline{\Large\bf This is a test}
\vspace{1cm}
\noindent
My List:
\vspace{2mm}
.
<<echo=FALSE,results='asis'>>=
myList = c("A. This is the first item in my list.", "B. This is the second item in my list, and it will span across two lines because it is so long. This is the second item in my list, and it will span across two lines because it is so long.", "C. This is the third item in my list")
#
\begin{enumerate}[label=\Alph*., itemsep=-1ex]
\item \Sexpr{str_trim(unlist(strsplit(chapter_outcomes[1], "[.]"))[2])}
\item \Sexpr{str_trim(unlist(strsplit(chapter_outcomes[2], "[.]"))[2])}
\item \Sexpr{str_trim(unlist(strsplit(chapter_outcomes[3], "[.]"))[2])}
\end{enumerate}
\end{document}
This provides me the correct output that I had wished to achieve:
However, I am now trying to get this iteration to occur in a for-loop, as I may not always have exactly three elements in my chapter_outcomes string array. I have tried variants of the following:
\begin{enumerate}[label=\Alph*., itemsep=-1ex]
\foreach \i in {\Sexpr{length(chapter_outcomes)}} {
\item \Sexpr{str_trim(unlist(strsplit(chapter_outcomes[\i], "[.]"))[2])}
}
\end{enumerate}
However, this leads to an error of "unexpected input" at the above syntax for chapter_outcomes[\i].
I have tried looking at similar posts (Iteration in LaTeX, http://www.bytemining.com/2010/04/some-latex-gems-part-1-tikz-loops-and-more/) but their focus is different enough that I cannot apply it to solve my problem here.
Thank you for any advice.
I don't have Latex handy and have not done it a long time, but :
1) doesn't \foreach require a range? If I understand your code correctly, \Sexpr evaluates just to the length (eg. {6}), whereas \foreach should have {1..6}
or
2) another typical error is indexes running {0..[length-1]} instead of {1..[length]} , which could lead to "unexpected input" as the interpreter tries to move past the last element.
Sounds like you should be taking a look at expl3. I don't use R/Sweave, but here's an example that should get you going.
\documentclass{article}
\usepackage{xparse,enumitem}
\ExplSyntaxOn
\cs_new_protected:Nn \lanner_sweave_wrap:n
{ \item \Sexpr { str_trim(unlist(strsplit(#1, "[.]"))[2]) } }
\cs_new_protected:Nn \lanner_sweave_enumlist:nn
{
\begin{enumerate}[#2]
\seq_set_split:Nnn \l_tmpa_seq { ;;; } { #1 }
\seq_map:NN \l_tmpa_seq \lanner_sweave_wrap:n
\end{enumerate}
}
\cs_generate_variant:Nn \lanner_sweave_enumlist:nn { f }
\NewDocumentCommand \EnumerateIt { O{label=\Alph*., itemsep=-1ex} m }
{ \lanner_sweave_enumlist:fn {#1} {#2} }
\ExplSyntaxOff
\begin{document}
<<echo=FALSE,results='asis'>>=
myList = c("A. This is the first item in my list.", "B. This is the second item in my list, and it will span across two lines because it is so long. This is the second item in my list, and it will span across two lines because it is so long.", "C. This is the third item in my list")
#
\EnumerateIt{\Sexpr{join(myList,";;;")}} % join myList with ";;;" -- I don't know the exact syntax
\end{document}
Of course, this can be done with pure expl3:
\documentclass{article}
\usepackage{xparse,enumitem}
\ExplSyntaxOn
\tl_new:N \l_lanner_tmp_tl
\seq_new:N \l_lanner_tmp_seq
\cs_new_protected:Nn \lanner_sweave_enumlist:nn
{
\begin{enumerate}[#2]
\tl_map_inline:nn {#1}
{
\seq_set_split:Nnn \l_lanner_tmp_seq { .~ } {##1}
\seq_pop_left:NN \l_lanner_tmp_seq \l_lanner_tmp_tl
\tl_set:Nf \l_lanner_tmp_tl
{ \seq_use:Nn \l_lanner_tmp_seq { .~ } }
\tl_trim_spaces:N \l_lanner_tmp_tl
\item \l_lanner_tmp_tl
}
\end{enumerate}
}
\cs_generate_variant:Nn \lanner_sweave_enumlist:nn { f }
\NewDocumentCommand \EnumerateIt { O{label=\Alph*., itemsep=-1ex} >{ \SplitList { ;; } } m }
{
\tl_show:n{#2}
\lanner_sweave_enumlist:fn {#2} {#1} }
\ExplSyntaxOff
\begin{document}
\EnumerateIt{
A. This is the first item in my list. ;;
B. This is the second item in my list, and it will span across two lines because it is so long,
This is the second item in my list, and it will span across two lines because it is so long. ;;
C. This is the third item in my list}
\end{document}

Compare getValue with map.layers[i].name

As part of a xtype combo, I would like to know if the layer I choose in my simple data store (represented by this.getValue()) is present in the map layers. So if it does, A should occur, and B if it does not. The problem is that myLayer variable seems to be unrecognized, even though Opera Dragonify throws no error at all. Where would be the error?
listeners: {
'select': function(combo, record) {
for(var i = 0; i < mapPanel.map.length; i++) {
var myLayer = mapPanel.map.layers[i].name;
if (myLayer == this.getValue()) {
// do A here...
} else {
// do B here...
}
}
}
}
Thanks for any pointers,
I think the problem is that you are using this.getValue() instead of using combo.getValue().
I don't know how your app is set but it's usually a better idea to use the first parameter of your listener instead of the keywork this in order to avoid scope issues.
Hope this helps
#Guilherme Lopes Thanks for that, but the solution was this: mapPanel.map.layers.length instead of mapPanel.map.length.

Using CGRectIntersectsRect with IBOutletCollection of an array of uiviews

Hello I have 3 views as part of an IBOutletCollection. They are in the array called myArrayOfViews. I'd like to be able to use CGRectIntersectsRect to determine when any of these 3 views overlap but so far no luck. I thought I could loop through the array twice and then run CGRectIntersectsRect but no luck. What am I missing. Thanks in advance!
for (UIView *view1 in self.myArrayOfViews) {
NSLog(#"view1 is %#",view1);
for (UIView *view2 in self.myArrayOfViews) {
NSLog(#"view2 is %#",view2);
if( CGRectIntersectsRect(view1.frame, view2.frame)) {
NSLog(#"overlap!");
}
}
}
You figured out what the problem was. Here's how to add the check that the two views are not the same:
for (UIView *view1 in self.myArrayOfViews) {
for (UIView *view2 in self.myArrayOfViews) {
if (view1 != view2 && CGRectIntersectsRect(view1.frame, view2.frame)) {
NSLog(#"overlap!");
}
}
}

Resources