Create an account


Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 20,124
» Latest member: codestar101
» Forum threads: 21,772
» Forum posts: 22,641

Full Statistics

Online Users
There are currently 969 online users.
» 0 Member(s) | 964 Guest(s)
Applebot, Baidu, Bing, Google, Yandex

 
  [Tut] Chart JS Pie Chart Example
Posted by: xSicKxBot - 12-08-2022, 01:23 PM - Forum: PHP Development - No Replies

Chart JS Pie Chart Example

by Vincy. Last modified on December 7th, 2022.

In this tutorial, we are going to learn how to create a pie chart using JavaScript libraries. We have used Chart.js library for the generating the pie charts. As an alternate option, I have also presented a 3d pie chart example using Google charts library.

Let us see the following examples of creating a pie chart using JavaScript.

  • Quick example – Simple pie chart example via ChartJS.
  • 3D pie chart with Google Charts library.
  • Responsive ChartJS pie chart.

Quick example – Simple pie chart example via ChartJS


<!DOCTYPE html>
<html>
<head>
<title>Chart JS Pie Chart</title>
<link rel='stylesheet' href='style.css' type='text/css' />
</head>
<body> <div class="phppot-container"> <h1>Responsive Pie Chart</h1> <div> <canvas id="pie-chart"></canvas> </div> </div> <script src="https://cdn.jsdelivr.net/npm/chart.js@4.0.1/dist/chart.umd.min.js"></script> <script> new Chart(document.getElementById("pie-chart"), { type : 'pie', data : { labels : [ "Lion", "Horse", "Elephant", "Tiger", "Jaguar" ], datasets : [ { backgroundColor : [ "#51EAEA", "#FCDDB0", "#FF9D76", "#FB3569", "#82CD47" ], data : [ 418, 263, 434, 586, 332 ] } ] }, options : { title : { display : true, text : 'Chart JS Pie Chart Example' } } }); </script>
</body>
</html>

Creating a ChartJS pie chart is a three-step process as shown below.

  1. Add the ChartJS library include to the head section of your HTML.
  2. Add a canvas element to the HTML.
  3. Add the ChartJS class initiation and invoking script before closing the HTML body tag.

About the ChartJS pie chart script


The script sets the following properties to initiate the ChartJS library.

  • type – The type of the chart supported by the ChartJS library.
  • data – It sets the chart labels and datasets. The dataset contains the data array and the display properties.
  • options – It sets the chart title text and its display flag as a boolean true to show it on the browser.

Output:

chartjs pie chart

In a previous tutorial, we have seen the various ways of creating line charts using the Chart JS library.

View Demo

Creating 3D pie chart


There is no option for a 3D pie chart using chart JS. For those users who have landed here looking for a 3D pie chart, you may try Google Charts.

This example uses Google Charts to create a 3D pie chart for a webpage. In a previous code, we use Google Charts to render a bar chart to show students’ attendance statistics.

The Google Charts JavaScript code prepares the array of animal distribution data. This array is for sending it to the chart data table which helps to draw the pie chart.

The Google Charts library accepts the is3D with a boolean true to output a 3D pie chart.

It creates a chart visualization object with the reference with respect to the UI element target. Then, it calls the Google Charts library function to draw and render the chart.

<!DOCTYPE html>
<html>
<head>
<title>3d Pie Chart JavaScript with Google Charts</title>
<link rel='stylesheet' href='style.css' type='text/css' /> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript"> google.charts.load("current", { packages : [ "corechart" ] }); google.charts.setOnLoadCallback(drawChart); function drawChart() { var data = google.visualization.arrayToDataTable([ [ 'Animal', 'Distribution' ], [ 'Horse', 11 ], [ 'Elephant', 2 ], [ 'Tiger', 2 ], [ 'Lion', 2 ], [ 'Jaguar', 7 ] ]); var options = { title : '3d Pie Chart JavaScript with Google Charts', is3D : true, }; var chart = new google.visualization.PieChart(document .getElementById('3d-pie-chart')); chart.draw(data, options); }
</script>
</head>
<body> <div class="phppot-container"> <h1>3d Pie Chart JavaScript with Google Charts</h1> <div id="3d-pie-chart" style="width: 700px; height: 500px;"></div> </div>
</body>
</html>

