score:59
Accepted answer
You can use the border-dash
property for particular dataset. You can specify border length & spacing. E.g borderDash: [10,5]
var ctx = document.getElementById("myChart");
var myChart = new Chart(ctx, {
type: 'line',
data: {
labels: ["Label1", "Label2", "Label3"],
datasets: [{
label: 'legend1',
data: [12, 19, 3],
borderDash: [10,5]
},{
label: 'legend2',
data: [22, 9, 13],
}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero:true
}
}]
}
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.4.0/Chart.min.js" ></script>
<html>
<body>
<div class="myChartDiv" style="height:500px">
<canvas id="myChart" width="600" height="300"></canvas>
</div>
</body>
</html>
Source: stackoverflow.com
Related Query
- Dotted Line in ChartJS
- Chartjs - how to make line position to vertical center and how to display dotted sharp in the backround?
- ChartJS Line Charts - remove color underneath lines
- Chartjs change grid line color
- Chartjs Tooltip Line Breaks
- Display line chart with connected dots using chartJS
- Chartjs 2 - Stacked bar and unstacked line on same chart with same y axis
- show label in tooltip but not in x axis for chartjs line chart
- chartjs show dot point on hover over line chart
- How can I draw dotted line using chartjs?
- ChartJS Line Graph - Multiple Lines, Show one Value on Tooltip
- ChartJs line chart repaint glitch while hovering over
- How to make a line dashed or dotted in chartJS?
- Chartjs Line Color Between Two Points
- How to render a vertical line on hover in chartjs
- ChartJS - Line Chart with different size datasets
- Show data dynamically in line chart - ChartJS
- In ChartJS is it possible to change the line style between different points?
- Line chart is showing under bar in combochart in chartjs
- ChartJS - Line chart issue with only 1 point
- chartjs - Drawing vertical line on integer x axis value
- ChartJs line chart - display permanent icon above some data points with text on hover
- Map event position to y axis value in chartjs line chart
- ChartJS vertical line not removed on touchend
- how to change Y axis value dynamically based on user input in Chartjs for Line chart?
- How to draw Horizontal line on Bar Chart Chartjs
- Chartjs break line for axes tick labels text
- Chartjs line graph dataset with offset
- Can we draw a Line Chart with both solid and dotted line in it?
- ChartJS Line chart cut off at the top and bottom
More Query from same tag
- Chart.js how to use scriptable options
- Mobile page loading in "zoomed" state
- Line chart with combination of fill and line
- Angular-Chart.js - Tooltip not working with 0 values
- How to use dates as X axis with Chart.js even when there is no Y axis value related
- Uncaught TypeError: Cannot read property 'format' of undefined
- Updating data in chart.js
- In react.js with chart.js, I can't access to my data in a componant
- hover/mouseover not activated on every move inside element
- ChartJS 2.7.0 updating and exporting as png
- Hiding labels on y axis in Chart.js
- How to show all dates on xAxis between two dates in chart.js
- Chart.js date x-axis with sparse datapoints
- Setting Chart.js Pie-Graph Options
- Chart.js change label color
- Bar Chart.js doesn't show values with PHP, MySQL, AJAX
- custom ticks in ChartsJS line plot
- ChartJS: Show all tooltips with Total for Multi Pie chart
- ChartJS not work in .php loaded by jquery .load() (AJAX)
- Displaying Chart with data retrieved from Entity Framework in Controller
- How to assign an array to data of charts.js's counts
- Chartjs with Typescript: The types of 'interaction.mode' are incompatible between these types
- Same bar different color / One bar with many colors
- How to replace the data array of my ChartJS
- Chart.js change color of Bar
- Labels attribute of chartsjs not taking context variable of type string
- Can individual bubbles in a chartjs bubble chart have labels?
- ChartJS: Translate x axis month to other languages
- How to Integrating Chart.js with Angular 7 with Data from database
- ChartJS does not display the legend