Hi, guys, welcome back to Appsloveworld. In our previous article, we learned about How to Create Multi-Line Chart Using Chart js in detail. And now moving ahead, let’s learn about another great feature of Chart Js i.eHow we can create straight lines and curves lines in the same graph using Chart.js.
Straight lines and curves lines in the same graph
we can create this task using the lineTension option of dataset ,bezierCurve is a chart level option using that we can the curved of the line chart. In the below example, we have taken two datasets i. eJavaScript Developer and Chart Js Developer. and for Chart Js Developer we have set lineTension to 1.
<!DOCTYPE html>
<html>
<head>
<title>Chart.js-Multi line charts </title>
<script src="https://cdn.jsdelivr.net/npm/chart.js@3.7.1/dist/chart.min.js"></script>
</head>
<body>
<div style="margin-left:5%;margin-right:5%">
<canvas id="myLineChart" style="width:100%;max-width:80%"></canvas>
</div>
<script>
var xValues = [2011, 2012, 2013, 2014, 2016, 2017, 2018, 2019, 2020, 2021, 2022];
const MultiLinechartData = {
type: "line",
data: {
labels: xValues,
datasets: [
{
label: 'JavaScript Developer',
lineTension: 0,
backgroundColor: 'blue',
borderColor: 'blue',
data: [100, 500, 600, 800, 700, 900, 1200, 850, 970, 750, 1100]
},
{
label: 'Chart Js Developer',
lineTension: 1,
borderColor: 'red',
data: [88, 800, 450, 550, 350, 820, 620, 730, 740, 660, 669]
}
]
},
options: {
plugins: {
title: {
display: true,
text: 'Software developers in organization',
}
},
scales: {
x: {
display: true,
title: {
display: true,
text: 'Year'
}
},
y: {
display: true,
title: {
display: true,
text: 'Employees'
}
}
}
}
};
new Chart("myLineChart", MultiLinechartData);
</script>
</body>
</html>
*Thank you so much if you have a question please comment
So what I want to do here is it will be green. So I want to grab this green color here, I’ll set it in green, and else if that’s not the case I want the default color of red. We’re going to put it in their semicolon.
All right, so now we have this here and then of course what we need to do is to return so we’ll look through every item here based on this condition, and then it will return the matching value. So we say return it will say here return the value of the color.
The post [Chart Js]- Straight Lines and Curves Lines in the Same Graph appeared first on Software Development | Programming Tutorials.
Read More Articles
- [Simple Way]-Cascading DropDownList in Asp.Net Mvc Using Jquery Ajax
- jQuery Ajax GET Example with Parameters
- How to Pass Parameters in AJAX POST?| JQuery Ajax Post Json Example
- [Simple Way]-How to get data from database using JQuery Ajax in asp net MVC
- How to add, edit and delete rows of an HTML table with Jquery?
- Registration form with image upload in MVC using jquery Ajax
- How to make an Inline editable table in MVC using jquery?
- Insert Update Delete Using Jquery Ajax and Modal Popup in Mvc
- [Solved]-How to Upload pdf file using jquery MVC?
- Dynamically creating graphs with jQuery
- Build input element and variations of them on the fly depending on user choice
- Posting file objects: illegal invocation
- jquery window.scroll doesn't work properly
- JS file is not updating to new id values
- Drag and drop nested list order with data-attribute
- Get id of article with certain class every time document changes?
- Explicit context lost in collection.fetch()
- JQuery functions not launching in ASP.NET
- Including element-specific javascript in Rails
- Jquery, Show/hide div, label for issue
- How to create a method for custom polymer element and call it in a main App?
- jQuery live not firing on resize and scroll
- How iterate a jQuery function for each slide in a slider?
- focus and focusout event order switching from one field to another
- jQuery $(this) out of scope when binding click event (Object Literal)
- ajax does not receive response from nodejs
- How to add and delete list items with jQuery?
- rounding numerical output inside append text
- Send a form data in jquery ajax
- jQuery cycle only current div
- call a function when slideDown or slideUp effect has finished
- Multiselect not working inside ui:repeat
- passing php array to script via jquery.get()
- JavaScript Fading Slides Out, Fixing Buttons
- Show a hidden div after page reload ( div becomes visible after page reload )
- How to pass data using ajaxFileUpload jQuery Plugin
- Basic mouseMove horizontal and vertical scroll
- Target specific item in Accordion with jQuery
- jquery plugin timers ajax called
- How to make a star rating default 5 and change after selected
- Display fixed title when content comes into view
- I want to open link Using jquery
- Applying and changing the classname of selected radio with scripting
- How can I show the time left until progress bar is finished loading?
- Wordpress Ajax response 0
- Streaming json data with django
- document.getElementById not working properly
- Copy paste text area lines limitation jquery
- div slides up and stays in position
- jQuery OnClick Run External Page when complete update page
- Updating data-value of input text box oninput not working
- Execute js after all image loaded
- JQuery 4 button menu, on click hide divs and show others, and vice versa
- Submit multiple forms with one click to an iframe
- Currency validation and formatting using single function
- addClass() in dependency of radio-field
- javascript Error: Why I cannot clone/copy a tag from "li" to "table"?
- Adding animations with addClass in jQuery
- Ajax: How to display dynamic drop down and text box?
- How to avoid already selected value from the facets(list) - VisualSearch
- Fixed Header Scrollable Table - How to preserve horizontal scroll position using css jquery on page loads
- Populate all numbers from array into random divs
- How do I use session variables with jQuery?
- Add CSS if Page URL equals <a> link on page not working when #anchor-tags are present
- Multiple Text Box Validation
- Button Firing 2 Scripts instead of 1
- How to post-process column values in jQuery DataTables
- JQuery: How to connect event to iFrame scrolling
- Button not highlighting the text
- Auto submit Form via ajax on selecting image
- Javascript in Pug
- Deleting a HTML table row on successful ajax request
- Prevent mouse out occurring when
- Meteor jQuery initialization
- Find the same element in ajax response
- Jquery file inclusion issue
- Bind jQuery events to DIV with specific HTML TAG like TEXTAREA
- jQuery datepicker disabled dates - multiple ranges
- Find specific div on click and toggle class
- How to bifurcate data in table according to a particular value
- notification update when receive ajax respone
- Sortable, filterable, user list in backbone marionette?
- Want to change the color of every div except the one dblclicked?
- No Validation errors showing up using jquery 3x with formvalidator.net
- Aurelia routing links generated by jQuery plugin
- Image Maps + Responsive Tabs with rwdImageMaps
- how to get the value of id if its id is an integer value in jquery
- pub/sub API does not work
- Use javascript to grab the filename of file selected in Rails form_for file_field before submitting
- Jquery inserted all the same selectors after the target div
- Google map api,how to handle marker hover event for all the markers at the same position(Overlapping markers)?
- twitter REST api with jquery
- Close a Modal with Javascript (Metro UI)
- Add URL to jQuery Datatables data set?
- How can I target only visible objects with nth-child?
- Image resize within the div on manual browser width change
- Create li data-role=list-divider from array
- Redirecting in JSP from servlet and JSP
- ajax response returning the same value
- animation is not executing after property is set to a variable
- SlideUp when click on the content
- Jquery confirm displays text several times
- Move list item from one unordered list to another
- Javascript how to remove corresponding tablerow element?
- Strange difference between Firefox, Internet Explorer and Safari pixel width
- '&' symbol got escaped in the url when used with 'window.location'
- Creating a new div onclick wordpress+ajax
- auto reload 'php' in javascript
- Migrating js file from prototype to jQuery does not work
- kendoui: kendogrid should be updated with click on kendochart
- How to get the values from dynamically created row of textboxes in JSON
- how to make toggled title stay after mouse out function is complete?
- Qlik Sense error in creating extension
- Positioning issue using css
- Prevent Auto Slide using Jquery
- ajax request call ending with error
- jquery - How can send data when copy/pasted data in input?
- JQuery function still running after attribute change
- How do I check if the window has scrolled to a href and then execute a function in javascript/jQuery?
- Reorder HTML rendered from PHP Array
- Someone can solve my jquery
- Using Semantic UI with asp.net webforms
- Echo a php code with Jquery Ajax
- Dropdownlist losing values on button submit
- Reload jquery appendto onclick
- Update table data based on dropdown box selection
- How to disable sorting on a column in a datatable
- Selecting element without element inside jQuery
- How do I extract data from xml and post to a div using jquery/javascript
- Jquery Validate require at least 1 checkbox if text field has a value
- Change colour of elements previously clicked
- jQuery loop inside of a string?
- How to check specific checkboxes with javascript/jquery?
- Jquery - copying an input to a div with keyup paste, having an issue with autofilled data
- jquery slide to attribute with specific data attribute value
- How to append div using $(this) selector in Jquery?
- Jquery .text() with php foreach
- On drag and drop element to div, add an id name to url
- Grab Data ID Value
- jquery remove issue in IE, canvas tag
- How to loop through list items in a jquery $.each call
- Override Date Object Error: "this is not a Date object."
- How can I Drag and Drop Images/Text on Canvas and save canvas as HTML?
- Images appending twice in Jquery
- How to exit from a jQuery function implementation?
- Jquery not working in Wordpress; function php
- MeteorJS external files: css and js
- Add/remove class on right click
- How to remove a class from all elements except the current one?
- How to make html and UI related javascript code less coupled?
- dynamic id on anchor not firing on other anchor last anchor php js pdo
- php jquery count down timer script
- How to force jquery ui menu or similar to show second submenu items horizontally
- How do I disable textarea on checkbox click?
- Can we call a jquery function after page load complete?
- ToggleClass overlap
- JS/jQuery - Check if element has all classes in array
- Jquery Form validation for select2 multiple
- Is there any way to call "benchmark" in the javascript code
- ul li items shuffle random position fade and one by one