percentage

CSS width in Percent related to the grand parent

心已入冬 提交于 2019-12-06 16:35:05
问题 How to relate width in percent to the grand parent? 回答1: You could simply relate width of li s to the parent ul which in turn it relates to the grand parent div : div{ overflow: hidden; width: 100%; } ul{ width: 1000%; } li{ width: 3%; } 回答2: Use javascript: var g = document.getElementById('grandparent'); var w = g.clientWidth; if (w > 400) w *= .3; var c = document.getElementsByClassName('child'); for (var i=0; i < c.length; i++) { c[i].style.width = w+'px'; } I have a jsfiddle example. 来源:

Any bug with hsla(0, 0%, 0%, 0), becoming hsla(0, 0, 0, 0)? (missing percent sign)

空扰寡人 提交于 2019-12-06 10:45:26
问题 I set up a text color as hsla(0, 0%, 0%, 0) to hide it. But sometimes it became hsla(0, 0, 0, 0) , which can't be executed by browser. I can fix this if I go the site with incognito mode. I have no idea if it's a bug in Chrome, from the server or just cache problem. If so, why it happens so often and how to fix it? 回答1: Zero's should be unitless in css. Lengths refer to distance measurements.The format of a length value (denoted by in this specification) is a (with or without a decimal point)

Javascript Image Resize Calculation

社会主义新天地 提交于 2019-12-06 09:39:44
Let's say I have an image that is 1920 x 1280. I'm using a slider to scale down the image, which goes from 100% to 0%, where 100% is the original size and 0% is the minimum size. The image can be no smaller than 350 in either height, or width, so 0% should equate to this minimum size. What formula would I use to calculate the new dimensions? If you could explain the logic, that would be helpful. I'm certain this is an SAT question that I failed... var min=Math.min(width,height); var result=Math.max(min * (percentage/100),350); var newHeight=(result/min) * height; var newWidth=(result/min) *

MongoDB aggregation - how to get a percentage value of how many times an event occurred per day of week

余生颓废 提交于 2019-12-06 07:34:40
Im a MongoDB noob so please dont judge me if my question is stupid:P Im trying to get some results from MongoDB to create a table that would show percentage statistics of how much do i play a certain game per day of week (all games together per day = 100%). This is my JSON import for the database: [ {"title":"GTA","date":"2017-11-13"}, {"title":"GTA","date":"2017-11-13"}, {"title":"BattleField","date":"2017-11-13"}, {"title":"BattleField","date":"2017-11-13"}, {"title":"BattleField","date":"2017-11-14"} ] Ive written an aggregation that grouped the results by days and counted the total amount

How to get percentage of counts of a column after groupby in Pandas

旧城冷巷雨未停 提交于 2019-12-05 14:57:37
I'm trying to get the distribution of grades for each rank for names in a list of data. However, I can't figure out how to get the proportion/percentage of each grade count over its rank group. Here's an example: df.head() name rank grade Bob 1 A Bob 1 A Bob 1 B Bob 1 C Bob 2 B Bob 3 C Joe 1 C Joe 2 B Joe 2 B Joe 3 A Joe 3 B Joe 3 B I use grade_count = df.groupby(['name', 'rank', 'grade']).['grade'].size()) to give me the count of each grade within its (name,rank) group: name rank grade Bob 1 A 2 B 1 C 1 2 B 1 3 C 1 Joe 1 C 1 2 B 2 3 A 1 B 2 Now for each size calculated, I'd like to get its

C How to calculate a percentage(perthousands) without floating point precision

我只是一个虾纸丫 提交于 2019-12-05 11:28:15
How do you calculate a percentage from 2 int values into a int value that represents a percentage(perthousands for more accuracy)? Background/purpose: using a processor that doesn't have a FPU, floating point computations take 100's of times longer. int x = 25; int y = 75; int resultPercentage; // desire is 250 which would mean 25.0 percent resultPercentage = (x/(x+y))*1000; // used 1000 instead of 100 for accuracy printf("Result= "); printf(resultPercentage); output: Result= 0 When really what I need is 250. and I can't use ANY Floating point computation. Example of normal fpu computation:

How do I print a '%' sign using string formatting?

家住魔仙堡 提交于 2019-12-05 10:05:15
问题 I've made a little script to calculator percent; however, I wish to actually include the '%' within the message printed... Tried this at the start - didn't work... oFile.write("Percentage: %s%"\n" % percent) I then tried "Percentage: %s"%"\n" % percent" which didn't work. I'd like the output to be: Percentage: x% I keep getting "TypeError: not all arguments converted during string formatting" 回答1: To print the % sign you need to 'escape' it with another % sign: percent = 12 print "Percentage:

ggplot donut chart percentage labels

核能气质少年 提交于 2019-12-05 07:44:55
I'm trying to add percentage labels to a donut chart but have been unsuccessful in plotting a clear representation of percentage values (rounded and not overlapping) ## my data library(ggplot2) col <- c("white", "black", "transparent", "grey", "blue", "yellow", "green", "red", "pink", "orange", "brown") freq <- c(101, 68, 34, 18, 14, 5, 5, 3, 2, 1, 1) ## create data frame colour.df <- data.frame(col, freq) colour.df ## calculate percentage colour.df$percentage = colour.df$freq / sum(colour.df$freq)* 100 colour.df = colour.df[rev(order(colour.df$percentage)), ] colour.df$ymax = cumsum(colour.df

ggplot2: How to add percentage labels to a donut chart

半世苍凉 提交于 2019-12-05 05:21:52
I am pretty new to R... so forgive me. I'm trying to make donut plots using ggplot2. I have modified the code of the post ggplot Donut chart but now I'm not able to add the percentage on the chart. This is my attempt: library(ggplot2) blank_theme <- theme_minimal()+ theme( axis.title.x = element_blank(), axis.title.y = element_blank(), panel.border = element_blank(), panel.grid=element_blank(), axis.ticks = element_blank(), plot.title=element_text(size=14, face="bold") ) dat = data.frame(count=c(319, 442, 239), category=c("University", "High Scool", "Lower")) dat$fraction = dat$count / sum(dat

Formatting a cell to a percentage in PHPExcel

天大地大妈咪最大 提交于 2019-12-04 22:44:34
I am automating an excel spreadsheet using PHP. I have been looking for a way to pragmatically format a cell to a percentage in PHPExcel. I want to change a value like 0.077922078 to 8% Is there a solution for this? Thanks in advance. assuming your cell is A1 .. $objPHPExcel->getActiveSheet()->getStyle('A1') ->getNumberFormat()->applyFromArray( array( 'code' => PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00 ) ); PHPExcel library has predefined only few basic formatting constants. You can actually build your own for virtually any purpose (coloring, formatting decimals & thousands etc).