Gradient smooth scroll on fullpage.js - gradient

http://www.symodd.com/ i really like the way the gradient changes on this website. i know that its using Fullpage.js for the scrolling but i cant figure out the gradient
so far i have tried changing the sectioncolor using JqueryUI but i cant figure out how to do the gradient
$(document).ready(function() {
$('#fullpage').fullpage({
sectionsColor: ['#f4efec to ', '#f4e0e9', '#f4d9d0', '#f4e3c9', '#b5dce1', '#d7e0b1'],
navigation: true ,
menu: '#fp-nav'
});
});

Related

Displaying only the cropperjs preview without the actual cropper

I am new to CropperJs. I am working on a Angular application and I would like to display the CropperJs preview without displaying the actual cropper.
Is this possible? I so how?
Here is my code:
Html:
<div class="preview">
<img
#image
[src]="urlSafe"
/>
</div>
Component:
public cropper: any;
#ViewChild('image', { static: false })
public image: ElementRef;
this.cropper = new Cropper(this.image.nativeElement, { preview: '.preview' });
this.cropper.setAspectRatio(this.selectedRatio.value);
Can anyone please help?
edit: I have put together a stackblitz here: https://stackblitz.com/edit/angular-ivy-xerqiw?file=src%2Fapp%2Fpreview%2Fpreview.component.ts
Can someone please have a look at it?
Initializing CropperJS with this option hides the crop area:
autoCrop: false
Might need to also disable cropper to prevent a user from drawing the crop area manually:
cropper.disable()

Chartjs + jsPDF = Blurry image

I'm having some issues exporting my Charts to PDF.
I have this div
<div id="chart-area">
<button type="button" id="btnPrint_" onClick="Print1()">Print</button>
<?php echo '<h2 id="title">'.$_SESSION['team_name'].'</h2>'; ?>
<canvas id="myChart" width="800" height="400"></canvas>
<div id="legend"></div>
</div>
and I'm creating my chart using ChartJS
$( document ).ready(function(){
var helpers = Chart.helpers;
var canvas = document.getElementById('myChart');
var data = {
labels: unique_dates,
datasets: [
{
label: "Ticket Count",
fillColor: "rgba(107, 110, 111, 0.6)",
strokeColor: "rgba(107, 110, 111, 0.6)",
highlightFill: "rgba(107, 110, 111, 0.6)",
highlightStroke: "rgba(151,137,200,1)",
data: ticket_count
},
{
label: "Subsidy Count",
fillColor: "rgba(8, 126, 210,0.5)",
strokeColor: "rgba(8, 126, 210,0.8)",
highlightFill: "rgba(220,220,220,0.75)",
highlightStroke: "rgba(220,220,220,1)",
data: subsidy_count
}
]
}
var bar = new Chart(canvas.getContext('2d')).Bar(data, {
tooltipTemplate: "<%if (label){%><%=label%>: <%}%><%= value %>kb",
animation: true,
});
//
var legendHolder = document.createElement('div');
legendHolder.innerHTML = bar.generateLegend();
document.getElementById('legend').appendChild(legendHolder.firstChild);
});
When I click the btnPrint_ Button I want to export my chart as PDF
like this
function Print1() {
var title = $("#title").text();
var doc = new jsPDF('l', 'mm',[210, 297]);
html2canvas($("#myChart"), {
onrendered: function(canvas) {
var imgData = canvas.toDataURL('image/png',1.0);
doc.text(130,15,title+" GT Log");
doc.addImage(imgData, 'PNG',20,30,0,130);
doc.addHTML(canvas);
doc.save(title+'gt_log.pdf');
}
});
}
The problem is that my chart is totally blurry in the pdf file.
Any idea how to fix this?
it's the first time that I'm using ChartJS and jsPDF so probably I'm doing something wrong.
Thanks!
The resolution comes from the Canvas size. The more you increase your Canvas (width and height), the better will be the resolution when downloading your PDF.
However, you probably don't want to increase the canvas size too much, so, one trick you could use is to create a hidden Canvas, with a higher width and height, use it to print the chart and create the PDF, getting a better PDF quality.
Here is a fiddle demonstrating this, with an option to download a PDF created from the original canvas/chart, and another option to download a new PDF from the hidden canvas/chart. You can see how the quality increase quite a bit when comparing both results.
https://jsfiddle.net/crabbly/kL68ey5z/
I don't think this is the best solution, however, it is the only way I could come up to increase the quality of my PDF chart files. I'm currently playing around both libraries, specially how jsPDF treats the w and h arguments when creating the docs.
Also, Chart.js does come with a built in function to extract an image form the chart (.toBase64Image()), however, the quality seems to be worse when I tested.
Since a few versions Chart.js has the parameter devicePixelRatio.
By default, the canvas is rendered in the DPI number by monitor, so 96 or Retina - not ideal for a printout, but perfect for the screen.
If you increase this value, more pixels are created. Expand the value so that you can export the chart in print quality as a Base64 image. The value does not affect the display of the chart on the monitor.
In my case, I set the value to 1.5.
options:{
devicePixelRatio: 1.5
}
Documentation: https://www.chartjs.org/docs/3.0.2/configuration/device-pixel-ratio.html
Works wonderfully ...
I've been working on a project trying to produce graphs with chartjs and then printing them using Chrome's print to PDF functionality, and I found that the chartjs graphs look poor. After reading various threads both on stackoverflow and github I developed one solution that worked well enough for me.
In my particular case I need the graphs at a fixed size and I can't have them be responsive because I need them to fit within the printed page correctly. I use style tags to set the size:
<canvas style="width: 300px; height: 300px" />
I've found that if you set responsive: false in the chart and then use the style tags like that, Chartjs won't mess with the size of the chart. Using any other method like setting width or height (not the style width or height) or using css classes will not set it properly. Chartjs only seems to work when I set the element's inline style tag for this.
Anyway, the trick that worked for me in getting better PDF output was to have Chartjs render a larger chart and then scaling it down to a smaller size so it fits on my page correctly.
Let's say for some reason we want a 300x300 pixel chart and that it looks poor when we print it to PDF. We need to have Chartjs draw this chart into a larger chart and then resize it down to 300x300. In my own project I am having Chartjs draw it 2x as large. So for this example I would make a canvas element that is 600x600 as follows:
<canvas style="width: 600px; height: 600px;" class="graph" />
At the same time I have a "graph" css class with height and width set to 300px. The chart will not render at 300px because of the inline style however.
You can then make the chart as you normally would, but immediately after the line of code that makes the chart, you remove the inline style tag from the chart. I found that when you do this, chartjs will draw the chart to the larger
600x600 size but then the chart instantly gets resized to 300x300. Here is an example of what the code looks like:
var ctx = canvas.getContext('2d'); var mychart = new Chart( ctx ,{ ....
}); canvas.removeAttribute("style");
The canvas.removeAttribute removes the inline style tag, so then the css class
takes effect and instantly causes the canvas to re-render at the smaller size. There is no flash or any indication that this has happened, yet I've found that you get a much higher quality looking chart.
There is one other issue with this. You will have to design your chart for the larger 600x600 size for example in order to get it to look right. When you draw the chart at a larger size, the lines and fonts don't get resized so everything looks really tiny. I had to set my chart manually to the larger size to design it and figure out good fonts and line sizes for the graph first, and then do the resize trick here.
I have also found that simply using the smaller sized chart and making thicker lines or larger fonts does not seem to have the same effect as sizing everything up first, and then rendering it as a smaller size.