3d pie chart

Responsive pie chart using Chart JS


The Chart JS library provides JavaScript options to make the output pie chart responsive.

This example script uses those options to render a responsive pie chart in a browser.

The JavaScript code to render a responsive pie chart is the same as we have seen in the quick example above.

The difference is nothing but to set responsive: true in the ChartJS options properties.

If you want to create a responsive chart using Google Charts, then the linked article has an example.

<!DOCTYPE html>
<html>
<head>
<title>Responsive Pie Chart</title>
<link rel='stylesheet' href='style.css' type='text/css' />
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body> <div class="phppot-container"> <h1>Responsive Pie Chart</h1> <div> <canvas id="pie-chart"></canvas> </div> </div> <script src="https://cdn.jsdelivr.net/npm/chart.js@4.0.1/dist/chart.umd.min.js"></script> <script> new Chart(document.getElementById("pie-chart"), { type : 'pie', data : { labels : [ "Lion", "Horse", "Elephant", "Tiger", "Jaguar" ], datasets : [ { backgroundColor : [ "#51EAEA", "#FCDDB0", "#FF9D76", "#FB3569", "#82CD47" ], data : [ 418, 263, 434, 586, 332 ] } ] }, options : { title : { display : true, text : 'Responsive Pie Chart' }, responsive : true } }); </script>
</body>
</html>

View DemoDownload

↑ Back to Top



https://www.sickgaming.net/blog/2022/12/...t-example/

Print this item

  (Indie Deal) Cyber Whale Bundle 2, Cashback, Devil in Me's out
Posted by: xSicKxBot - 12-08-2022, 01:22 PM - Forum: Deals or Specials - No Replies

Cyber Whale Bundle 2, Cashback, Devil in Me's out

Cyber Whale Bundle 2 | 6 Steam Games | 96% OFF
[www.indiegala.com]
Add to your collection & get a selection of games made with heart and mind brought to you by Whale Rock Games for the passionate gamers: Synthwave Burnout, NeuraGun, Inquisitor's Heart and Soul, Cybernetic Fault, Cyberpunk SFX, Euphoria: Supreme Mechanics.

https://www.youtube.com/watch?v=p6_hzXmQt3A
Blackfriday Cashback Sale
[www.indiegala.com]
For a limited time, any purchase made on IndieGala, be it store deals or bundles, will be rewarding you instantly and handsomely, directly into your IndieGala account, ready to be used!
[www.indiegala.com]
https://www.youtube.com/watch?v=wAw5RROD3ZI


https://steamcommunity.com/groups/indieg...7229708288

Print this item

  (Free Game Key) Saints Row IV Re-Elected and Wildcat Gun Machine - Free Epic Games
Posted by: xSicKxBot - 12-08-2022, 01:22 PM - Forum: Deals or Specials - No Replies

Saints Row IV Re-Elected and Wildcat Gun Machine - Free Epic Games

2 Free Epic Games Games

❤️ Saints Row IV Re-Elected
https://store.epicgames.com/p/saints-row-iv-re-elected

❤️ Wildcat Gun Machine
https://store.epicgames.com/p/wildcat-gun-machine-c66c4e

This game is free to keep if claimed by December 15, 2022 5:00 PM or in 7 days

Next weeks freebies:
Mystery Game (15 days of charismas giveaways, a giveaway a day)



We are welcoming everyone to join our discord[discord.gg]. We are more active there on finding giveaways, small or large, and there are daily raffles you can participate.

?GrabFreeGames.com ?Twitter ?Steam Curator ?Facebook[fb.me]?Discord[discord.gg]
❤️Support us: HumbleBundle Partner[www.humblebundle.com] Fanatical Affiliate[www.fanatical.com]


https://steamcommunity.com/groups/GrabFr...3040654188

Print this item

  News - Call Of Duty Has A Long, Strange History On Nintendo Consoles
Posted by: xSicKxBot - 12-08-2022, 01:22 PM - Forum: Lounge - No Replies

Call Of Duty Has A Long, Strange History On Nintendo Consoles

