Chart made with Vue, Transitioning State
How do I make an chart made with vue, transitioning state?
Chart made without a charting library like d3, but composed of Vue directives. Showing also how to transition state with watchers. What is a chart made with vue, transitioning state? How do you make a chart made with vue, transitioning state? This script and codes were developed by Sarah Drasner on 18 November 2022, Friday.
Chart made with Vue, Transitioning State - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Chart made with Vue, Transitioning State</title> <link href="https://fonts.googleapis.com/css?family=Mada" rel="stylesheet"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div id="app"> <select v-model="selected"> <option v-for="option in options" v-bind:value="option.value"> {{ option.text }} </option> </select> <svg viewBox="0 0 400 400"> <!--xaxis --> <g targetVal="targetVal" class="xaxis"> <line x1="0" y1="1" x2="350" y2="1"/> <g v-for="(select, index) in targetVal"> <line y1="0" y2="7" v-bind="{ 'x1':index*10, 'x2':index*10 }"/> <text v-if="index % 5 === 0" v-bind="{ 'x':index*10, 'y':20 }">{{ index }}</text> </g> </g> <!--yaxis --> <g targetVal="targetVal" class="yaxis"> <line x1="0" y1="1" :x2="getMax" y2="1"/> <g v-for="n in getMaxRange"> <line y1="0" y2="7" v-bind="{ 'x1':n*10, 'x2':n*10 }"/> <text v-if="n % 5 === 0" v-bind="{ 'x':getMax-(n*10)-5, 'y':20 }">{{ n }}</text> </g> </g> <!-- bars --> <g v-for="(select, index) in targetVal" class="bars"> <rect v-bind="{ 'x':index*10+20, 'y':getMax-select*10 }" width="10" :height="select*10"/> </g> </svg>
</div> <script src='https://cdnjs.cloudflare.com/ajax/libs/vue/2.1.10/vue.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.16.4/lodash.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/gsap/1.19.0/TweenMax.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Chart made with Vue, Transitioning State - Script Codes CSS Codes
body { font-family: 'Mada', sans-serif; background: #222;
}
#app { text-align: center; max-width: 400px; margin: 30px auto; display: table;
}
span { color: white;
}
svg { width: 400px;
}
svg text { fill: grey; font-family: 'Mada', sans-serif;
}
line { stroke: #555; stroke-width: 2px;
}
select { font-family: 'Mada', sans-serif; background: #444; color: #ccc; border: 0; width: 200px; margin: 0 0 25px; outline: 0; cursor: pointer; height: 35px;
}
select option { font-family: 'Mada', sans-serif;
}
.xaxis { -webkit-transform: translate(20px, 370px); transform: translate(20px, 370px);
}
.yaxis { -webkit-transform: translate(20px, 0px) rotate(90deg); transform: translate(20px, 0px) rotate(90deg);
}
.bars:nth-child(1) rect { fill: #666666;
}
.bars:nth-child(2) rect { fill: #6a5e6e;
}
.bars:nth-child(3) rect { fill: #725775;
}
.bars:nth-child(4) rect { fill: #7d4f7a;
}
.bars:nth-child(5) rect { fill: #854777;
}
.bars:nth-child(6) rect { fill: #8c4070;
}
.bars:nth-child(7) rect { fill: #943863;
}
.bars:nth-child(8) rect { fill: #9c3052;
}
.bars:nth-child(9) rect { fill: #a3293c;
}
.bars:nth-child(10) rect { fill: #ab2121;
}
.bars:nth-child(11) rect { fill: #b3311a;
}
.bars:nth-child(12) rect { fill: #ba4612;
}
.bars:nth-child(13) rect { fill: #c2600a;
}
.bars:nth-child(14) rect { fill: #c97f03;
}
.bars:nth-child(15) rect { fill: #cc9f00;
}
.bars:nth-child(16) rect { fill: #ccbf00;
}
.bars:nth-child(17) rect { fill: #b9cc00;
}
.bars:nth-child(18) rect { fill: #99cc00;
}
.bars:nth-child(19) rect { fill: #79cc00;
}
.bars:nth-child(20) rect { fill: #59cc00;
}
.bars:nth-child(21) rect { fill: #39cc00;
}
.bars:nth-child(22) rect { fill: #1acc00;
}
.bars:nth-child(23) rect { fill: #00cc06;
}
.bars:nth-child(24) rect { fill: #00cc26;
}
.bars:nth-child(25) rect { fill: #00cc46;
}
.bars:nth-child(26) rect { fill: #00cc66;
}
.bars:nth-child(27) rect { fill: #00cc86;
}
.bars:nth-child(28) rect { fill: #00cca6;
}
.bars:nth-child(29) rect { fill: #00ccc6;
}
.bars:nth-child(30) rect { fill: #00b3cc;
}
.bars:nth-child(31) rect { fill: #0093cc;
}
.bars:nth-child(32) rect { fill: #0073cc;
}
.bars:nth-child(33) rect { fill: #0053cc;
}
.bars:nth-child(34) rect { fill: #0033cc;
}
.bars:nth-child(35) rect { fill: #0013cc;
}
.bars:nth-child(36) rect { fill: #0d00cc;
}
.bars:nth-child(37) rect { fill: #2d00cc;
}
.bars:nth-child(38) rect { fill: #4d00cc;
}
.bars:nth-child(39) rect { fill: #6c00cc;
}
.bars:nth-child(40) rect { fill: #8c00cc;
}
Chart made with Vue, Transitioning State - Script Codes JS Codes
'use strict';
new Vue({ el: '#app', data: function data() { return { selected: [25, 37, 15, 13, 25, 30, 11, 17, 35, 10, 25, 15, 5, 27, 15, 13, 25, 36, 15, 14, 35, 10, 14, 15, 35, 17, 12, 13, 25, 30, 14, 17, 35, 10, 25, 15], targetVal: [25, 37, 15, 13, 25, 30, 11, 17, 35, 10, 25, 15, 5, 27, 15, 13, 25, 36, 15, 14, 35, 10, 14, 15, 35, 17, 12, 13, 25, 30, 14, 17, 35, 10, 25, 15], options: [{ text: 'First Dataset', value: [25, 37, 15, 13, 25, 30, 11, 17, 35, 10, 25, 15, 5, 27, 15, 13, 25, 36, 15, 14, 35, 10, 14, 15, 35, 17, 12, 13, 25, 30, 14, 17, 35, 10, 25, 15] }, { text: 'Second Dataset', value: [13, 25, 30, 11, 17, 35, 10, 25, 15, 5, 27, 15, 13, 25, 36, 15, 14, 35, 10, 14, 15, 35, 17, 12, 13, 25, 30, 14, 17, 35, 10, 25, 15, 25, 37, 15] }, { text: 'Third Dataset', value: [35, 10, 25, 15, 5, 27, 15, 13, 25, 36, 15, 14, 35, 10, 14, 15, 35, 17, 12, 13, 25, 30, 14, 17, 35, 10, 25, 15, 25, 37, 15, 13, 25, 30, 11, 17] }] }; }, computed: { getMax: function getMax() { return Math.max.apply(Math, this.selected) * 10; }, getMaxRange: function getMaxRange() { var maxi = Math.max.apply(Math, this.selected); return _.range(maxi); } }, watch: { selected: function selected(newValue, oldValue) { // Create a dummy object that will get updated by GSAP var tweenedData = {}; // Update function that is invoked on each tween step // we use this to push the data var update = function update() { var obj = Object.values(tweenedData); obj.pop(); this.targetVal = obj; }; // Create an object to hold the source data to be tweened and the // function pointer for update events var tweenSourceData = { onUpdate: update, onUpdateScope: this }; for (var i = 0; i < oldValue.length; i++) { // Turn the current index into a string var key = i.toString(); tweenedData[key] = oldValue[i]; tweenSourceData[key] = newValue[i]; } // Tween over the our target dummy object, but only for the specific key TweenMax.to(tweenedData, 1, tweenSourceData); } }
});
![Chart made with Vue, Transitioning State - Script Codes](http://shots.codepen.io/sdras/pen/OWZRZL-512.jpg)
Developer | Sarah Drasner |
Username | sdras |
Uploaded | November 18, 2022 |
Rating | 4.5 |
Size | 4,609 Kb |
Views | 14,168 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Polyscape | 4,889 Kb |
Vue Book Content Typer | 22,438 Kb |
City Construction Site | 16,521 Kb |
Responsive GreenSock-Teaching Monster | 8,589 Kb |
Money Printer | 4,158 Kb |
Form with Animation That Assists in UX | 6,268 Kb |
Example Motion Design Docs | 17,386 Kb |
Steampunk Lighting | 11,521 Kb |
Responsive Animated Infographic. | 17,461 Kb |
React Game- Elephant Taco Hunt | 23,726 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Part 19 Bootstrap split button dropdown | Venkatesha | 1,601 Kb |
Pure CSS Torch Light | Juliendargelos | 2,727 Kb |
Improve | Gavra | 1,652 Kb |
Bootstrap example | Ssaakkaa | 2,716 Kb |
Css3 only dropdown menu | Riogrande | 2,519 Kb |
Responsive Section hover effect to show content | Berdejitendra | 2,540 Kb |
HTM5 picture dropzone | Jaysalvat | 2,576 Kb |
Magnus 3 | ARocketfish | 7,944 Kb |
Cofee and sugar | Tripack | 2,094 Kb |
Responsive slide | Thorien | 2,400 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!