SVG attribute stroke-dasharray in the Vue component - svg

Help me to represent this element as a vue-component, where
.circle-chart-percent text (user defined value) == .circle-chart-circle stroke-dasharray.
<svg class="circle-chart" viewbox="0 0 33.83098862 33.83098862" width="200" height="200" xmlns="http://www.w3.org/2000/svg">
<circle class="circle-chart-background" stroke="#cccccc" stroke-width="0.35" stroke-dasharray="100" fill="none" cx="16.91549431" cy="16.91549431" r="15.91549431" />
<circle class="circle-chart-circle" stroke="#4f5357" stroke-width="0.5" stroke-dasharray="90" stroke-linecap="round" fill="none" cx="16.91549431" cy="16.91549431" r="15.91549431" />
<g class="circle-chart-info">
<text class="circle-chart-percent" x="16.91549431" y="15.5" alignment-baseline="central" text-anchor="middle" font-size="8">30%</text>
<text class="circle-chart-subline" x="16.91549431" y="20.5" alignment-baseline="central" text-anchor="middle" font-size="2">name</text>
</g>
</svg>
<script>
var svg = document.querySelector('.circle-chart-circle');
att = svg.getAttribute('stroke-dasharray');
text = document.querySelector('text.circle-chart-percent');
if (att === '100') {
text.textContent = 'full';
}
else {
text.textContent = att + '%';
}
</script>
<style>
.circle-chart-circle {
animation: circle-chart-fill 2s reverse;
transform: rotate(-90deg);
transform-origin: center;
}
.circle-chart-info {
animation: circle-chart-appear 2s forwards;
opacity: 0;
transform: translateY(0.3em);
}
#keyframes circle-chart-fill {
to {
stroke-dasharray: 0 100;
}
}
#keyframes circle-chart-appear {
to {
opacity: 1;
transform: translateY(0);
}
}
</style>
https://codepen.io/pershay/pen/gjyKme

Follow Vue Guide: style-binding, then you will reach goal easily.
Below is one simple demo:
bind :stroke-dasharray="progress"
create one computed property=computedText to return the progress description (in your codes, it is text.textContent = 'full'; or att+'%')
Vue.component('svg-circle', {
template: `<svg class="circle-chart" viewBox="0 0 33.83098862 33.83098862" width="200" height="200" xmlns="http://www.w3.org/2000/svg">
<circle class="circle-chart-background" stroke="#cccccc" stroke-width="0.35" stroke-dasharray="100" fill="none" cx="16.91549431" cy="16.91549431" r="15.91549431" />
<circle class="circle-chart-circle" stroke="#4f5357" stroke-width="0.5" :stroke-dasharray="progress" stroke-linecap="round" fill="none" cx="16.91549431" cy="16.91549431" r="15.91549431" />
<g class="circle-chart-info">
<text class="circle-chart-percent" x="16.91549431" y="15.5" alignment-baseline="central" text-anchor="middle" font-size="8">{{computedText}}</text>
<text class="circle-chart-subline" x="16.91549431" y="20.5" alignment-baseline="central" text-anchor="middle" font-size="2">name</text>
</g>
</svg>
`,
props: ['progress'],
computed: {
computedText: function () {
let description = ''
let progress = this.progress < 0 ? 0 : (this.progress > 100 ? 100 : this.progress)
if (progress === '100') {
description = 'full';
}
else {
description = progress + '%';
}
return description
}
}
})
new Vue({
el: '#app',
data() {
return {
progress: 10
}
},
methods:{
changeProgress: function () {
this.progress += 10
}
}
})
.circle-chart-circle {
animation: circle-chart-fill 2s reverse;
transform: rotate(-90deg);
transform-origin: center;
}
.circle-chart-info {
animation: circle-chart-appear 2s forwards;
opacity: 0;
transform: translateY(0.3em);
}
#keyframes circle-chart-fill {
to { stroke-dasharray: 0 100;
}
} #keyframes circle-chart-appear {
to { opacity: 1; transform: translateY(0); }
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.16/vue.js"></script>
<div id="app">
<button v-on:click="changeProgress()">Change Progress - {{progress}}</button>
<div>
<svg-circle :progress="progress">
</svg-circle>
</div>
</div>

Related

Safari won't rotate an SVG path but chrome and firefox does?