Microsoft's recent announcement that it intends to put Call Of Duty games onto Nintendo consoles for the next 10 years came as a surprise to many. After all, the best-selling shooter franchise has not yet appeared on the Nintendo Switch, despite that console holding onto a huge portion of market share for years now.

However, the truth is that despite Nintendo's reputation as a more "kid-friendly" publisher, several COD games have appeared on its consoles in the past. In fact, it's only in the past decade or so that the Tokyo gaming giant has completely divested itself of the famed series, and we can't help but wonder if that'll change soon.

Early Call Of Duty fans may remember the days of console-exclusive spin-offs like Finest Hour and Big Red One in the mid-2000's, which came out for the GameCube, PS2, and Xbox. In fact, the first COD game was PC-exclusive, which limited its appeal. That would change in subsequent years, of course.

Continue Reading at GameSpot

https://www.gamespot.com/articles/call-o...01-10abi2f

Print this item

  PC - Call of Duty: Warzone 2.0
Posted by: xSicKxBot - 12-08-2022, 01:22 PM - Forum: New Game Releases - No Replies

Call of Duty: Warzone 2.0



As shown at Call of Duty: Next, Call of Duty: Warzone 2.0, the sequel to the seminal Battle Royale experience over 125 million players dropped in to play, is set to arrive this November 16, as part of Modern Warfare II's Season One.

This massive, free-to-play offering leverages new technology shared with Modern Warfare II, introduces a host of new innovations, and continues the new era of Call of Duty coming this Fall, starting with Modern Warfare II's launch on October 28.

Publisher: Activision

Release Date: Nov 16, 2022




https://www.metacritic.com/game/pc/call-...warzone-20

Print this item

  [Oracle Blog] Accelerate Your Java Programming Career
Posted by: xSicKxBot - 12-07-2022, 06:41 AM - Forum: Java Language, JVM, and the JRE - No Replies

Accelerate Your Java Programming Career

Looking for a flexible and affordable way to get started with Java SE? Look no further.


https://blogs.oracle.com/java/post/accel...ing-career

Print this item

  [Tut] Python | Split String Variable Spaces
Posted by: xSicKxBot - 12-07-2022, 06:41 AM - Forum: Python - No Replies

Python | Split String Variable Spaces

Rate this post

⭐Summary: The most efficient way to split a string using variable spaces is to use the split function like so given_string.split(). An alternate approach is to use different functions of the regex package to split the string at multiple whitespaces.

Minimal Example


text = "a b c d"
# Method 1
print(text.split())
# Method 2
import re
print(re.split('\s+', text))
# Method 3
print([x for x in re.findall(r'\S+', text) if x != ''])
# Method 4
print(re.sub(r'\s+', ',', text).split(','))
# Method 5
print(list(filter(None, text.split()))) # ['a', 'b', 'c', 'd']

Problem Formulation


?Problem: Given a string. How will you split the string using multiple spaces?

Example


# Input
text = "abc xyz lmn pqr"
# Output
['abc', 'xyz', 'lmn', 'pqr']

The given input has multiple spaces between each substring, i.e., there are three spaces after abc, two spaces after xyz while a single space after lmn. So, not only do you have multiple spaces between the substring but also varied number of spaces. Can you split the string by varied and multiple spaces?


Though the question might look daunting at first but once you get hold of it, the solutions to this problem are easier than one can imagine. So, without further delay let us dive into the different ways of solving the given problem.

Method 1: Using split()


The built-in split('sep') function allows you to split a string in Python based on a given delimiter. By default the split function splits a given string at whitespaces. Meaning, if you do not pass any delimiter to the split function then the string will be split at whitespaces.

You can use this default property of the split function and successfully split the given string at multiple spaces just by using the split() function.

Code:

text = "abc xyz lmn pqr"
print(text.split()) # ['abc', 'xyz', 'lmn', 'pqr']

?Recommended DigestPython String split()

Method 2: Using re.split


The re.split(pattern, string) method matches all occurrences of the pattern in the string and divides the string along the matches resulting in a list of strings between the matches. For example, re.split('a', 'bbabbbab') results in the list of strings ['bb', 'bbb', 'b'].

