This jquery plugin helps to generate SVG based RATING with various fancy features. Download and include this plugin in your html file.
Include jQuery and this plugin on your page.
<script src="https://github.com/senthilporunan/jRate/raw/master/jRate.js"></script>
<div id="jRate"></div>
$("#jRate").jRate();
<div class="jRate" id="somthingUnique"></div>
$(".jRate").jRate();
Note: remember to set a unique id on each element or it won't work!
Set your favourite start and end color. By giving value in the form of hex value, rgb value or standard color name. We can use one color format also by giving same start and end color.
$("#jRate").jRate({
startColor: "cyan",
endColor: "blue"
});
Set your own default initial value.
$("#jRate").jRate({
rating:2
});
We can customize our own value for width and height.
$("#jRate").jRate({
width: 70,
height: 70
});
We can chooose shape from available list. If you need more shapes, raise feature request in github. Available shapes are STAR, RECTANGLE, SQUARE, CIRCLE, RHOMBUS, TRIANGLE.
$("#jRate").jRate({
shape: 'RHOMBUS'
});
Make the shapes from smaller to bigger. We can use growth field to make this happen.
$("#jRate").jRate({
widthGrowth: 0.2,
heightGrowth: 0.2
});
Number of shapes was decided by the count parameter. We can customize own numeric value for it.
$("#jRate").jRate({
count: 10
});
Set your favourite background color. By giving value in the form of hex value, rgb value or standard color name.
$("#jRate").jRate({
backgroundColor: 'black'
});
Set transparency value between 0 and 1.
$("#jRate").jRate({
transparency: 0.5
});
We can set our own gap between two shapes. We can customize our own values in it.
$("#jRate").jRate({
shapeGap: '10px'
});
Set opacity value.
$("#jRate").jRate({
opacity: 0.3
});
Set a desired minimum and maximum value.
$("#jRate").jRate({
min: 10,
max: 15
});
Set the precision value.
$("#jRate").jRate({
precision: 0
});
Set the stroke width for STAR, CIRCLE, RECTANGLE, RHOMBUS, TRIANGLE only.
$("#jRate").jRate({
strokeWidth: '25px'
});
We can set a boolean variable to make horizontal or vertical. And, set a boolean value for reverse.
$("#jRate").jRate({
horizontal: false
});
We can set a boolean variable to make reverse or not.
$("#jRate").jRate({
reverse: true
});
Set the readonly value.
$("#jRate").jRate({
readOnly: true
});
Write your own methods to do own action when the rating value change action occurs.
$("#jRate").jRate({
onChange: function(rating) {
$('#demo-onchange-value').text("Your Rating: "+rating);
}
});
Write your own methods to do own action when the rating value click or set action occurs.
$("#jRate").jRate({
onSet: function(rating) {
$('#demo-onset-value').text("Selected Rating: "+rating);
}
});
This plugin is licensed under the MIT license.
Copyright (c) 2015 Senthil Porunan