I'm running into an extremely odd issue. I'm trying to animate an SVG path rotation based on an image hover. It seems to not add the class with the transform when you hover over the image. When I manually add it in the HTML it does work but I don't get why it won't work with just a hover function. I have added all the prefixes too. I made a codepen with an example SVG and image to hover. Please check this in safari and chrome.
Codepen link
HTML
<div class="wrapper-logo">
<svg class="App-logo" viewBox="0 0 375 84" fill="#DB3232" xmlns="http://www.w3.org/2000/svg">
<path class="LETTER-P" d="M39.3,6.1c9.59-.72,18.89,2.31,26.17,8.58,14.99,12.98,16.72,35.69,3.68,50.69-12.98,15.07-35.76,16.8-50.75,3.82-2.52-2.24-4.76-4.83-6.63-7.64v14.13c0,1.59-1.3,2.88-2.88,2.88s-2.88-1.3-2.88-2.88V41.94c0-8.58,3.1-16.94,8.72-23.43,6.27-7.28,14.99-11.68,24.58-12.4Z" />
</svg>
</div>
<svg class="App-pill" viewBox="0 0 375 84" fill="#DB3232" xmlns="http://www.w3.org/2000/svg"> <defs>
<mask id="mask-p">
<path class="LETTER-P" d="M39.3,6.1c9.59-.72,18.89,2.31,26.17,8.58,14.99,12.98,16.72,35.69,3.68,50.69-12.98,15.07-35.76,16.8-50.75,3.82-2.52-2.24-4.76-4.83-6.63-7.64v14.13c0,1.59-1.3,2.88-2.88,2.88s-2.88-1.3-2.88-2.88V41.94c0-8.58,3.1-16.94,8.72-23.43,6.27-7.28,14.99-11.68,24.58-12.4Z" fill="white"/>
<path class='pill-1' d="M47.3377 18.8021L18.8226 47.1101C13.7279 52.1678 13.7293 60.3942 18.8258 65.3743C23.9223 70.4298 32.2122 70.4281 37.2309 65.3704L65.746 37.0624C68.2554 34.5713 69.5477 31.2502 69.5471 27.9295C69.5465 24.6087 68.253 21.2882 65.7428 18.7982C60.7223 13.7426 52.4325 13.7444 47.3377 18.8021Z" fill="black"/>
</mask>
</defs>
</svg>
<footer>
<img src="https://via.placeholder.com/150
C/O https://placeholder.com/" class="shoes small" alt="browns" onmouseover="rotateBrowns(this)" />
</footer>
CSS
.App-pill {
display: block;
width: 0;
height: 0;
}
.App-logo {
min-width: 50%;
pointer-events: none;
}
/* LETTER */
.LETTER-P {
-webkit-mask: url(#mask-p);
mask: url(#mask-p);
}
.pill-1 {
-webkit-transform: rotate(0deg);
-ms-transform: rotate(0deg);
transform: rotate(0deg);
-webkit-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
-webkit-transform-origin: 42px 41px;
-ms-transform-origin: 42px 41px;
transform-origin: 42px 41px;
}
.horizontal {
-webkit-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);
}
JS
let shoesarray = document.querySelectorAll('.shoes')
let path1 = document.querySelector('.pill-1')
let path2 = document.querySelector('.pill-1')
let path3 = document.querySelector('.pill-1')
let path4 = document.querySelector('.pill-1')
function rotateBrowns() {
console.log('e')
path1.classList.add('horizontal')
path2.classList.add('horizontal')
path3.classList.add('horizontal')
path4.classList.add('horizontal')
}
function revertBrowns() {
console.log('e')
path1.classList.remove('horizontal')
path2.classList.remove('horizontal')
path3.classList.remove('horizontal')
path4.classList.remove('horizontal')
}

svg tooltip on mouse hover position

I'm working on a svg, a tooltip must appear on hover, but the problem is that tooltips appear far from the desired location.
The svg is a map and that's why the tooltip's location must be precise. First intention that the svg itself is the problem but after checking with another one which works perfectly I didn't find the source of the problem.
the actual result:
the desired one:
the yellow part is where the hover happen in the map.
Part of the svg code:
<svg id="Layer_0" data-name="Layer 0" xmlns="http://www.w3.org/2000/svg" width="529.017" height="491.509" viewBox="0 0 529.017 491.509">
<defs>
<style>
.cls-5898b1 {
fill: #5898b1 ;
}
.cls-f9f9f9 {
fill: #f9f9f9 ;
}
.cls-061d53 {
fill: #061d53 ;
}
.cls-5898b1, .cls-f9f9f9, .cls-061d53, .cls-IDF {
stroke: #061d53;
stroke-width: 0.5px;
}
.cls-f9f9f9-nostroke {
fill: #f9f9f9;
}
.cls-IDF {
fill: #bee0e0;
}
/* .mapImage, .mapImageMobile { */
/* float: left; */
/* width: 100%; */
/* } */
.mapImage path, .mapImageMobile path {
stroke-width: 1px;
}
.mapImage polygon, .mapImageMobile polygon {
stroke-width: 1px;
}
.mapImage path:hover, .mapImage polygon:hover, .mapImageMobile path:hover,
.mapImageMobile polygon:hover {
fill: #ffcb00;
}
.cls-1, .cls-4 {
stroke: #C4C4C4;
}
.st0 {
fill: #000000;
}
.cls-1, .cls-3, .cls-2 {
fill: transparent;
}
<g id="Groupe_1355" data-name="Groupe 1355" transform="translate(-129.507 -2290.08)">
<g id="Groupe_1190" data-name="Groupe 1190" transform="translate(-35.507 2042.682)">
<a id="centre" style="stroke:#061D53;">
<path id="FR-F" class="cls-f9f9f9-nostroke" data-name="Tracé 1042" d="M2822.574,2031.032a.545.545,0,0,1-.094-.146,10,10,0,0,1,0-3.668c.084-.661.556-1.926.667-2.583.064-.382-.071-1.209.125-1.542.248-.421,1.289-.729,1.625-1.083a7.25,7.25,0,0,0,1.292-2.167,19.775,19.775,0,0,0,.083-2.125,20.276,20.276,0,0,1,.75-3c.172-.478.755-1.34.875-1.834.161-.668-.172-2.111.083-2.75a3.738,3.738,0,0,1,1.375-1.542,3.789,3.789,0,0,1,1.709,0c.388.08,1.067.562,1.458.625a1.778,1.778,0,0,0,1-.083c.406-.3.38-1.531.75-1.875a4.486,4.486,0,0,1,1.834-.583,12.812,12.812,0,0,0,1.292,0c.418-.125,1.04-.834,1.458-.958.469-.14,1.515.206,1.959,0a2.524,2.524,0,0,0,.917-1.084c.147-.4-.118-1.3,0-1.708a3.525,3.525,0,0,1,.959-1.542c.441-.287,1.609-.064,2.084-.292a4.236,4.236,0,0,0,1.375-1.292c.323-.575.277-1.98.542-2.584.18-.41.952-1.019,1.042-1.458.107-.523-.7-1.609-.459-2.084s1.631-.473,2-.875a4.753,4.753,0,0,0,.75-2.208c.024-.371-.3-1.087-.292-1.458.019-.614.86-1.808.625-2.376-.166-.4-1.393-.454-1.5-.875s.6-1.135.875-1.459c.212-.248.875-.533,1-.833.141-.338-.328-1.154-.125-1.459s1.171-.178,1.417-.458a1.528,1.528,0,0,0,.208-1.125,1.348,1.348,0,0,0-.667-.5c-.238-.079-.775.108-1,0a2.837,2.837,0,0,1-.853-.986c-.059-.1-.109-.189-.147-.264a4.525,4.525,0,0,1-.5-1.833c.038-.362.614-.933.667-1.292a3.093,3.093,0,0,0-.292-1.542c-.137-.221-.663-.429-.833-.625-.281-.323-.875-1.074-.833-1.5a2.776,2.776,0,0,1,1.333-1.584c.5-.206,1.633.313,2.167.208a4.927,4.927,0,0,0,1.667-.875,7.99,7.99,0,0,0,1.208-1.667,10.572,10.572,0,0,0,1.083-2.625,5.313,5.313,0,0,0-.25-2.5c-.141-.254-.753-.469-.917-.708a12.664,12.664,0,0,1-.583-2,5.6,5.6,0,0,0-.958-1.917c-.219-.172-.842-.113-1.083-.25a4.216,4.216,0,0,1-1.25-1.292,4.653,4.653,0,0,1-.375-2.084,3.471,3.471,0,0,1,.367-.953,4.334,4.334,0,0,1,.592-.881,5.386,5.386,0,0,1,1.709-1c.657-.211,2.113.016,2.75-.25.553-.23,1.324-1.227,1.834-1.542a7.255,7.255,0,0,1,1.542-.667,16.14,16.14,0,0,1,1.667-.125c.732-.074,2.221-.613,2.917-.375.321.109.633.867.958.958a2.907,2.907,0,0,0,1.375-.333,7.579,7.579,0,0,0,2.125-1.375,6.794,6.794,0,0,0,.625-1.375,6.764,6.764,0,0,1,.75-1.792c.329-.314,1.339-.359,1.709-.625a2.534,2.534,0,0,0,.833-1.042c.079-.368-.428-1.086-.375-1.458a2.924,2.924,0,0,1,.667-1.125,7.51,7.51,0,0,1,1.258-.661,5.364,5.364,0,0,1,.77,1.23c.089.322-.11,1.019,0,1.333.177.5,1.107,1.185,1.334,1.667a4.512,4.512,0,0,1,.279,1.334,16.093,16.093,0,0,0-.279,1.834,8.07,8.07,0,0,0,.667,1.167,7.467,7.467,0,0,1,.667,2.112c.007.594-.847,1.713-.667,2.278.1.32.862.559,1.056.833.272.383.315,1.413.611,1.778.153.189.643.351.833.5a5.356,5.356,0,0,1,1.223,1.223c.2.4.027,1.405.278,1.778.271.4,1.27.72,1.667,1,.25.177.836.492.945.779.18.472-.364,1.5-.306,2a3.339,3.339,0,0,0,.583,1.444,3.058,3.058,0,0,0,1.195.556c.278.061.873-.1,1.139,0,.376.145.836.9,1.2,1.083.31.157,1.094.057,1.362.278a5.025,5.025,0,0,1,.944,2.278c.094.47-.179,1.473,0,1.917.153.381.985.8,1.139,1.181a3.008,3.008,0,0,1,0,1.32c-.057.255-.444.684-.445.945a1.046,1.046,0,0,0,.306.653c.3.194,1.063.066,1.417.042a2.332,2.332,0,0,0,1-.167c.175-.141.149-.705.334-.833.282-.2,1.031-.037,1.375-.042a4.759,4.759,0,0,0,1.25,0,1.625,1.625,0,0,0,.667-.625c.1-.229-.153-.8,0-1a1.527,1.527,0,0,1,1.125-.292c.414.086,1.013.766,1.333,1.042.262.227.654.938,1,.958.416.025,1.09-.662,1.333-1,.116-.16.09-.634.25-.75a1.446,1.446,0,0,1,1.125,0c.284.162.383.964.667,1.125.417.237,1.516-.263,1.917,0,.371.242.617,1.191.708,1.625.085.407-.25,1.333,0,1.667s1.285.173,1.584.458a4.559,4.559,0,0,1,.708,2.084,3.276,3.276,0,0,1-.083,1.458c-.172.329-1,.583-1.167.917a1.689,1.689,0,0,0,0,1.167,1.655,1.655,0,0,0,1,.542c.35.018.968-.409,1.292-.542a7.726,7.726,0,0,1,1.458-.583,7.4,7.4,0,0,1,1.931.292,9.191,9.191,0,0,0,1.584.556,4.1,4.1,0,0,0,1.889-.695c.236-.194.39-.864.639-1.042a2.652,2.652,0,0,1,1.167-.263,3.458,3.458,0,0,1,1.167.263c.279.142.634.781.944.82a2.181,2.181,0,0,0,1.223-.612c.21-.2.3-.879.556-1.028.193-.115.682.033,1.06.1a1.526,1.526,0,0,0,.176.564,2.168,2.168,0,0,0,.916.583c.24.07.759-.063,1,0a2.084,2.084,0,0,1,1.042.583c.218.392-.189,1.356-.083,1.792a4.048,4.048,0,0,0,.917,1.584,9.343,9.343,0,0,0,1.375.542c.224.12.716.357.834.583a4.751,4.751,0,0,1,0,2.334,5.606,5.606,0,0,1-.792,1.833c-.208.255-.915.468-1.084.75-.188.315.061,1.17-.167,1.459-.322.408-1.659.282-1.958.708a2.309,2.309,0,0,0,0,1.458c.087.288.6.707.667,1a4.265,4.265,0,0,1-.25,1.625,4.537,4.537,0,0,1-.583,1.167c-.133.16-.541.334-.667.5-.175.231-.2.893-.417,1.083a2.6,2.6,0,0,1-1.459.333c-.2-.02-.545-.32-.75-.333a2.863,2.863,0,0,0-1.542.458,2.456,2.456,0,0,0-.625,1.417,3.426,3.426,0,0,0,.917,1.667c.344.321,1.411.427,1.709.792a5.322,5.322,0,0,1,.5,2.125c.049.424-.169,1.316,0,1.708.113.264.7.538.833.792a2.246,2.246,0,0,1,.209,1.25,2.986,2.986,0,0,1-1.083,1.125c-.26.156-.964.108-1.167.333a1.617,1.617,0,0,0-.208,1.167c.1.279.755.522.875.792.182.409-.132,1.363,0,1.792.1.337.692.828.792,1.167a4.344,4.344,0,0,1-.042,1.667,6.105,6.105,0,0,1-.75,1.542c-.179.252-.757.589-.875.875a3.652,3.652,0,0,0,0,1.625,4.967,4.967,0,0,0,.875,1.875c.3.3,1.22.432,1.542.709a4.581,4.581,0,0,1,.875,1.333c.265.648.18,2.15.542,2.75.18.3.917.569,1.084.875a5.666,5.666,0,0,1,.25,2.292c-.028.48-.412,1.395-.431,1.875a4.436,4.436,0,0,0,.278,1.861c.245.4,1.218.755,1.528,1.112a4.5,4.5,0,0,1,.861,1.611,8.536,8.536,0,0,1-.444,2.695c-.126.454-.618,1.286-.694,1.75a6.316,6.316,0,0,0,.083,1.7c.084.427.589,1.2.583,1.639a6.057,6.057,0,0,1-.7,1.806,9.875,9.875,0,0,0-.944,1.612,2.345,2.345,0,0,0,.043.756c-.3-.048-.6-.121-.766-.145-.43-.063-1.244-.607-1.667-.5-.3.077-.629.711-.889.889-.426.292-1.539.454-1.889.833-.229.25-.243,1.006-.444,1.279a2.911,2.911,0,0,1-1.056.777c-.554.182-2-.481-2.334,0-.152.222.54.779.389,1s-.792,0-1.055,0a7.7,7.7,0,0,0-1.557,0c-.36.1-.917.677-1.277.778-.307.087-1.079-.25-1.278,0s.278,1.223,0,1.333a4.9,4.9,0,0,0-1.445.612,1.693,1.693,0,0,0-.333,1c.02.148.32.35.333.5.02.21-.349.567-.333.778.021.292.5.73.612,1,.177.422.726,1.417.444,1.778-.086.11-.43-.059-.556,0-.339.162-.616.986-.944,1.167a5.688,5.688,0,0,1-2.834.333c-.373-.071-.954-.729-1.334-.722-.355.007-.924.531-1.223.722-.227.145-.662.465-.888.612-.724.466-2.522,1.029-2.946,1.778-.177.314.182,1.133,0,1.444-.194.33-1.075.453-1.358.744a4.049,4.049,0,0,0-1.753.062c-.307.12-.469.912-.75,1.084a6.319,6.319,0,0,1-3.834.5c-.273-.089-.567-.685-.833-.792-.62-.248-2.011.12-2.667,0-.548-.1-1.535-.691-2.083-.792a6.887,6.887,0,0,0-2,0c-.469.1-1.276.874-1.75.792s-.959-1.189-1.417-1.375c-.328-.133-1.2-.278-1.417,0-.346.435.566,1.615.5,2.167-.033.278-.223.967-.5,1-.407.049-.668-1.142-1.064-1.25a2.39,2.39,0,0,0-1.853.639c-.149.209.182.846,0,1.028a1.85,1.85,0,0,1-1.834,0c-.316-.317.268-1.433,0-1.792-.195-.262-.927-.328-1.25-.375a5.1,5.1,0,0,0-1.917,0,3.008,3.008,0,0,0-1.25,1.139c-.1.235.133.808,0,1.028-.28.462-1.421.784-1.917,1-.344.15-1.079.663-1.417.5-.4-.191-.3-1.329-.583-1.667a2.894,2.894,0,0,0-1.584-.875,1.829,1.829,0,0,0-.917.542c-.2.222-.252.918-.5,1.083a3.261,3.261,0,0,1-2.084.083,4.657,4.657,0,0,1-1.028-.833c-.149-.128-.45-.3-.678-.489a.745.745,0,0,1-.294-.387c-.078-.485.989-1.218.973-1.709a1.705,1.705,0,0,0-.556-.833c-.348-.3-1.469-.338-1.667-.75-.252-.524.6-1.669.583-2.25a2.908,2.908,0,0,0-.583-1.75c-.338-.243-1.256-.068-1.667,0-.51.084-1.479.86-1.959.667-.674-.271-.809-2.08-1.333-2.583-.464-.445-1.854-.656-2.334-1.084a5.866,5.866,0,0,1-1.584-2.584c-.067-.529.546-1.514.625-2.042a6.676,6.676,0,0,0,0-2.129,7.393,7.393,0,0,0-1.292-2.038c-.411-.464-1.6-1.04-1.917-1.57-.395-.649-.208-2.339-.625-2.973-.358-.543-1.72-.991-2.125-1.5a9.785,9.785,0,0,1-.75-1.833c-.306-.732-.675-2.371-1.25-2.917-.282-.269-1.134-.326-1.458-.542-.405-.269-.87-1.272-1.333-1.417a1.485,1.485,0,0,0-1.167.25c-.3.365.164,1.437,0,1.876a1.525,1.525,0,0,1-.542.625c-.442.213-1.529-.151-1.959.083-.269.147-.436.859-.708,1a2.222,2.222,0,0,1-.958,0c-.649-.078-1.888-.635-2.542-.625-.313,0-.912.435-1.209.333a3.476,3.476,0,0,1-1.458-1.959c-.112-.486.372-1.46.375-1.959a4.754,4.754,0,0,0-.375-2.083,2.5,2.5,0,0,0-1.209-.708c-.3-.055-.933.344-1.208.208-.4-.2-.5-1.29-.833-1.583-.368-.321-1.459-.355-1.833-.667-.521-.433-.969-1.792-1.375-2.334C2823,2031.41,2822.728,2031.213,2822.574,2031.032Z" transform="translate(-2481.446 -1580.518)">
<title transform="translate(-2481.446 -1580.518)">Centre Val de Loire</title>
</path>
</a>
It appear that the bug appears just on large size desktops, in medium size the tooltip works perfectly.
You need to add closing tags </style>,</defs> </g> </svg>
Move <title> tag from path inside<a>link tags
Remove from <title> transform = "translate (-2481.446 -1580.518)
<svg id="Layer_0" data-name="Layer 0" xmlns="http://www.w3.org/2000/svg" width="529.017" height="491.509" viewBox="0 0 529.017 491.509">
<defs>
<style>
.cls-5898b1 {
fill: #5898b1 ;
}
.cls-f9f9f9 {
fill: #f9f9f9 ;
}
.cls-061d53 {
fill: #061d53 ;
}
.cls-5898b1, .cls-f9f9f9, .cls-061d53, .cls-IDF {
stroke: #061d53;
stroke-width: 0.5px;
}
.cls-f9f9f9-nostroke {
fill: #f9f9f9;
}
.cls-IDF {
fill: #bee0e0;
}
/* .mapImage, .mapImageMobile { */
/* float: left; */
/* width: 100%; */
/* } */
.mapImage path, .mapImageMobile path {
stroke-width: 1px;
}
.mapImage polygon, .mapImageMobile polygon {
stroke-width: 1px;
}
.mapImage path:hover, .mapImage polygon:hover, .mapImageMobile path:hover,
.mapImageMobile polygon:hover, path:hover {
fill: #ffcb00;
}
.cls-1, .cls-4 {
stroke: #C4C4C4;
}
.st0 {
fill: #000000;
}
.cls-1, .cls-3, .cls-2 {
fill: transparent;
}
</style>
</defs>
<g id="Groupe_1355" data-name="Groupe 1355" transform="translate(-129.507 -2290.08)">
<g id="Groupe_1190" data-name="Groupe 1190" transform="translate(-35.507 2042.682)">
<a id="centre" style="stroke:#061D53;">
<title transform="translate(-2481.446 -1580.518)">Centre Val de Loire</title>
<path id="FR-F" class="cls-f9f9f9-nostroke" data-name="Tracé 1042" d="M2822.574,2031.032a.545.545,0,0,1-.094-.146,10,10,0,0,1,0-3.668c.084-.661.556-1.926.667-2.583.064-.382-.071-1.209.125-1.542.248-.421,1.289-.729,1.625-1.083a7.25,7.25,0,0,0,1.292-2.167,19.775,19.775,0,0,0,.083-2.125,20.276,20.276,0,0,1,.75-3c.172-.478.755-1.34.875-1.834.161-.668-.172-2.111.083-2.75a3.738,3.738,0,0,1,1.375-1.542,3.789,3.789,0,0,1,1.709,0c.388.08,1.067.562,1.458.625a1.778,1.778,0,0,0,1-.083c.406-.3.38-1.531.75-1.875a4.486,4.486,0,0,1,1.834-.583,12.812,12.812,0,0,0,1.292,0c.418-.125,1.04-.834,1.458-.958.469-.14,1.515.206,1.959,0a2.524,2.524,0,0,0,.917-1.084c.147-.4-.118-1.3,0-1.708a3.525,3.525,0,0,1,.959-1.542c.441-.287,1.609-.064,2.084-.292a4.236,4.236,0,0,0,1.375-1.292c.323-.575.277-1.98.542-2.584.18-.41.952-1.019,1.042-1.458.107-.523-.7-1.609-.459-2.084s1.631-.473,2-.875a4.753,4.753,0,0,0,.75-2.208c.024-.371-.3-1.087-.292-1.458.019-.614.86-1.808.625-2.376-.166-.4-1.393-.454-1.5-.875s.6-1.135.875-1.459c.212-.248.875-.533,1-.833.141-.338-.328-1.154-.125-1.459s1.171-.178,1.417-.458a1.528,1.528,0,0,0,.208-1.125,1.348,1.348,0,0,0-.667-.5c-.238-.079-.775.108-1,0a2.837,2.837,0,0,1-.853-.986c-.059-.1-.109-.189-.147-.264a4.525,4.525,0,0,1-.5-1.833c.038-.362.614-.933.667-1.292a3.093,3.093,0,0,0-.292-1.542c-.137-.221-.663-.429-.833-.625-.281-.323-.875-1.074-.833-1.5a2.776,2.776,0,0,1,1.333-1.584c.5-.206,1.633.313,2.167.208a4.927,4.927,0,0,0,1.667-.875,7.99,7.99,0,0,0,1.208-1.667,10.572,10.572,0,0,0,1.083-2.625,5.313,5.313,0,0,0-.25-2.5c-.141-.254-.753-.469-.917-.708a12.664,12.664,0,0,1-.583-2,5.6,5.6,0,0,0-.958-1.917c-.219-.172-.842-.113-1.083-.25a4.216,4.216,0,0,1-1.25-1.292,4.653,4.653,0,0,1-.375-2.084,3.471,3.471,0,0,1,.367-.953,4.334,4.334,0,0,1,.592-.881,5.386,5.386,0,0,1,1.709-1c.657-.211,2.113.016,2.75-.25.553-.23,1.324-1.227,1.834-1.542a7.255,7.255,0,0,1,1.542-.667,16.14,16.14,0,0,1,1.667-.125c.732-.074,2.221-.613,2.917-.375.321.109.633.867.958.958a2.907,2.907,0,0,0,1.375-.333,7.579,7.579,0,0,0,2.125-1.375,6.794,6.794,0,0,0,.625-1.375,6.764,6.764,0,0,1,.75-1.792c.329-.314,1.339-.359,1.709-.625a2.534,2.534,0,0,0,.833-1.042c.079-.368-.428-1.086-.375-1.458a2.924,2.924,0,0,1,.667-1.125,7.51,7.51,0,0,1,1.258-.661,5.364,5.364,0,0,1,.77,1.23c.089.322-.11,1.019,0,1.333.177.5,1.107,1.185,1.334,1.667a4.512,4.512,0,0,1,.279,1.334,16.093,16.093,0,0,0-.279,1.834,8.07,8.07,0,0,0,.667,1.167,7.467,7.467,0,0,1,.667,2.112c.007.594-.847,1.713-.667,2.278.1.32.862.559,1.056.833.272.383.315,1.413.611,1.778.153.189.643.351.833.5a5.356,5.356,0,0,1,1.223,1.223c.2.4.027,1.405.278,1.778.271.4,1.27.72,1.667,1,.25.177.836.492.945.779.18.472-.364,1.5-.306,2a3.339,3.339,0,0,0,.583,1.444,3.058,3.058,0,0,0,1.195.556c.278.061.873-.1,1.139,0,.376.145.836.9,1.2,1.083.31.157,1.094.057,1.362.278a5.025,5.025,0,0,1,.944,2.278c.094.47-.179,1.473,0,1.917.153.381.985.8,1.139,1.181a3.008,3.008,0,0,1,0,1.32c-.057.255-.444.684-.445.945a1.046,1.046,0,0,0,.306.653c.3.194,1.063.066,1.417.042a2.332,2.332,0,0,0,1-.167c.175-.141.149-.705.334-.833.282-.2,1.031-.037,1.375-.042a4.759,4.759,0,0,0,1.25,0,1.625,1.625,0,0,0,.667-.625c.1-.229-.153-.8,0-1a1.527,1.527,0,0,1,1.125-.292c.414.086,1.013.766,1.333,1.042.262.227.654.938,1,.958.416.025,1.09-.662,1.333-1,.116-.16.09-.634.25-.75a1.446,1.446,0,0,1,1.125,0c.284.162.383.964.667,1.125.417.237,1.516-.263,1.917,0,.371.242.617,1.191.708,1.625.085.407-.25,1.333,0,1.667s1.285.173,1.584.458a4.559,4.559,0,0,1,.708,2.084,3.276,3.276,0,0,1-.083,1.458c-.172.329-1,.583-1.167.917a1.689,1.689,0,0,0,0,1.167,1.655,1.655,0,0,0,1,.542c.35.018.968-.409,1.292-.542a7.726,7.726,0,0,1,1.458-.583,7.4,7.4,0,0,1,1.931.292,9.191,9.191,0,0,0,1.584.556,4.1,4.1,0,0,0,1.889-.695c.236-.194.39-.864.639-1.042a2.652,2.652,0,0,1,1.167-.263,3.458,3.458,0,0,1,1.167.263c.279.142.634.781.944.82a2.181,2.181,0,0,0,1.223-.612c.21-.2.3-.879.556-1.028.193-.115.682.033,1.06.1a1.526,1.526,0,0,0,.176.564,2.168,2.168,0,0,0,.916.583c.24.07.759-.063,1,0a2.084,2.084,0,0,1,1.042.583c.218.392-.189,1.356-.083,1.792a4.048,4.048,0,0,0,.917,1.584,9.343,9.343,0,0,0,1.375.542c.224.12.716.357.834.583a4.751,4.751,0,0,1,0,2.334,5.606,5.606,0,0,1-.792,1.833c-.208.255-.915.468-1.084.75-.188.315.061,1.17-.167,1.459-.322.408-1.659.282-1.958.708a2.309,2.309,0,0,0,0,1.458c.087.288.6.707.667,1a4.265,4.265,0,0,1-.25,1.625,4.537,4.537,0,0,1-.583,1.167c-.133.16-.541.334-.667.5-.175.231-.2.893-.417,1.083a2.6,2.6,0,0,1-1.459.333c-.2-.02-.545-.32-.75-.333a2.863,2.863,0,0,0-1.542.458,2.456,2.456,0,0,0-.625,1.417,3.426,3.426,0,0,0,.917,1.667c.344.321,1.411.427,1.709.792a5.322,5.322,0,0,1,.5,2.125c.049.424-.169,1.316,0,1.708.113.264.7.538.833.792a2.246,2.246,0,0,1,.209,1.25,2.986,2.986,0,0,1-1.083,1.125c-.26.156-.964.108-1.167.333a1.617,1.617,0,0,0-.208,1.167c.1.279.755.522.875.792.182.409-.132,1.363,0,1.792.1.337.692.828.792,1.167a4.344,4.344,0,0,1-.042,1.667,6.105,6.105,0,0,1-.75,1.542c-.179.252-.757.589-.875.875a3.652,3.652,0,0,0,0,1.625,4.967,4.967,0,0,0,.875,1.875c.3.3,1.22.432,1.542.709a4.581,4.581,0,0,1,.875,1.333c.265.648.18,2.15.542,2.75.18.3.917.569,1.084.875a5.666,5.666,0,0,1,.25,2.292c-.028.48-.412,1.395-.431,1.875a4.436,4.436,0,0,0,.278,1.861c.245.4,1.218.755,1.528,1.112a4.5,4.5,0,0,1,.861,1.611,8.536,8.536,0,0,1-.444,2.695c-.126.454-.618,1.286-.694,1.75a6.316,6.316,0,0,0,.083,1.7c.084.427.589,1.2.583,1.639a6.057,6.057,0,0,1-.7,1.806,9.875,9.875,0,0,0-.944,1.612,2.345,2.345,0,0,0,.043.756c-.3-.048-.6-.121-.766-.145-.43-.063-1.244-.607-1.667-.5-.3.077-.629.711-.889.889-.426.292-1.539.454-1.889.833-.229.25-.243,1.006-.444,1.279a2.911,2.911,0,0,1-1.056.777c-.554.182-2-.481-2.334,0-.152.222.54.779.389,1s-.792,0-1.055,0a7.7,7.7,0,0,0-1.557,0c-.36.1-.917.677-1.277.778-.307.087-1.079-.25-1.278,0s.278,1.223,0,1.333a4.9,4.9,0,0,0-1.445.612,1.693,1.693,0,0,0-.333,1c.02.148.32.35.333.5.02.21-.349.567-.333.778.021.292.5.73.612,1,.177.422.726,1.417.444,1.778-.086.11-.43-.059-.556,0-.339.162-.616.986-.944,1.167a5.688,5.688,0,0,1-2.834.333c-.373-.071-.954-.729-1.334-.722-.355.007-.924.531-1.223.722-.227.145-.662.465-.888.612-.724.466-2.522,1.029-2.946,1.778-.177.314.182,1.133,0,1.444-.194.33-1.075.453-1.358.744a4.049,4.049,0,0,0-1.753.062c-.307.12-.469.912-.75,1.084a6.319,6.319,0,0,1-3.834.5c-.273-.089-.567-.685-.833-.792-.62-.248-2.011.12-2.667,0-.548-.1-1.535-.691-2.083-.792a6.887,6.887,0,0,0-2,0c-.469.1-1.276.874-1.75.792s-.959-1.189-1.417-1.375c-.328-.133-1.2-.278-1.417,0-.346.435.566,1.615.5,2.167-.033.278-.223.967-.5,1-.407.049-.668-1.142-1.064-1.25a2.39,2.39,0,0,0-1.853.639c-.149.209.182.846,0,1.028a1.85,1.85,0,0,1-1.834,0c-.316-.317.268-1.433,0-1.792-.195-.262-.927-.328-1.25-.375a5.1,5.1,0,0,0-1.917,0,3.008,3.008,0,0,0-1.25,1.139c-.1.235.133.808,0,1.028-.28.462-1.421.784-1.917,1-.344.15-1.079.663-1.417.5-.4-.191-.3-1.329-.583-1.667a2.894,2.894,0,0,0-1.584-.875,1.829,1.829,0,0,0-.917.542c-.2.222-.252.918-.5,1.083a3.261,3.261,0,0,1-2.084.083,4.657,4.657,0,0,1-1.028-.833c-.149-.128-.45-.3-.678-.489a.745.745,0,0,1-.294-.387c-.078-.485.989-1.218.973-1.709a1.705,1.705,0,0,0-.556-.833c-.348-.3-1.469-.338-1.667-.75-.252-.524.6-1.669.583-2.25a2.908,2.908,0,0,0-.583-1.75c-.338-.243-1.256-.068-1.667,0-.51.084-1.479.86-1.959.667-.674-.271-.809-2.08-1.333-2.583-.464-.445-1.854-.656-2.334-1.084a5.866,5.866,0,0,1-1.584-2.584c-.067-.529.546-1.514.625-2.042a6.676,6.676,0,0,0,0-2.129,7.393,7.393,0,0,0-1.292-2.038c-.411-.464-1.6-1.04-1.917-1.57-.395-.649-.208-2.339-.625-2.973-.358-.543-1.72-.991-2.125-1.5a9.785,9.785,0,0,1-.75-1.833c-.306-.732-.675-2.371-1.25-2.917-.282-.269-1.134-.326-1.458-.542-.405-.269-.87-1.272-1.333-1.417a1.485,1.485,0,0,0-1.167.25c-.3.365.164,1.437,0,1.876a1.525,1.525,0,0,1-.542.625c-.442.213-1.529-.151-1.959.083-.269.147-.436.859-.708,1a2.222,2.222,0,0,1-.958,0c-.649-.078-1.888-.635-2.542-.625-.313,0-.912.435-1.209.333a3.476,3.476,0,0,1-1.458-1.959c-.112-.486.372-1.46.375-1.959a4.754,4.754,0,0,0-.375-2.083,2.5,2.5,0,0,0-1.209-.708c-.3-.055-.933.344-1.208.208-.4-.2-.5-1.29-.833-1.583-.368-.321-1.459-.355-1.833-.667-.521-.433-.969-1.792-1.375-2.334C2823,2031.41,2822.728,2031.213,2822.574,2031.032Z" transform="translate(-2481.446 -1580.518)">
</path>
</a>
</g>
</g>
</svg>

How to create SVG radial lines

I am trying to create a scale with radial lines and numbers with range 0-100.
Here is my code:
<!DOCTYPE html>
<html>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<head>
<title>SVG Gauge</title>
</head>
<style>
#wrapper {
position: relative;
margin: auto;
}
#meter {
width: 100%;
height: 100%;
transform: rotateX(180deg);
}
.circle {
fill: none;
}
#mask {
stroke: #404040;
stroke-width: 60;
}
.blackie {
fill:none;
stroke: #000000;
stroke-width: 30;
}
.range {
stroke-width: 60;
}
.scale {
stroke: #cccccc;
}
#slider, #lbl {
position: absolute;
}
#slider {
cursor: pointer;
left: 0;
margin: auto;
right: 0;
top: 58%;
width: 94%;
}
#lbl {
background-color: #4B4C51;
border-radius: 2px;
color: white;
font-family: 'courier new';
font-size: 15pt;
font-weight: bold;
padding: 4px 4px 2px 4px;
right: -48px;
top: 57%;
}
#meter_needle {
height: 40%;
left: 0;
margin: auto;
position: absolute;
right: 0;
top: 10%;
transform-origin: bottom center;
transform: rotate(270deg);
}
</style>
<body>
<div id="wrapper">
<svg id="meter">
<g class="scale">
<defs>
<linearGradient id="grad" x1="0%" y1="0%" x2="100%" y2="0%">
<stop offset="0%" style="stop-color:rgb(102, 102, 255);stop-opacity:1" />
<stop offset="100%" style="stop-color:rgb(204, 204, 255);stop-opacity:1" />
</linearGradient>
</defs>
<circle id="high" class="circle range" cx="50%" cy="50%" stroke="url(#grad)">
</circle>
<circle id="mask" class="circle" cx="50%" cy="50%">
</circle>
<circle id="low" class="blackie" cx="50%" cy="50%" r="360">
</circle>
<circle id="outline_ends" class="circle outline" cx="50%" cy="50%">
</circle>
</g>
</svg>
<img id="meter_needle" src="gauge-needle.svg" alt="">
<input id="slider" type="range" min="0" max="100" value="0" />
<label id="lbl" id="value" for="">0%</label>
</div>
<script>
var r = 400;
var circles = document.querySelectorAll('.circle');
var total_circles = circles.length;
for (var i = 0; i < total_circles; i++) {
circles[i].setAttribute('r', r);
}
var meter_dimension = (r * 2) + 100;
var wrapper = document.querySelector('#wrapper');
wrapper.style.width = meter_dimension + 'px';
wrapper.style.height = meter_dimension + 'px';
var cf = 2 * Math.PI * r;
var semi_cf = cf / 2;
var z = 40 * Math.PI;
document.querySelector('#outline_ends')
.setAttribute('stroke-dasharray', 2 + ',' + (semi_cf - 2));
document.querySelector('#high')
.setAttribute('stroke-dasharray', semi_cf + ',' + cf);
document.querySelector('#mask')
.setAttribute('stroke-dasharray', semi_cf + ',' + cf);
document.querySelector('#low')
.setAttribute('stroke-dasharray', semi_cf - z + ',' + cf);
var slider = document.querySelector('#slider');
var lbl = document.querySelector("#lbl");
var svg = document.querySelector('#meter');
var high = document.querySelector('#high');
var mask = document.querySelector('#mask');
var low = document.querySelector('#low');
var meter_needle = document.querySelector('#meter_needle');
function range_change_event() {
var percent = slider.value;
var meter_value = semi_cf - ((percent * semi_cf) / 100);
mask.setAttribute('stroke-dasharray', meter_value + ',' + cf);
meter_needle.style.transform = 'rotate(' + (270 + ((percent * 180) / 100)) + 'deg)';
lbl.textContent = percent + '%';
}
slider.addEventListener('input', range_change_event);
</script>
</body>
</html>
I have found on the web plenty of good examples with HTML canvas and D3js but nothing based on SVG..
I am thinking to create an element "line" and add it across the black arc.
What is the simplest way to create the numeric scale?
Here you go:
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-250 -250 500 500" width="500" height="500" id="svg">
<defs>
<style>
line {
stroke: black;
stroke-width: 1px;
}
text {
fill: red;
text-anchor: middle;
font-size: 16px;
font-family: sans-serif;
}
rect {
fill: transparent;
}
#id {
display: none;
}
.origin {
fill: green;
}
.outer {
fill: none;
stroke: black;
}
</style>
</defs>
<circle r="5" cx="0" cy="0" class="origin"/>
<path d="M-180,0 a1,1 0 0,1 360,0" class="outer"/>
<g id="gauge" transform="rotate(-90)">
<g id="noon">
<rect x="-10" y="-220" width="20" height="100"/>
<line x1="0" y1="-190" x2="0" y2="-180"/>
<text x="0" y="-200"></text>
</g>
</g>
</svg>
<script>
for (i=0; i<=180; i = i + 18) {
var new_tick = noon.cloneNode(true);
new_tick.getElementsByTagName('text')[0].textContent = i/180 * 100;
new_tick.removeAttribute("id");
new_tick.setAttribute("transform", "rotate(" + i + " 0 0)");
gauge.appendChild(new_tick);
}
</script>
I think this is fairly self-explanatory. (For example the RECT is just a guide which you can turn on - by changing the fill - if you want to better visualize what's going in inside each G.)
Let me know if you have any follow on questions.
Here's a Codepen, if it helps: https://codepen.io/MSCAU/pen/OoQMdV
What is the simplest way to create the numeric scale?
The easiest way to animate the scaling of the svg circle is to animate its radius
<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
width="400" height="400" viewBox="0 0 400 400" >
<circle cx="200" cy="200" r="10" fill="none" stroke-width="2" stroke="purple" >
<animate attributeName="r" values="1;100;1" dur="4s" repeatCount="indefinite" />
</circle>
</svg>

SVG - Center text for each path/shape

I'm able to center text for each path/shape explicitly, but I don't want to do the math for each one. I've tried this the code below but it just puts the two texts on top of one another, which would make sense if it's referring to the one <svg> and not each <g> or <path>.
<svg viewBox="0 0 91.742 214.2" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#000" stroke-width="1">
<g>
<text class="room-text" x="50%" y="50%">145</text>
<path class="room" d="m 0.134593,0.134751 2.2679,133.799999 86.179,0.75595 -5.2917,-133.049999 z"/>
</g>
<g>
<text class="room-text" x="50%" y="50%">146</text>
<path class="room" d="m 2.402593,133.94175 0.75595,80.131 88.446,-0.75594 -3.0238,-78.619 z"/>
</g>
</svg>
I've also tried anchor-text and baseline-alignment but an explicit x and y value are still needed.
Yeah. I ended up just doing it through JavaScript.
document.addEventListener("DOMContentLoaded", function(event) {
var svg = document.getElementById("svg");
/***** Get the room box and text box *****/
for (i = 1; i < svg.childNodes[1].childNodes.length; i += 2) {
var room = svg.childNodes[1].childNodes[i].childNodes[3]; // path element
var textbox = svg.childNodes[1].childNodes[i].childNodes[1]; // text element
var new_x = document.createAttribute("x"); // make a new attribute to add to the textbox
new_x.value = room.getBBox().width / 2 + room.getBBox().x - textbox.getBBox().width / 2; // calculate the textbox's new x position
textbox.setAttributeNode(new_x) // assign the textbox the new x value
}
});
body {
box-sizing: border-box;
}
.main {
width: 100%;
}
svg {
display: block;
margin: 0 auto;
width: 400px;
height: 400px;
}
.room {
fill: rgba(220, 220, 220, .4);
}
.room:hover {
fill: rgba(0, 255, 255, 0.4);
}
.room-text {
fill: black;
font-size: 14px;
font-family: "Helvetica";
}
<div id="svg">
<svg viewBox="0 0 181.01 255.02" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#000" stroke-width="1">
<g id="r145">
<text class="room-text" y="40">145</text>
<path class="room" d="m0.13374 1.6456 0.75595 68.792 135.32-2.2679-4.5357-68.036z"/>
</g>
<g>
<text class="room-text" y="130">146</text>
<path class="room" d="m0.88969 70.437 29.482 103.57 150.43-3.7798-44.601-102.05z"/>
</g>
<g>
<text class="room-text" y="220">147</text>
<path class="room" d="m30.372 174 42.333 79.375 96.762 1.5119 11.339-84.667z"/>
</g>
</svg>
</div>

SVG not working in Chrome

This works in Firefox but not Chrome. Basically the animation works correctly in Firefox with the lightbulb glowing and the leaf growing but for some reason cannot get it to work in Chrome. Thanks for the help here.
jsfiddle here, http://jsfiddle.net/EfLtD/1/
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 250 250" enable-background="new 0 0 250 250" xml:space="preserve">
<g id="light-bulb-6-icon_1_">
<path fill="#FFFFFF" d="M-314.3,152.1c-2.1,0-2.8-0.6-7.4-5c-0.6-0.6-1.4-1.3-2.2-2h25.6c-0.9,0.8-1.7,1.6-2.4,2.2
c-4.6,4.3-5.3,4.8-7.4,4.8H-314.3z M-326.6,137.7c-1.7,0-3.1-1.4-3.1-3.1s1.4-3.1,3.1-3.1h31.2c1.7,0,3.1,1.4,3.1,3.1
c0,1.7-1.4,3.1-3.1,3.1H-326.6z M-327.4,123.9c-1.7,0-3.1-1.4-3.1-3.1c0-1.7,1.4-3.1,3.1-3.1h32.7c0.9,0,1.7,0.4,2.3,1
c0.5,0.6,0.8,1.3,0.8,2.1c0,1.8-1.4,3.1-3.1,3.1L-327.4,123.9L-327.4,123.9z M-298,109.7c0.3-13.3,6.4-23.6,12.4-33.5
c6-10,11.6-19.4,11.6-31.5c0-16.9-11.6-35.1-37.1-35.1c-25.5,0-37,18.2-37,35.1c0,12.1,5.6,21.4,11.5,31.3
c5.9,9.9,12,20.1,12.6,33.7h-9.1c-0.3-10.3-5.6-19.1-11.2-28.5c-6.4-10.8-13-21.9-13-36.5c0-13.7,5-25.2,14.4-33.2
c8.4-7.2,19.7-11.1,31.9-11.1c12.1,0,23.4,3.9,31.8,11.1c9.4,8,14.4,19.5,14.4,33.2c0,14.6-6.6,25.7-13,36.5
c-5.6,9.4-10.8,18.2-11.2,28.5L-298,109.7L-298,109.7z M-312.8,109.6c-3.3-14.5-1.4-40.1,6.7-54.6l2.4-4.3l-3.9,3.1
c-5.2,4-9.9,14.2-11.6,21.9c-5.4-3.9-7.4-10.6-5.3-18.3c2.9-10.6,14-22,31.7-23.2c-2,1.8-3.6,4.2-4.5,7c-1.9,5.3-1.3,10.1-0.7,14.7
c0.6,4.6,1.1,9-0.8,13.6c-2,4.8-6.1,7.9-11.3,8.4l-0.8,0.1l-0.1,0.8c-1,9.8,0.3,22.7,3.1,30.8L-312.8,109.6L-312.8,109.6z"/>
<path fill="#225650" d="M-311,1.4c11.9,0,23,3.9,31.2,10.9c9.2,7.8,14.1,19.1,14.1,32.5c0,14.3-6.6,25.3-12.9,36
c-5.5,9.2-10.6,17.9-11.3,28h-7c0.6-12.5,6.5-22.4,12.2-32c5.8-9.7,11.8-19.7,11.8-32c0-11.2-4.1-20.5-12-27.1
c-6.9-5.8-16.2-9-26.1-9c-9.9,0-19.2,3.2-26.1,9c-7.8,6.6-12,16-12,27.1c0,12.4,5.7,21.8,11.6,31.9c5.7,9.5,11.5,19.3,12.4,32.1
h-7.1c-0.6-10.1-5.8-18.8-11.3-28c-6.3-10.6-12.9-21.7-12.9-36c0-13.4,4.9-24.6,14.1-32.5C-334,5.2-322.9,1.4-311,1.4L-311,1.4
M-295.4,35.5c-1.2,1.6-2.2,3.4-2.9,5.4c-1.9,5.5-1.3,10.4-0.8,15.2c0.5,4.5,1.1,8.7-0.7,13.1c-1.8,4.5-5.6,7.3-10.4,7.8l-1.6,0.2
l-0.2,1.6c-1,9.4,0.2,21.7,2.7,29.9h-2.7c-3-14.4-1.1-39.1,6.8-53.1l4.9-8.7l-7.8,6.1c-5.1,4-9.6,13.2-11.6,21
c-4.1-3.7-5.5-9.6-3.7-16.2c1.6-5.9,5.5-11.4,11-15.4C-307.7,38.6-301.8,36.3-295.4,35.5 M-294.7,118.7c0.6,0,1.2,0.2,1.6,0.7
c0.2,0.3,0.5,0.7,0.5,1.4l0,0v0c0,1.1-1,2.1-2.1,2.1h-32.7c-1.1,0-2.1-1-2.1-2.1c0-1.1,1-2.1,2.1-2.1L-294.7,118.7 M-295.4,132.5
c1.2,0,2.1,0.9,2.1,2.1c0,1.1-1,2.1-2.1,2.1h-31.2c-1.1,0-2.1-1-2.1-2.1s1-2.1,2.1-2.1H-295.4 M-300.9,146.1
c-0.2,0.2-0.3,0.3-0.5,0.5c-4.6,4.2-5.1,4.5-6.7,4.5h-6.2c-1.6,0-2.1-0.4-6.7-4.7c-0.1-0.1-0.2-0.2-0.3-0.3H-300.9 M-311-0.6
c-23.6,0-47.3,15.1-47.3,45.3c0,28.1,24.2,43.8,24.2,66h11.1c-0.6-28-24.1-41.7-24.1-66c0-22.8,18-34.1,36-34.1S-275,22-275,44.7
c0,24.3-24,38.7-24,66h11c0-22.2,24.2-37.9,24.2-66C-263.8,14.5-287.4-0.6-311-0.6L-311-0.6z M-289.6,33.1
c-33.2,0-46.5,33.8-28.9,44.2c1.5-8.4,6.5-18.9,11.5-22.8c-8.3,14.8-10.3,41.2-6.6,56.1h7.1c-3.1-8-4.5-21.8-3.5-31.7
c5-0.5,9.8-3.4,12.1-9c3.9-9.7-2.1-18.1,1.5-28.4C-295.1,37.7-292.7,34.9-289.6,33.1L-289.6,33.1z M-294.7,116.7h-32.7
c-2.3,0-4.1,1.9-4.1,4.1c0,2.3,1.9,4.1,4.1,4.1h32.7c2.3,0,4.1-1.9,4.1-4.1C-290.5,118.5-292.4,116.7-294.7,116.7L-294.7,116.7z
M-295.4,130.5h-31.2c-2.3,0-4.1,1.9-4.1,4.1c0,2.3,1.9,4.1,4.1,4.1h31.2c2.3,0,4.1-1.9,4.1-4.1
C-291.3,132.3-293.1,130.5-295.4,130.5L-295.4,130.5z M-295.7,144.1h-30.7c8.1,7.5,8.9,9,12.1,9h6.2
C-304.9,153.1-304.2,151.7-295.7,144.1L-295.7,144.1z"/>
</g>
<g>
<path fill="#F9E46E" class="yellow" d="M89.5,93.2c0,24.3,23.5,38,24.1,66h24c0-27.3,24-41.7,24-66C161.6,47.7,89.5,47.7,89.5,93.2z"/>
</g>
<g id="light-bulb-6-icon_37_">
<path fill="#FFFFFF" d="M122.2,200.9c-2.1,0-2.8-0.6-7.4-5c-0.6-0.6-1.4-1.3-2.2-2h25.6c-0.9,0.8-1.7,1.6-2.4,2.2
c-4.6,4.3-5.3,4.8-7.4,4.8H122.2z M109.9,186.5c-1.7,0-3.1-1.4-3.1-3.1s1.4-3.1,3.1-3.1h31.2c1.7,0,3.1,1.4,3.1,3.1
c0,1.7-1.4,3.1-3.1,3.1H109.9z M109.1,172.7c-1.7,0-3.1-1.4-3.1-3.1c0-1.7,1.4-3.1,3.1-3.1h32.7c0.9,0,1.7,0.4,2.3,1
c0.5,0.6,0.8,1.3,0.8,2.1c0,1.8-1.4,3.1-3.1,3.1L109.1,172.7L109.1,172.7z M138.6,158.5c0.3-13.3,6.4-23.6,12.4-33.5
c6-10,11.6-19.4,11.6-31.5c0-16.9-11.6-35.1-37.1-35.1S88.4,76.6,88.4,93.5c0,12.1,5.6,21.4,11.5,31.3c5.9,9.9,12,20.1,12.6,33.7
h-9.1c-0.3-10.3-5.6-19.1-11.2-28.5c-6.4-10.8-13-21.9-13-36.5c0-13.7,5-25.2,14.4-33.2c8.4-7.2,19.7-11.1,31.9-11.1
c12.1,0,23.4,3.9,31.8,11.1c9.4,8,14.4,19.5,14.4,33.2c0,14.6-6.6,25.7-13,36.5c-5.6,9.4-10.8,18.2-11.2,28.5L138.6,158.5
L138.6,158.5z"/>
<path fill="#225650" d="M122.3,201.9h6.2c3.2,0,3.9-1.4,12.4-9h-30.7C118.3,200.4,119,201.9,122.3,201.9z M135.2,195.3
c-4.6,4.2-5.1,4.5-6.7,4.5h-6.2c-1.6,0-2.1-0.4-6.7-4.7c-0.1-0.1-0.2-0.2-0.3-0.3h20.5C135.5,195,135.3,195.2,135.2,195.3z"/>
<path fill="#225650"d="M141.1,179.3h-31.2c-2.3,0-4.1,1.9-4.1,4.1c0,2.3,1.9,4.1,4.1,4.1h31.2c2.3,0,4.1-1.9,4.1-4.1
C145.2,181.1,143.4,179.3,141.1,179.3z M141.1,185.5h-31.2c-1.1,0-2.1-1-2.1-2.1s1-2.1,2.1-2.1h31.2c1.2,0,2.1,0.9,2.1,2.1
C143.2,184.5,142.3,185.5,141.1,185.5z"/>
<path fill="#225650" d="M125.5,48.1c-23.6,0-47.3,15.1-47.3,45.3c0,28.1,24.2,43.8,24.2,66h11.1c-0.6-28-24.1-41.7-24.1-66
c0-22.8,18-34.1,36.1-34.1s36,11.4,36,34.1c0,24.3-24,38.7-24,66h11c0-22.2,24.2-37.9,24.2-66C172.8,63.2,149.1,48.1,125.5,48.1z
M146.6,157.5h-7c0.6-12.5,6.5-22.4,12.2-32c5.8-9.7,11.8-19.7,11.8-32c0-11.2-4.1-20.5-12-27.1c-6.9-5.8-16.2-9-26.1-9
s-19.2,3.2-26.1,9c-7.8,6.6-12,16-12,27.1c0,12.4,5.7,21.8,11.6,31.9c5.7,9.5,11.5,19.3,12.4,32.1h-7.1c-0.6-10.1-5.8-18.8-11.3-28
c-6.3-10.6-12.9-21.7-12.9-36c0-13.4,4.9-24.6,14.1-32.5c8.2-7,19.3-10.9,31.2-10.9c11.9,0,23,3.9,31.2,10.9
c9.2,7.8,14.1,19.1,14.1,32.5c0,14.3-6.6,25.3-12.9,36C152.4,138.6,147.2,147.3,146.6,157.5z"/>
<path fill="#225650" d="M141.8,165.5h-32.7c-2.3,0-4.1,1.9-4.1,4.1c0,2.3,1.9,4.1,4.1,4.1h32.7c2.3,0,4.1-1.9,4.1-4.1
C146,167.3,144.1,165.5,141.8,165.5z M143.9,169.5L143.9,169.5c0,1.2-1,2.1-2.1,2.1h-32.7c-1.1,0-2.1-1-2.1-2.1
c0-1.1,1-2.1,2.1-2.1h32.7v0c0.6,0,1.2,0.2,1.6,0.7C143.7,168.4,144,168.8,143.9,169.5L143.9,169.5z"/>
</g>
<path fill="#FFFFFF" class="leaf" stroke="#225650" stroke-width="2" stroke-miterlimit="10" d="M121.8,158.6c-3.3-14.5-1.4-40.1,6.7-54.6
l2.4-4.3l-3.9,3.1c-5.2,4-9.9,14.2-11.6,21.9c-5.4-3.9-7.4-10.6-5.3-18.3c2.9-10.6,14-22,31.7-23.2c-2,1.8-3.6,4.2-4.5,7
c-1.9,5.3-1.3,10.1-0.7,14.7c0.6,4.6,1.1,9-0.8,13.6c-2,4.8-6.1,7.9-11.3,8.4l-0.8,0.1l-0.1,0.8c-1,9.8,0.3,22.7,3.1,30.8
L121.8,158.6L121.8,158.6z"/>
</svg>
/* CSS */
/* Globe */
#yellow-globe {width: 300px; height: 300px; margin: 0 auto; text-align: center;}
#keyframes yellow {
0% {
fill: #FFFFFF;
}
25% {
fill: #FFFFFF;
}
50% {
fill: #F9E46E;
}
75% {
fill: #F9E46E;
}
100% {
fill: #F9E46E;
}
}
.yellow {
fill: yellow;
animation-name: yellow;
animation-duration: 1s;
animation-iteration-count: infinite;
}
.leaf {
stroke-dasharray: 242;
stroke-dashoffset: 242;
animation: dash 4s linear alternate;
animation-iteration-count: 1;
}
#keyframes dash {
from {
stroke-dashoffset: 242;
}
to {
stroke-dashoffset: 0;
}
}
#keyframes fillme {
0% {
fill: #FFFFFF;
}
25% {
fill: #FFFFFF;
}
50% {
fill: #225650;
}
75% {
fill: #225650;
}
100% {
fill: #225650;
}
}
You need to include the -webkit- prefix on animations (and transitions) for webkit browsers (like Chrome). Working demo
You may also want to include the -ms- and -moz- prefixes so that you can reach older versions of FireFox and IE as well

Resources