Approach: To split the string using multiple space characters use re.split("\s+", text) where \s+ is the matching pattern and it represents a special sequence that returns a match whenever it finds any whitespace character and splits the string. So, whenever there’s a space or multiple spaces (any number of occurrences of space are whitespace characters) the string will be split.

Code:

import re
text = "abc xyz lmn pqr"
print(re.split('\s+', text))
# ['abc', 'xyz', 'lmn', 'pqr']

?Recommended Read:  Python Regex Split.

Method 3: Using re.findall


The re.findall(pattern, string) method scans the string from left to right, searching for all non-overlapping matches of the pattern. It returns a list of strings in the matching order when scanning the string from left to right.

?Recommended Read: Python re.findall() – Everything You Need to Know

Code:

import re
text = "abc xyz lmn pqr"
print([x for x in re.findall(r'\S+', text) if x != ''])
# ['abc', 'xyz', 'lmn', 'pqr']

Method 4: Using re.sub


The regex function re.sub(P, R, S) replaces all occurrences of the pattern P with the replacement R in string S. It returns a new string. For example, if you call re.sub('a', 'b', 'aabb'), the result will be the new string 'bbbb' with all characters 'a' replaced by 'b'.

Approach: Use the re.sub method to replace all occurrences of space characters in the given string with a comma. Thus, the string will now have commas instead of space characters and you can simply split it using a normal string split method by passing comma as the delimiter.

Silly! Isn’t it? Nevertheless, it works.

Code:

import re
text = "abc xyz lmn pqr"
res = re.sub(r'\s+', ',', text).split(',')
print(res)
# ['abc', 'xyz', 'lmn', 'pqr']

Method 5: Using filter


Python’s built-in filter() function filters out the elements that pass a filtering condition. It takes two arguments: function and iterable. The function assigns a Boolean value to each element in the iterable to check whether the element will pass the filter or not. It returns an iterator with the elements that pass the filtering condition.

?Related Read: Python filter()

Approach: You can use the filter() method to split the string by space. Feed in None as the first argument and the list of split strings as the second argument into the filter function. The filter() function then iterates through the list and filters out the spaces from the given string and returns only the non-whitespace characters. As the filter() method returns an object, we need to use the list() to convert the object into a list.

Code:

text = "abc xyz lmn pqr"
print(list(filter(None, text.split())))
# ['abc', 'xyz', 'lmn', 'pqr']

Conclusion


Hurrah! We have successfully solved the given problem using as many as five different ways. I hope you enjoyed reading this article and it helped you in your Python coding journey. Please subscribe and stay tuned for more interesting articles!

Happy coding! ?

?Suggested Read: Python Regex Superpower [Full Tutorial]


Do you want to master the regex superpower? Check out my new book The Smartest Way to Learn Regular Expressions in Python with the innovative 3-step approach for active learning: (1) study a book chapter, (2) solve a code puzzle, and (3) watch an educational chapter video.



https://www.sickgaming.net/blog/2022/12/...le-spaces/

Print this item

  (Indie Deal) Development Update #3 - Elcado Needs Help
Posted by: xSicKxBot - 12-07-2022, 06:41 AM - Forum: Deals or Specials - No Replies

Development Update #3 - Elcado Needs Help


Greetings Mercenaries,

For this Friday’s devlog, we wanted to show you our most recent YouTube video highlighting some of the exciting things the development team has been working on.

While you’re checking the video out, be sure to head over to IndieGala[freebies.indiegala.com] or Steam to play the new Vorax alpha 0.3, which is still available for a limited time

“Bilial-Like” Creatures Stalk the Night
There are more dangerous things than simple zombies that lurk in the dark on the island. Not only do they present a physical threat, but their terrifying appearance will test even the most hardened mercenary’s sanity.

While it can be dangerous to engage them, they often drop special loot that can be extremely useful. Remember, good things come to those that are brave.

Sergeant Elcado Needs Help

While much of the island has been ravaged by the virus, there are still people who have managed to survive. One such survivor is Sergeant Elcado, who is the only surviving member of a NATO squad sent to investigate the ongoing events on the island. Survivors like him can often help you throughout your mission, but they will often ask that you do something for them in exchange.

