In this article, we’re going to focus on how we can create a smooth line without points. You can see here we have removed the points or the dots in the line, but you can still Hover over it. So we have a very nice smooth line. We’ll make this line more elastic so it looks more curved.
How can I remove the point dot in each data point in the line chart?
we can accomplish this task by using the point’s radius property of the chart js option in the configuration as below example:
elements: {
point:{
radius: 0
}
}
Option configuration :
options: {
elements: {
point: {
radius: 0
}
},
plugins: {
title: {
display: true,
text: 'Sale Chart',
}
},
scales: {
x: {
display: true,
title: {
display: true,
text: 'Year'
}
},
y: {
display: true,
title: {
display: true,
text: 'Sale($)'
}
}
}
}
Hide points in line chart and show only tooltip
You can see here in the below image we have removed the dots in the line, but you can still Hover tooltip.
<!DOCTYPE html>
<html>
<head>
<title>ChartJS-Hide Points in Line Chart</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: 'Sale',
lineTension: 0,
borderColor: 'red',
data: [343, 343, 8, 550, 89, 89, 898, 232, 343, 243, 554]
}
]
},
options: {
elements: {
point: {
radius: 0
}
},
plugins: {
title: {
display: true,
text: 'Sale Chart',
}
},
scales: {
x: {
display: true,
title: {
display: true,
text: 'Year'
}
},
y: {
display: true,
title: {
display: true,
text: 'Sale($)'
}
}
}
}
};
new Chart("myLineChart", MultiLinechartData);
</script>
</body>
</html>
*Thank you so much if you have a question please comment
And of course, we will change the thickness of the line so it’s nice and thick. So let’s start to look at how to do this in this video, we’re going to focus on one of the reader questions, which is how to remove the points or the dots in a line charging charges. So this question came from one of my other videos about how to add shadows to the line charging charges. And probably most likely you want to remove the dots from it. That’s a fair point.
So let me start to work on that and let’s start with how to do it. To do that, we do need to go to the charts .com Getting Started link to get the default code. And for some reason, I get this error here why? I do not know, but on Firefox, it works fine. However, let’s copy this chunk of code here because you basically need the code on this page.
And then what we’re going to do is we’re going to just paste it in here. Once we paste that in here, I’m going to remove that, put it in there, save this, and refresh. So now we have a nice bar chart, but we don’t want a bar chart. We want a line chart. So what we’re going to do is a few things.
We’re going to convert it into a line chart. So let’s search here. The type will be the line. Secondly, I want to change the color. If I save this right now, refresh, you can see we have multiple colors here.
And I don’t want this. I want just single color only. And eventually, it will not matter so much because we will not even have this kind of background color anyway. But just to be sure and to simplify, we’re just going to put only one single color here.
Once we save it and refresh it. Now we have a single color. The next thing I want to do is maybe to smooth out the line because right now we have these dots here, but also it’s not elastic. It’s a very tightened line which is just straight lines. And let’s make it more elastic.
The post How to leave just points without lines in ChartJS 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
- How to pass dynamically rendered content to binding handler?
- jquery plugin jquery-loadmask fails to fire event after 1st run -- need tips to debug
- Script tag not running properly
- jQuery function on array not working
- jquery dialog() ok will submit php $GET variable
- How to disable default trim in writing variable ejs, node.js?
- Cannot match pattern for wordpress empty paragraph tag
- Slide to show more content overflowed on div
- jquery ajax return data and html
- Trying to create a JQuery menu with a submenu that slides up on hover, and slides down when mouse exits
- How to start cd-horizontal-timeline from the last element
- JQuery autcomplete not working with multiple input fields
- Unable to submit form using jquery submit method
- How do I make a jQuery loop which changes the href attribute of a link?
- Apply CSS to dynamically generated <li> for chat list
- how to create differently responsive carousel using bootstrap
- Disabling after onclick addClass
- Create a slider with arrow keys and with the mouse click
- Bootstrap tab content slideDown/slideUp not working
- Delayed start of GIF image in IE & Edge
- AngularJS + Jquery Gantt - multiple charts
- GIF freezes on page load
- jquery load data
- WorkAround Jquery Datatable in Laravel
- How to correctly change a rendered text's color in fabric.js
- JQuery Ajax Post submission - with conditional validation before ajax post or pop alert
- How to read and load data from local file when page loads
- Map not centered in leaflet.js
- How to get jqgrid cell value when editing row?
- Why can't jQuery get a CSS file via browser.runtime.getURL?
- Select one member from JSON result based on member value
- Can't fix syntax error
- Want to search using comman separated text in asp.net
- Jquery select multiple nth-childs
- convert div data to image using html2canvas and php
- trying if the user chooses a file a one element is created but instead it is doubled
- How to get the data that was being sent from controller to json?
- radio button to enable number type
- How to Pass on value on raw to js Shopify
- Push through list using jQuery
- Show confim popup on page unload [DUPLICATED]
- Keep getting Access to XMLHttpRequest at '(api url)' from origin '(localserver)' has been blocked by CORS policy
- How to handle with url link on jeditable field?
- I can't detect the event when the input value changes
- Access a local JSON object using a js file
- Getting the urls params in a page using jquery
- Make divs scroll horizontally using jQuery
- How To Call Spring MVC Controller From JQuery Ajax Call
- How to configure JSME (chemistry portal configured with javascript) in vuejs?
- ajax is loading data twice from database using laravel php
- jQuery vertical menu issue
- How to run an async function in js with timeouts (for rate limiting)
- ajax xhr.responseText when result contains @ error uncaught typeerror
- Prevent two event types from being fired
- Change button action in object
- How to get the tab-list class that is outside of the selector. I'm using the <input id="date-field"> as my this element
- Primefaces effect on growl only triggered second time
- jQuery Lightbox For Native Galleries wordpress plugin buttons not showing outside box
- canvas image does not have changed css filter values
- Executing a Function from a separate page
- How can I navigate until a span into a table?
- How to display information for a specific item from a database through a for loop?
- Switchstyle Problem in Joomla/Php/Jquery/Css
- Is it possible to add click function that would pop up audio files for my code?
- web - copy section to clipboard and remove certain elements
- JSON object output not right
- Dealing with overflow of a navigation bar
- What is JQuery/Ajax GetData url for asp.net
- How can i abort/cancel a HTTP request caused by Javascript code?
- In jQuery, how can I create a custom event with a default?
- Detecting a change in the text of a span
- JQuery UI autocomplete not working after disabled textbox
- Using <object> for SVG to and inline css from HTML to edit fill
- Integers and booleans posted via $.ajax converted to strings by PHP
- using jQuery scollLeft() method to scroll to the right by default, what is wrong with my code?
- Server controls and building HTML - ASP.NET
- How to disable a link in javascript only if a certain "if" condition is met
- Using jQuery read a txt file can't return the value out of the function
- nested accordion collapsing doesn't work properly
- xhtml compliance error handler event like html compliance onerror event to handle empty image
- Set the options of DropDown with TextField value
- How to fix automatic image movement
- Dynamically changing CSS style files with onchange event
- jQuery: ajax inside another? smart?
- Passing array into processing page in jqGrid
- object HTMLImageElement apeearing from jQuery when trying to insert images
- preventDefault. Wait for menu animation before go to link
- Modal Popup is getting closing when am trying to append the data to its body in jquery
- Attaching multiple click events with same div in Jquery
- How can i make my image show fade in before falling?
- Rails 5: rails-jquery-autocomplete routes blocked by page routes
- get value of particular pic id using jquery ui drag and drop
- How to pass two user input dates through url
- jquery datatable Manipulate data after ajax call
- Open other page after AJAX jQuery Mobile
- How to use jQuery Ajax to refresh a php include?
- How to get previous month values in UTC in Javascript
- jquery conditional logic for currentpage
- How Can I Set hour and minute on datepicker jquery,it shouldnt be writable too long
- Can I validate one field in two different groups?
- Change color of drop down selected option on hover
- How to get data from API use url and key javascript
- CakePHP: JQuery submit() returns a blank page
- Ajax script printing code instead of actual message?
- jQuery jumpy effect when using .slideToggle()
- Roundabout jquery in document Strict
- TextBox Get clear when div show/hide using jquery
- jQuery -- Search table for partial matches in different columns
- How to replace bunch of tags with JavaScript or jQuery?
- Uncaught ReferenceError: $ is not defined - Laravel 9, Vite
- How can I escape the ajaxStart event
- Escape characters in String in a HTML page?
- invert background color of page on scroll
- jquery logic to remove an alert message in rails not working
- Mouse scroll direction changes function
- Radio button and normal button are not communicating
- disable dropdownlist value selected and get the next value of dropdown list
- how to only display the graph with highcharts
- JQuery Overlay Opacity and Text Problem
- Reload only the bootstrap tab when clicked
- Do you have Flash or flex or jQuery header animation like this url site http://www.zhoyosoft.com?
- Remove class when selecting different radio button
- .sortable() removing css of my page
- Why is click event not working on MacOS Safari?
- assign li a background color of my choice
- How to append text only once in a loop
- jqgrid - resize and overlay
- how to dynamically Add collapse class to multiple divs of same class using jquery
- Get content of div box from another page
- javascript send local file to api
- Jquery An ajax WIth html.dropdown
- Validate form before calculating
- vuejs jquery issue when trying to import bootstrap
- Pdf export not work in kendo grid
- jQuery event help - I have a Select list with OptGroups, I want to call function only if option belongs to a certain optgroup
- How I can pass php variable to ajax
- What is wrong with this vanilla JavaScript colors filter?
- JQuery Select Multiselect Options Based on Text Field
- Swap with JQuery
- Taking data from inside Ajax Jsonp
- .load() jQuery with div selector causing <script> to be overlooked
- jquery numeric input onchange event not working
- Rspec test failed on Circle CI (Ruby on Rails 5.2.3)
- Jquery Datatables update row for search to work
- How to display a thumbnail with a mouseover?
- accessing the parent accordion in nested accordion
- Have a form submit to two possible different controllers
- Separate pages from PDF into images or HTML
- Table Edit js with codeigniter
- Highcharts duplicated code