Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Raphael JS - creating a custom progress bar

I am trying to create a custom progress bar like in the image below:

Custom progress bar

I think my best options for creating this type of component is by using JavaScript and SVG or Canvas, and now I'm trying to create this in Raphael JS.

I was wondering if this is possible or if it's an incredible hard thing to do or maybe Raphael is not the best tool for doing this, I am pretty new to Raphael and all that I managed to do is to recreate the shapes by using Raphael JS.

window.onload = function() {
var paper = Raphael("holder", 500, 500);
var border = paper.path("M177.726,35.14c-6.51-19.56-24.73-30.02-46.369-35.14l-4.061,3.7c16.59,5.44,29.609,15.21,33.25,30.37c6.891,28.729-26.721,55.2-70.56,55.2c-43.84,0-77.45-26.471-70.55-55.2c3.64-15.16,16.65-24.93,33.24-30.37L48.616,0c-21.64,5.12-39.86,15.58-46.37,35.14c-12.83,38.52,31.03,74,87.74,74C146.696,109.14,190.556,73.66,177.726,35.14z M89.986,107.014c-33.546,0-64.678-13.115-79.311-33.411C2.173,61.81-0.044,48.742,4.263,35.812C9.725,19.401,24.444,8.14,48.018,2.332l0.595,0.542C31.43,9.313,20.658,19.875,17.369,33.574c-2.601,10.831,0.055,21.67,7.682,31.346c12.873,16.331,37.755,26.477,64.935,26.477c27.177,0,52.06-10.145,64.936-26.475c7.63-9.676,10.29-20.516,7.691-31.348c-3.289-13.696-14.065-24.26-31.253-30.701l0.594-0.542c23.574,5.809,38.293,17.069,43.754,33.48c4.307,12.93,2.09,25.998-6.412,37.791C154.663,93.898,123.532,107.014,89.986,107.014z");
var fill = paper.path("M173.587,33.481C168.126,17.069,153.407,5.809,129.833,0l-0.594,0.541c17.188,6.441,27.963,17.004,31.252,30.701c2.6,10.832-0.061,21.672-7.691,31.348c-12.875,16.33-37.758,26.475-64.936,26.475c-27.18,0-52.063-10.146-64.936-26.477c-7.627-9.676-10.283-20.516-7.682-31.346C18.536,17.543,29.309,6.981,46.491,0.542L45.896,0C22.322,5.809,7.603,17.069,2.142,33.48c-4.307,12.931-2.09,25.998,6.412,37.791c14.633,20.296,45.764,33.411,79.311,33.411s64.678-13.115,79.311-33.411C175.677,59.478,177.894,46.411,173.587,33.481z");

border.attr({
    fill: "#00FFFF",
});

fill.attr({
    fill: "#99FF00",
});
}

JS Fiddle with shapes

like image 812
hex Avatar asked Jun 12 '26 16:06

hex


1 Answers

It is better you go with Canvas using KineticJS or any other API which help in order to get you quick started with the geometrical shapes and its manipulation. Since you can easily use color transitions in order to get the progress you want to see. It would be good approach if you look into Canvas rather than SVG.

like image 66
Shiv Kumar Ganesh Avatar answered Jun 14 '26 06:06

Shiv Kumar Ganesh