Community Highlight: Gameplay Versatility & Compatibility
One of our goals in developing Vorax, is to provide the player with multiple different ways to play the game. Whether it’s going in guns blazing, or cleverly trapping an area to avoid fighting enemies head on, we want the player to choose how they approach each and every situation.
https://youtu.be/6FZJgo-0c2s
To highlight this, check out some of the content created by our community members showcasing how they tackle difficult situations.

What's next?
That’s all for this week, everyone. But look forward to the next one when we will take a closer look at some of the strategic aspects of the game, such as trap crafting and building fortifications.

Remember, the Open Alpha is still available for those of you wishing to experience some of the new content and updates we’ve added to the game. Also, be sure to join our Discord to get exclusive news on updates, events, and more.

Wishlist now:
https://store.steampowered.com/app/1874190/Vorax/
[discord.gg]


https://steamcommunity.com/groups/indieg...3395007889

Print this item

  News - Rainbow Six Siege Shines In The Solar Raid Update With A New Operator And Map
Posted by: xSicKxBot - 12-07-2022, 06:41 AM - Forum: Lounge - No Replies

Rainbow Six Siege Shines In The Solar Raid Update With A New Operator And Map

The Operation Solar Raid update for Rainbow Six Siege is out today and brings a new operator, a new map, cross-play/cross-progression, a revamped battle pass, and a new system for Ranked.

The new player character is Operator Solis from Colombia. She's a defender who wields the SPEC-IO sensor, which can pick up and highlight essential intel. She uses the gadget to identify Attacker devices. Her gloves can interact with gadget overlays and she can activate cluster scans. She has medium health, medium speed, and wields the P90 or the ITA 12L for her primary as well as the SMG-11 as her secondary.

The new map is called Nighthaven Labs. It will not be bannable for the duration of the Operation Solar Raid season to ensure that players get the chance to familiarize themselves with the map. Set in an extension of the Nighthaven headquarters, the map features multiple access points, via many breakable walls and a runout hatch.

Continue Reading at GameSpot

https://www.gamespot.com/articles/rainbo...01-10abi2f

Print this item

  (Free Game Key) Fort Triumph and RPG in a box - Free Epic Games
Posted by: xSicKxBot - 12-07-2022, 06:41 AM - Forum: Deals or Specials - No Replies

Fort Triumph and RPG in a box - Free Epic Games

❤️ Fort Triumph
https://store.epicgames.com/p/fort-triumph


❤️ RPG in a Box
https://store.epicgames.com/p/rpg-in-a-box

This game is free to keep if claimed by December 8, 2022 5:00 PM

Next weeks freebies:
Saints Row IV Re-Elected
Wildcat Gun Machine


We are welcoming everyone to join our discord[discord.gg]. We are more active there on finding giveaways, small or large, and there are daily raffles you can participate.

?GrabFreeGames.com ?Twitter ?Steam Curator ?Facebook[fb.me]?Discord[discord.gg]
❤️Support us: HumbleBundle Partner[www.humblebundle.com] Fanatical Affiliate[www.fanatical.com]


https://steamcommunity.com/groups/GrabFr...2920688459

Print this item

 
Latest Threads
Temu Promo Code For New U...
Last Post: codestar101
1 hour ago
[Verified] 30% Off Temu C...
Last Post: codestar101
1 hour ago
Temu Coupon Code 30% OFF ...
Last Post: codestar101
1 hour ago
How To Get Temu Coupon Co...
Last Post: codestar101
1 hour ago
Temu Coupon Code 30% Off ...
Last Post: codestar101
2 hours ago
New Temu Coupon Code [ald...
Last Post: codestar101
2 hours ago
Temu Coupon Code 30% Off ...
Last Post: codestar101
2 hours ago
Temu Coupon 30%Off Code [...
Last Post: codestar101
2 hours ago
Cupones Para Temu [ald911...
Last Post: Bebeckman6
2 hours ago
Codice Coupon Temu Primo ...
Last Post: Bebeckman6
2 hours ago

Forum software by © MyBB Theme © iAndrew 2016