Finding SVG Elements using RSelenium and XPath - svg

I am writing a dynamic web scraper for a private website, where I am scraping the results of different bar charts available for sports teams. The problem is that the teams city name is the text available in the span element with class 'bar-chart__value', but there are duplicates (i.e. New York, Los Angeles).
It seems the only place where unique values are available for the team name is in the svg element, but I can't figure out how to find the svg element using xpath.
leaderboard <- map_dfr(1:length(a), function(x){
team <- remDr$findElements("xpath", "//span[#class = 'bar-chart__logo']/*[name() = 'svg']")[[x]]$getElementText()
if(team == "Average") {
number <- remDr$findElements("xpath", "//span[#class = 'bar-chart__value']")[[x]]$getElementText()
avg <<- x
} else if(x > avg){
number <- remDr$findElements("xpath", "//span[#class = 'bar-chart__value']
//span[#class = 'play-link__number-span']")[[x-1]]$getElementText()
} else {
number <- remDr$findElements("xpath", "//span[#class = 'bar-chart__value']
//span[#class = 'play-link__number-span']")[[x]]$getElementText()
}
df <- tibble(unlist(team), unlist(number))
colnames(df) <- c("Team", specific)
return(df)
})
Does anyone know how to use xpath in the findElement method to find an svg element? This is the code returning the error:
remDr$findElements("xpath", "//span[#class = 'bar-chart__logo']/*[name() = 'svg']")[[1]]$getElementText()

use local-name() instead of name()-> this might include the prefix.
remDr$findElements("xpath", "//span[#class = 'bar-chart__logo']/*[local-name() = 'svg']")[x]$getElementText()

Related

Switching between two colors on a awesome wm container widget

I create a wibox.container.background with something like:
local w = wibox.widget({
{
id = "texte",
text = "mon texte",
widget = wibox.widget.textbox
},
bg = beautiful.bg_normal,
widget = wibox.container.background
})
Now I want to switch between two background colors with:
w.bg = w.bg == beautiful.bg_normal and beautiful.bg_focus or beautiful.bg_normal
But that doesn't work. It seems w.bg refers to a solid pattern and not to a simple hexa color string.
Am I pointing to the correct bg variable?
I would recommend that you keep your own variable local is_focus = true and use that to update the background.
What happens is that the background "string" that you specify goes through gears.color and is transformed into a cairo pattern. That is what is then actually used for drawing. You could also pass in a cairo pattern directly and avoid the "loop" through gears.color.
Example for my proposed solution:
local w = wibox.widget({
{
id = "texte",
text = "mon texte",
widget = wibox.widget.textbox
},
bg = beautiful.bg_normal,
widget = wibox.container.background
})
local is_focused = false
local function switch_background()
is_focused = not is_focused
w.bg = is_focused and beautiful.bg_focus or beautiful.bg_normal
end

Displaying a DICOM dataset as 3D representation

I am trying to show a DICOM Series as a 3D representation. It worked with a different set of data but with the current one, the 3D image does not show up. The output values in the datastack of windowCenter and windowWidth are -964 and -664. I am using the latest version of AMI.js but still cannot display the DICOMs as 3D.
Do I have to convert the negativ values somehow, so that they turn out as positive values? Or do you have any other idea why I cannot display the Data?
I am loading the Data with the AMI.VolumeLoader, here is the important bit of code:
let loader = new AMI.VolumeLoader();
loader.load(files)
.then(() => {
let series = loader.data[0].mergeSeries(loader.data)[0];
loader.free();
loader = null;
let stack = series.stack[0];
//stack Helper
vrHelper = new AMI.VolumeRenderingHelper(stack);
scene.add(vrHelper);
//LUT
lut = new AMI.LutHelper('lut-canvases');
lut.luts = AMI.LutHelper.presetLuts();
lut.lutsO = AMI.LutHelper.presetLutsO();
//update related uniforms
vrHelper.uniforms.uTextureLUT.value = lut.texture;
vrHelper.uniforms.uLut.value = 1;
// camera
let centerLPS = stack.worldCenter();
camera.lookAt(centerLPS.x, centerLPS.y, centerLPS.z);
camera.updateProjectionMatrix();
controls.target.set(centerLPS.x, centerLPS.y, centerLPS.z);
})
.catch((error) => window.console.log(error));
A different set of Data is showing as it should be:
The other set of data is just not showing up and I don't even get an error message.

define Frontend Layouts for page trees

I'm using the field Frontend-Layout at my TYPO3 7.6-Backend. Because my website will have four different departments with different colours in frontend.
So I'm using:
TCEFORM {
pages {
layout {
altLabels {
0 = [ blue]
1 = [ orange ]
2 = [ green]
3 = [ yellow]
}
}
}
} ### TCEFORM
At my FLUIDTEMPLATE I'll wrap an <div>-wrapper, to set my different languages globally at my stylesheet. f.e. div.wrap.blue { background-color:blue;}
<div class="wrap
{f:if(condition:'{data.layout} == 0',then:'blue')}
{f:if(condition:'{data.layout} == 1',then:'orange')}
{f:if(condition:'{data.layout} == 2',then:'green')}
{f:if(condition:'{data.layout} == 3',then:'yellow')}">
...
This works perfect for me.
But how can I slide (or inherit) the frontend-layout-info from my parent-page to the subpages on my pagetree? I don't want to choose the frontend layout in page properties everytime, if I will add a new page into my pagetree. This must be working automatically. Is this possible? With slide?
For example
*ROOT
+ parent blue
~~ sub blue 1 /* these pages also have frontend layout 0 */
~~ sub blue 2
+ parent orange
~~ sub orange 1
+ parent green
...
+ parent yellow
...
Thebks for your opinion or tips ..
I don't think it's dead simple to set the {data.layout} layout recursively without manipulating the database. I have three 'solutions' coming to mind to solve your problem:
1) Create four Backend Layouts that you can select for your current and childpages. (Basically rinse and repeat what you have done for your first backend layout)
2) Using your layout modes you could try setting a body class using typoscript like so (i did not test this):
page.bodyTag >
page.bodyTagCObject = TEXT
page.bodyTagCObject.field = data.layout
page.bodyTagCObject.wrap = <body class="color-|">
3) Use a similar typoscript but update the value using typoscript conditions such as [pidInRootline]
page.bodyTag >
page.bodyTagCObject = TEXT
page.bodyTagCObject.wrap = <body class="blue">
[PIDinRootline = 1]
page.bodyTagCObject.wrap = <body class="orange">
[global]
[PIDinRootline = 2]
page.bodyTagCObject.wrap = <body class="green">
[global]
# and so on
I had your same problem and this typoscript worked fine for me,
the result is what you wanted to reach.
as you can see the 20.10 object is used when frontend layout is set on the page, while the 20.20 object is used when frontend layout is not set and takes it in slide mode:
page {
bodyTagCObject >
bodyTagCObject = COA
bodyTagCObject {
stdWrap.noTrimWrap = |<body |>|
20 = COA
20 {
wrap = class="|"
10 = TEXT
10 {
if.isTrue.data = page:layout
data = page:layout
noTrimWrap = |page-layout-| |
}
20 = TEXT
20 {
if.isFalse.data = page:layout
data = levelfield:-2, layout, slide
noTrimWrap = |page-layout-|
}
}
}
}
I hope I have been helpfull.

