I am using google charts with twitter bootstrap in rails application.
In fluid layout if the span width decreases, the chart overflows its parent div.
Can google chart width be given in percentages?
Please help.
Update
I am using google_visualr gem.
Here is my controller code.
def home
# Indents
indent_status_table = GoogleVisualr::DataTable.new
indent_status_table.new_column('string', 'STATUS')
indent_status_table.new_column('number', 'COUNT')
indent_status_table.add_rows(1)
indent_status_table.set_cell(0, 0, 'Open')
indent_status_table.set_cell(0, 1, 100)
opts = { :title => 'INDENT STATUS', :is3D => true }
#indent_status_chart = GoogleVisualr::Interactive::PieChart.new(indent_status_table, opts)
end
And here is my html.erb code
<div id='shipment_status_chart' style="width:100%; height:200px"></div>
<%= render_chart #shipment_status_chart, 'shipment_status_chart' %>
And in java script code.
$(function() {
$(window).resize(function(){
drawChart();
});
});
You can specify the chart width in the HTML
<div id="chart_div" style="width:100%; height:300px"></div>
From Google Charts documentation:
Specifying the size in HTML - A chart can take a few seconds to load
and render. If you have the chart container already sized in HTML, the
page layout won't jump around when the chart is loaded.
Here is a Fiddle showing 100% width.
Update
To resize the chart when the window changes size, you can use jQuery to update the chart size.
$(document).ready(function () {
$(window).resize(function(){
drawChart();
});
});
Here is a Fiddle showing 100% width with update on screen resize.
I'm using Google Charts with ng-google-chart.js and in order to make my charts responsive I've added style="max-width:100%"
Example:
<div class="row">
<div class="col-md-3">
<div google-chart style="max-width:100%" chart="chart"/>
</div>
<div class="col-md-3">
<div google-chart style="max-width:100%" chart="chart"/>
</div>
<div class="col-md-3">
<div google-chart style="max-width:100%" chart="chart"/>
</div>
<div class="col-md-3">
<div google-chart style="max-width:100%" chart="chart"/>
</div>
</div>
Related
I'm trying to create the following layout:
When the page is smaller - the blue column should go under the red column.
No matter what I try - the issue is the red box always wants to be the same height as the blue box.
https://codepen.io/LeeBow/pen/eYKGzdb
<div class="container-fluid">
<div class="row">
<div class="col-md-8 order-md-1">
<div
style="height:100px;width:100px;background-color:red"></div>
</div>
<div class="col-md-4 order-md-3"><div style="height:300px;width:100px;background-color:blue"></div></div>
</div>
<div class="row">
<div class="col-md-4 order-md-2"><div style="height:100px;width:100px;background-color:green"></div></div>
</div>
</div>
I would like my green box to move under the red box.
The red box always stays the same height as the blue box. It moves under the red box correctly when the screen is smaller.
But the green box will not move under the red box.
Make two blue boxes:
one for desktop (use classes d-md-block d-none) and
one for mobile (use classes d-md-none d-block, which is the opposite from above).
Those classes are Bootstrap classes to manipulate display CSS property.
See the snippet below.
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.2.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-OERcA2EqjJCMA+/3y+gxIOqMEjwtxJY7qPCqsdltbNJuaOe923+mo//f6V8Qbsw3" crossorigin="anonymous"></script>
<div class="container-fluid">
<div class="row">
<div class="col-md-8">
<div style="height:100px;width:100%;background-color:red"></div>
<div class="d-md-none d-block" style="height:300px;width:100%;background-color:blue"></div> <!-- Show on mobile -->
<div style="height:100px;width:100%;background-color:green"></div>
</div>
<div class="col-md-4 d-md-block d-none">
<div style="height:300px;width:100%;background-color:blue"></div> <!-- Show on desktop -->
</div>
</div>
</div>
I have a webpage that shows an image up to size 400x400px, if they click on the image then I want it to display in a modal that sizes to accommodate the actual size of the image
The modal comes up but it defaults to 500px whatever the size of the image (from https://getbootstrap.com/docs/5.2/components/modal/#fullscreen-modal). If the image is larger than that I want the modal to be larger, and if smaller I want the modal to be smaller, I cannot see how to do this. I notice you can also have a fullscreen image by using modal-fullscreen but that doesn't help me.
Surely possible for the modal to size to accommodate the data
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<div>
<a data-bs-toggle="modal" data-bs-target="#full_size_image_dialog">
<img src="https://via.placeholder.com/400" class="figure-img img-fluid border border-dark">
</a>
<div id="full_size_image_dialog" class="modal">
<div class="modal-dialog modal-dialog-scrollable">
<div class="modal-content">
<div class="modal-header">
<h5>
Full Size artwork
</h5>
</div>
<div class="modal-body">
<img src="https://via.placeholder.com/500" class="figure-img img-fluid border border-dark">
</div>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
Edit
So I went though the answers at How to resize Twitter Bootstrap modal dynamically based on the content
The only answer that sort of worked was adding style="max-width : 1200px;"to the div with bootstrap class of modal-dialog
<div id="full_size_image_dialog" class="modal">
<div class="modal-dialog modal-dialog-scrollable" style="max-width : 1200px;">
<div class="modal-content">
<div class="modal-header">
<h5>
Full Size artwork
</h5>
</div>
<div class="modal-body">
<img src="http://172.17.22.1:9790/minimserver/*/Music/PopRock/Lily*20Allen/Alright,*20Still/01*20-*20Smile.wav/$!picture-34755692-444226.jpg" class="figure-img img-fluid border border-dark">
<figcaption>
1200 x 1200
</figcaption>
</div>
</div>
</div>
</div>
The trouble is that if the actual height of the image is larger than the height of the browser window then the image has to be scrolled vertically
What I actually want is the full image to be displayed full size but only if enough room in browser, otherwise display the max size it can be displayed without vertical scrolling. I can set a lower value for max-width so it works on my window, but then that is not going to be great for users with bigger resolution windows.
It does handle preventing sideways scrolling okay, so if the width of window is too small to show whole image it will shrink image accordingly, and we can reasonably assume images will usually be square.
So my attempted solution was to use Bootstraps container system to set different max-width size for different screen widths using col-md, col-xl ectera. But the trouble is it seems from the help that modal windows need to use their own container within the modal-body div but this isn't going to help because the max-width style has to be applied at the modal div so is outside of modal-body scope.
I tried just utilising the main page container, but it just uses the first dialog code each time, i.e it never uses more than 700px max width
<div class="row g-0">
<div class="col p-2">
<div id="full_size_image_dialog" class="modal">
<div class="modal-dialog modal-dialog-scrollable" style="max-width : 700px;">
<div class="modal-content">
<div class="modal-header">
<h5>
Full Size artwork
</h5>
</div>
<div class="modal-body">
<img src="http://172.17.22.1:9790/minimserver/*/Music/PopRock/Lily*20Allen/Alright,*20Still/01*20-*20Smile.wav/$!picture-34755692-444226.jpg" class="figure-img img-fluid border border-dark">
<figcaption>
1200 x 1200
</figcaption>
</div>
</div>
</div>
</div>
</div>
<div class="col-md p-2">
<div id="full_size_image_dialog" class="modal">
<div class="modal-dialog modal-dialog-scrollable" style="max-width : 1200px;">
<div class="modal-content">
<div class="modal-header">
<h5>
Full Size artwork
</h5>
</div>
<div class="modal-body">
<img src="http://172.17.22.1:9790/minimserver/*/Music/PopRock/Lily*20Allen/Alright,*20Still/01*20-*20Smile.wav/$!picture-34755692-444226.jpg" class="figure-img img-fluid border border-dark">
<figcaption>
1200 x 1200
</figcaption>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row g-0">
<div class="col-7 col-md-6 col-lg-4 col-xl-3 p-2">
<a data-bs-toggle="modal" data-bs-target="#full_size_image_dialog">
<img src="http://172.17.22.1:9790/minimserver/*/Music/PopRock/Lily*20Allen/Alright,*20Still/01*20-*20Smile.wav/$!picture-34755692-444226.jpg" class="img-fluid border border-dark">
</a>
</div>
At the moment, this is the best solution I could come up with using only CSS:
.modal-dialog {
max-width: max-content !important;
}
.modal-body {
display: flex;
}
.modal-body img {
object-fit: contain;
}
Only problem is that white bars appear to the left and right of the image when screen height is less then image height.
This is because of the object-fit: contain; style which I added to the image to maintain the original aspect ratio. If you remove this style then then white bars will disappear but the image will not keep it's initial aspect ratio when it's height is shrinking.
JS Fiddle: https://jsfiddle.net/hvaosw5j/
So I'm trying to use tooltip component from BS5. But somehow it doesn't work. Let me show you the html code first.
<div class="row">
<div class="col-12 col-md-4">
<a class="card">
<div class="card-body">
<div class="card-title">this is title. <span class="badge badge-theme" data-bs-toggle="tooltip" data-bs-placement="top" title="this is tooltip">Origiinal content</span></div>
</div>
</a>
</div>
</div>
What's weird is that when I place the tooltip outside the card component, the tooltip works perfectly. What is the problem? Thanks in advance. :)
here is a working example of a tooltip on a whole card:
Working demo
Placing id="example" data-bs-toggle="tooltip" data-bs-placement="top" title="Tooltip on top" in my demo on any element will result in the tooltip appearing on that element. In this case, I placed it on on the div with the class .card.
Feel free to change the id name from example to your desired id (in both script.js and index.html).
I am using the jQuery UI sortable function on my page to sort a list of div, witch works fine. My problem is that when i start dragging a div or after I sort one or more divs, it breaks my design. Is there any way to prevent or fix this design issue when using jQuery UI sortable?
<div class="gentbl">
<div class="genrw">
<div class="rwttl">Title</div>
<div class="rwelm">Element</div>
</div>
<div class="genrw">
<div class="rwttl">Title</div>
<div class="rwelm">Element</div>
</div>
<div class="genrw">
<div class="rwttl">Title</div>
<div class="rwelm">Element</div>
</div>
<div class="genrw">
<div class="rwttl">Title</div>
<div class="rwelm">Element</div>
</div>
</div>
$(function(){
$('.gentbl').sortable({
revert: true
});
$('.gentbl').disableSelection();
});
Working example: HERE
Is there is any layout like this
http://layout.jquery-dev.net/samples/gispaho/layoutintab.htm which suport google map as a contend i use the above one. i got a problem, splitter drag fails over the google map.
Ref
https://stackoverflow.com/questions/15795815/jquery-dragable-fails-over-the-google-map
what i tried is
<div id="layout" class="sun-layout" style="height: 600px;">
<div class="ui-layout-west sun-layout">
<div class="map1">
</div>
</div>
<div class="ui-layout-center sun-layout">
<div class="map2">
</div>
</div>
in Dom ready
var $layout = $("#layout"); $layout.layout({
west__size: 400 });
We had the same problem in our application. We just show an invisible div over the map on the start of the resize and hide it at the end. That div will temporarily stop all mouse events from reaching the map. I imagine the same technique will work on your other question. As long as there is some way to hook into the resize start and resize end events, this should be effective.
So to apply it to your situation I would alter the html as such:
<div id="layout" class="sun-layout" style="height: 600px;">
<div class="ui-layout-west sun-layout">
<div class="map-mask"></div> <!-- Your map mask -->
<div class="map1">
</div>
</div>
<div class="ui-layout-center sun-layout">
<div class="map-mask"></div> <!-- Your map mask -->
<div class="map2">
</div>
</div>
Then I would add the following events to jquery UI layout:
.layout({
...
onresize_start: function(){
$(".map-mask").show();
},
onresize_end: function(){
$(".map-mask").hide();
},
...
})
And some CSS. I don't know what context the sizing is for map, so you will need to tailor this. The idea is to get the div in a z-index higher than the map and cover it completely.
.map-mask{
height:100%;
width:100%;
position: absolute;
z-index: 1000;
}