IMPORTXML with bad xpath - xpath

I'm looking for data on the Yahoo Finance website for EV / EBITDA, but xPath returns values where I can't get the ID:
https://finance.yahoo.com/quote/CARD3.SA/key-statistics?p=CARD3.SA
xPath:
// * [# id = "Col1-0-KeyStatistics-Proxy"] / section / div [3] / div [1] / div [2] / div / div [1] / div [1] / table / tbody / tr [9] / td [4]
There are no differences between xpath "current" and 03/31/2020 except in full xpath (one is 4 and the other 3):
current:
/ html / body / div [1] / div / div / div [1] / div / div [3] / div [1] / div / div [1] / section / div [3] / div [1 ] / div [2] / div / div [1] / div [1] / table / tbody / tr [9] / td [4]
03/31/2020:
/ html / body / div [1] / div / div / div [1] / div / div [3] / div [1] / div / div [1] / section / div [3] / div [1] / div [2] / div / div [1] / div [1] / table / tbody / tr [9] / td [3]
cheers!

IMPORTXML nor IMPORTHTML can't import the data. You should use IMPORTFROMWEB addon to do this (note : number of requests are limited with the "Free" plan) :
You'll need the following XPath :
For headers :
//span[.="Current"]/ancestor::tr[1]//span[text()][count(./*)=0]
For data :
//span[.="Enterprise Value/EBITDA"]/../following-sibling::td
Output :
Formula used in C4 :
=TRANSPOSE(IMPORTFROMWEB(C1;C2:D2))
Possible alternative : GoogleAppScript to request and load the JSON data directly from the Yahoo API.

Related

Difference in Behavior Between Firefox and Chrome for HTML Canvas fillRect operation and fontBoundingBoxAscent

I am working on a bug in a library for Leaflet and I cannot figure out how to work around a difference in how Firefox and Chrome implement HTML Canvas. It revolves around the ctx.fillRect function -- it does not appear to be working in Firefox. On Chrome, the application works properly and the labels are properly coloured:
Chrome
However with Firefox it appears as such:
Firefox
The code in my library which draws the labels is:
drawLabel(labelText, textColor, backgroundColor, labelPosition) {
const textWidth = this.ctx.measureText(labelText).width;
const textHeight = this.ctx.measureText(labelText).fontBoundingBoxAscent;
// Calculate label xy position
const labelX = labelPosition.x;
const labelY = labelPosition.y;
this.ctx.fillStyle = backgroundColor;
// Magic numbers will centre the rectangle over the text
this.ctx.fillRect(labelX - textWidth / 2 - 1, labelY - textHeight + 1, textWidth + 3, textHeight + 2);
this.ctx.fillStyle = textColor;
this.ctx.fillText(labelText, labelX - textWidth / 2, labelY);
}
I've tried to leverage ctx.rect and ctx.fill as a substitute but that does not work. Logging the ctx object did show that Chrome and Firefox implement Canvas context a little differently, but the fields that I am modifying do not appear to be different.
The problem is that fontBoundingBoxAscent is not enabled in Firefox by default and requires the user to turn it on in about:config under dom.textMetrics.fontBoundingBox.enabled.

How can I widen the popup window in Kendo UI grid?

I want to widen the popup window in Kendo UI grid. So that also the elements in it fill the window.
In the answer How do I Change window size on kendo grid editor template? only the window is made wider, but not also the elements contained in it.
Simple provide the width in your grid definition: https://docs.telerik.com/kendo-ui/api/javascript/ui/grid/configuration/editable.window or see https://stackoverflow.com/a/30778406/4944034 for a practical example.
in the area of kendoGrid add the following code to the event edit:
jQuery("#grid").kendoGrid({
...
edit: function(e){
kendoUi_popUpEditWindow_setWidth('950px');
},
...
})
and the corresponding function:
function kendoUi_popUpEditWindow_setWidth(width){
if(typeof(width) != "string" || (width + '').indexOf("px") == -1 ){
width = "800px";
}
left = (jQuery( window ).width() - parseInt(width)) / 2;
left = left + "px";
jQuery(".k-widget.k-window").css('left', left);
jQuery(".k-edit-form-container").attr('style', 'width:' + width);
jQuery(".k-edit-form-container .k-edit-field").children().attr('style', 'width:100%');
}

how to add a value to a parameter without quotes

I'm using SASS to generate some styles, but I can't figure this one out.
Example:$v: round(($s / 12) * 100) + "%";
results in: width: "25%";
but I want it to result in width: 25%;
Adding quotes to a number turns it into a string.
Try this instead:
$v: round(($s / 12) * 100%);
Event better:
$v: round(percentage($s / 12));

storing values from calc function as a variable in scss

Hello there fellow coders,
I'm just starting out with SCSS; which is beyond awesome! There is one question I have regarding variables. I am wanting to calculate the width of divs plus it's padding, margins, and borders within a navigation element. I am then wanting to pass that calculated width into a variable like this:
$numbDivs: 4;
$divWidth: 150px;
$divPadd: 10px;
$divBorderWidth: 1px;
$divMarg: 2px;
$navBreakPoint: calc( #{$numbDivs} * ( #{$divWidth} + ( ( #{$divPadd} + #{$divBorderWidth} + #{$divMarg} ) * 2 ) ) );
I've enen tried it without the #{} portion, and that didn't work.
It might just be that scss doesn't support this...but it would be nice.
Thanks for all of y'all's posts.
calc() is a function of CSS, not Sass. If you want to store the result as a variable, drop the string interpolation and just calculate it:
$navBreakPoint: $numbDivs * ($divWidth + (($divPadd + $divBorderWidth + $divMarg) * 2));
It is worth noting that calc() does not worked in combination with media queries (see: calc() not working within media queries)

Is there a scrollIntoView technique for kendoGrid

I have a kendoGrid displaying a data source that has 200 rows and 50 columns. There are vertical and horizontal scrollbars, which is desired.
How can I cause the grid to scroll into view a specific column, row or row&column ?
Two use cases are:
Column name Z selected from a menu, jump to column Z (scroll it into view)
Grid with data source is FOO is scrolled about until Column X is left most column in view. The grid then replaced with a new one whose data source is BAR. If BAR contains a column X then I want to scroll it into view.
Thanks,
Richard
The very first thing that you need is finding the position of the cell. If you know the number of the row and the column you can do:
var col = 30;
var row = 100;
var pos = $("tr:nth(" + (row - 1) + ")", grid.tbody).find("td:nth(" + (col - 1) + ")").position();
Then you have to scroll and you can go directly using:
$(grid.tbody).closest(".k-grid-content").scrollTop(pos.top).scrollLeft(pos.left);
or animate it using:
$(grid.tbody).closest(".k-grid-content").animate({
scrollTop : pos.top,
scrollLeft: pos.left
}, 2000);

Resources