Is it possible to show compass blueprint grid to see its layout.
Here is the sample that I want to achieve:
http://www.blueprintcss.org/tests/parts/grid.html
Alternatively, include the showgrid mixin (+showgrid in the original SASS syntax):
#my-container
+showgrid
You do, however, need to generate the image for your particular grid flavor:
$ compass grid-img W+GxH [path/to/grid.png]
# Where:
#
# W = Width of 1 column in pixels.
# G = Width of 1 gutter in pixels.
# H = Height of the typographic baseline in pixels.
Just add the class showgrid to your container
if you inspect element on that page and remove the showgrid class you'll see it disappear
Related
I want to draw a relief of some region (sea and land involved), but I DO NOT want to show the variation of marine bathymetry, so I must set them to a common negative value to make sure that all the bathymetry map to the same color, like lightblue. I don't know how to do it?
That's easy using grdclip. When using command line GMT you can try:
gmt grdclip grid -Ggrid_clipped -Sb0/-1000 -V
which sets all values of your input grid grid< 0 to -1000 (adjust the values for your needs) and writes the clipped grid to outfile grid_clipped.
If you're using PyGMT you can try:
import pygmt
grid = pygmt.grdclip(grid, below = [0, -1000])
where you can directly hand the clipped grid to another PyGMT function for plotting like
fig.grdimage(grid = grid).
I am using Ruby to combine a list of existed SVG (trigger with XHR by react-inlinesvg - if someone wants to know) to display it on my views. The existed SVG size are all 90x90 . By using rmagick I can get its bounding box size, then translate the next element with these size. A simplified code will be like this:
# Preparing svg, <svg> tag, xml, etc..
...
divider = ''
shift = 0
svg_path.map do |svg|
canvas = ImageList.new(svg) # from rmagick
canvas.trim!
width = canvas.columns # get the bounding box after trimming
content = svg_content(svg) # Read content of existed svg
output = "<g transform='translate(#{shift}, 0)'>" + content +"</g>" + divider
shift += width + 10 # A small space between each svg
# Add divider
divider = "<g transform='translate(#{shift}, 0)'>" + #divider + "</g>"
end
...
# Add </svg> tag
Expected
Result
The link above is a demonstration for my problem, the real SVG is much more complicated.
The problem here is: I can get the exactly size of each element by pixel, however when I translating the next element with those sizes, it does not move as I expected.
Is there a way in d3 to not draw overlapping tick labels? For example, if I have a bar chart, but the bars are only 5 pixels wide and the labels are 10 pixels wide, I end up with a cluttered mess. I'm currently working on an implementation to only draw the labels when they do not overlap. I can't find any existing way to do that, but wasn't sure if anyone else had dealt with this problem.
There is no way of doing this automatically in D3. You can set the number of ticks or the tick values explicitly (see the documentation), but you'll have to figure out the respective numbers/values yourself. Another option would be to rotate the labels such that there is less chance of them overlapping.
Alternatively, like suggested in the other answer, you could try using a force layout to place the labels. To clarify, you would use the force layout on the labels only -- this is completely independent of the type of chart. I have done this in this example, which is slightly more relevant than the one linked in the other answer.
Note that if you go with the force layout solution, you don't have to animate the position of the labels. You could simply compute the force layout until it converges and then plot the labels.
I've had a similar problem with multiple (sub-)axis, where the last tick overlaps my vertical axis in some situations (depending on the screen width), so I've just wrote a little function that compares the position of the end of the text label with the position of the next axis. This code is very specific to my use case, but could adapted easily to your needs:
var $svg = $('#svg');
// get the last tick of each of my sub-axis
$('.tick-axis').find('.tick:last-of-type').each(function() {
// get position of the end of this text field
var endOfTextField = $(this).offset().left + $(this).find('text').width();
// get the next vertical axis
var $nextAxis = $('line[data-axis="' + $(this).closest('.tick-axis').attr('data-axis') + '"]');
// there is no axis on the very right, so just use the svg width
var positionOfAxis = ($nextAxis.length > 0) ? $nextAxis.offset().left : $svg.offset().left + $svg.width();
// hide the ugly ones!
if (endOfTextField > positionOfAxis) {
$(this).attr('class', 'tick hide');
}
});
The ticks with color: aqua are the hidden ones:
I'm trying to create a thumbnail grid with Singularity 1.x. Here's the code:
$cols: 3
$grids: $cols
$gutters: 0.2
.element
#for $i from 1 through $cols
&:nth-child(#{$cols}n+#{$i})
+grid-span(1,$i, $output-style: 'float')
The problem is that the second element (the one that receives grid-span(1,2)) lacks gutter (margin-right).
Screenshots:
http://d.pr/i/Xsb7+
http://d.pr/i/ZcMg+
I tried changing the number of columns $cols, and the result is the same: all elements receive correct margin, except for the second one.
How do make second element have correct margin just like the others?
This appears to be an oversight in the Float output method. This will be fixed in 1.0.5
Good day.
How to impose white_rectangle.jpg on logo.jpg in the image below
using Imagemagic.
And a bonus question: what's Ruby's method can make the task.
def (path_to_image)
# impose white_rectangle.jpg on logo
end
This can easily be accomplished using RMagick:
require 'RMagick'
logo = Magick::Image.read("logo.jpg").first
rect = Magick::Image.read("white_rectangle.jpg").first
result = logo.composite(rect, x, y, Magick::CopyCompositeOp)
result.write "result.jpg"
An alternative is to just draw a white rectangle without using a composite image:
image = Magick::Image.read("logo.jpg").first
gc = Magick::Draw.new
gc.stroke = 'white'
gc.fill = 'white'
gc.rectangle x_start, y_start, x_end, y_end
gc.draw(image)
image.write "result.jpg"
Using ImageMagick command line tools, you can overlay one image with another like this:
$ composite white_rectangle.jpg logo.jpg -geometry +x+y result.jpg