Using the same view twice but with different values

I have a view that i want to use twice but with different values.
{{#view App.ColorPickerView sytleName="Background Color" css="bgColor"}}
{{view.sytleName}}
{{/view}}
{{#view App.ColorPickerView sytleName="Text Color" css="textColor"}}
{{view.sytleName}}
{{/view}}
This should be easy.
Please see this jsfiddle http://jsfiddle.net/rmossuk/LUEUV/11/
Basically when you click on Background Color it should change the background color but it is changing the text color as it seems to be using the next instance of the view.
Anyone help me with this ?
Thank you
Rick
The answer is very simple, in the didInsertElement, you declare the view as global, so when instanciating the second ColorPicker, the view in onChange method of the first color picker refers to the second view.
Declaring view with var view = this; makes the code work.

Jquery UI datepicker change background color for a day

I am using Jquery UI datepicker and I am trying to change the background color for each day in a month.
For this I am using beforeShowDay function in Jquery UI date-picker.
As an example I am trying to change the background color for odd days in a month and my script changes only border color.
I am not sure where the mistake is, How do I over ride the entire back ground color in Jquery to achieve the desired result.
please help.
Script Used:
$(document).ready(function() {
//$("#datepicker").datepicker();
$("#datepicker").datepicker({ inline: true, beforeShowDay: highlightOdds});
});
function highlightOdds(date) {
return [true, date.getDate() % 2 == 1 ? 'odd' : ''];
}
Css Used:
.odd { background-color: green; }
hii All I found it myself,
I just modifed the css as given below and it works cool :)
.odd a.ui-state-default {color:white;
background-color: red;
background: red;}
thank u all :)

Sidebar height 100% with changing size of div in browser

I got a problem with my website.
On the left I have a sidebar, and next to it I have the container.
At the moment I have found this javascript function:
$(document).ready(function(){
$("#sidebar").height( $(document).height() );
});
This script makes sure that my sidebar is 100%. Also if I resize the screen, the sidebar automatically changes height.
The problem is that I have a dashboard in my container with moving divs, who can change size and are stackable underneath each other. (example: http://demo.webdeveloperplus.com/drag-drop-panels/)
If I stack these divs underneath each other, the sidebar does not change height automatically. How can I make sure that the sidebar is also changing height when I stack these divs in the container? Do I need to loop the script?
Hope someone can help me with this.
(ps. I do not have a footer in my website so the sidebar has to keep on the height of the document. (background))
Ok, this is a two part answer. Part one is that you will need to get the height of the viewport for the browser. Part two is that you will need to re-do this function whenever the window resizes. after some testing (in IE 9, Chrome and FF) I've found this to work well:
function getClientHeight() {
var retval = 0;
if (typeof (window.innerHeight) == 'number') {
retval = window.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) {
retval = document.documentElement.clientHeight;
} else if (document.body && document.body.clientHeight) {
retval = document.body.clientHeight;
}
return retval;
}
$(document).ready(function () {
$(window).resize(function (event) {
$("#sidebar").height(getClientHeight());
});
$("#sidebar").height(getClientHeight());
});
I Fixed the problem now. I used another way to set the height of the sidebar always 100%.
For people who want to know how I fixed this:
I gave the #sidebar style: position: fixed; and putted the divs inside the sidebar outside of the div and made a new div #sidebarcontent. Then gave the #sidebarcontent style position: absolute; and placed them on the right place. I tested this for cross browser and it worked even on IE6.