iTextSharp pdf table cell height issue

I have iTextSharp 5.4.4 (nuget) and have a nice table with a barcode (ean13) and text below it.
I have specific tablecell heights (and cell widths) because I want to print the pdf to an A4 with stickers.
Here is the current layout:
as you can see, there is a rather large gap between the ean13 code and the text below.
here is my C# code:
PdfPCell c = new PdfPCell();
c.FixedHeight = 21.2f * postScriptPointsPerMilimeter; // to get to accurate milimeters
c.HorizontalAlignment = Element.ALIGN_CENTER;
Paragraph p = new Paragraph();
p.Font.Size = 6;
Chunk code = new Chunk(dr["productcode"].ToString());
p.Alignment = Element.ALIGN_CENTER;
p.Add(code);
BarcodeEAN ean13 = new BarcodeEAN();
ean13.CodeType = BarcodeEAN.EAN13;
ean13.Code = dr["ProductEan13"].ToString();
ean13.BarHeight = 4.0f * postScriptPointsPerMilimeter;
var a = ean13.CreateImageWithBarcode(cb, null, null);
a.ScalePercent(90);
c.AddElement(a);
c.AddElement(p);
t.AddCell(c);
My question is to reduce the space between the barcode and the text. I cannot see if it has something to do with the barcode's margins or the paragraph's or maybe both... hard to troubleshoot.
p.Leading = 0;
That was missing. I thought that
p.SpacingBefore = 0;
would do the trick, but it didn't. Leading did!

Typo3 list the content of all child-pages as content of the parent page

As the title says, I need to list the content of all child-pages on the parent-page, after its own content. Or the thing I really need is, one page with content and and a menu which links to the different headers of the content. e.g. athe parent-page with content:
**Parent Head**
parent text
*first subhead*
first subtext
*second subhead*
second subtext
and the menu should look like:
Parent
-first subhead
-second subhead
I thought it would be easier if the parent-page "collects" the content of the child-pages.
The other solution was, that the child-pages would be links to extern URLs, to the specific c-IDs of the different contents of the parent-page. But I think this isn't that easy for the website owner, who doesn't know anything about where he can find the right c-ID in the web-page-source-code.
So how would You make that? Or how can I realize the thing with the child-page-content?
EDIT: Have a solution now. Just have to fix, that the submenu will be displayed without childpages.
Here is the code:
temp.contentnav = CONTENT
temp.contentnav {
table = tt_content
select {
pidInList = 7
orderBy = sorting
where = colPos=0
languageField=sys_language_uid
}
renderObj = TEXT
renderObj {
field = header
wrap= <li>|</li>
typolink.parameter.field=pid
typolink.parameter.dataWrap=|#{field:uid}
typolink.ATagParams = class="linkClass"
if.isTrue.field=header
}
wrap = <ul id="submenuClass"> | </ul>
}
page.10.marks.MENU.2.NO.after.cObject < temp.contentnav
Try something like this
temp.pageIds = HMENU
temp.pageIds.entryLevel = 1
temp.pageIds.1 = TMENU
temp.pageIds.1 {
NO.stdWrap.field = uid
NO.allWrap = |,
NO.doNotLinkIt = 1
}
lib.container = CONTENT
lib.container.table = tt_content
lib.container.select {
pidInList.cObject < temp.pageIds
}
There is a content element "Menu/Sitemap" with has an option to render subpages with content.
If you want to do it via TypoScript, render the menu, and then replace the menu items with content of them.
# Pseudocode on menuitem
# assuming you are using css_styled_content
1.allStdWrap.cObject < styles.content.get
# Set pid for CONTENT object from styles.content.get to the uid of the page
# which gets rendered
1.allStdWrap.cObject.select.pidInList.data = uid
Can't provide you with an working snippets atm.

Resources