score:0
we can use order to overcome this problem ex.
label: 'Schedule',
data: [...lineData],
borderColor: '#9630D6',
backgroundColor: '#fff',
type: 'line',
order: 0,
},
{
label: 'bar 1st',
data: [...barData1],
backgroundColor: '#97CEA5',
barThickness: 40,
order: 1,
},
{
label: 'bar 2nd',
data: [...barData2],
backgroundColor: '#E2BB72',
barThickness: 40,
order: 2,
},
{
label: 'bar 3rd',
data: [...barData3],
backgroundColor: '#E2E28F',
barThickness: 40,
order: 3,
}
score:5
I found the solution my self.
Actually, we need to put the line data above the bar data in the dataset. the chart.js creates the chart from top to bottom in the order it finds the chartdata in the dataset.
So I changed the code to to below
var PCTCtx = document.getElementById("pctdiv").getContext("2d");
PCTChart = new Chart(PCTCtx, {
type: 'bar',
data: {
datasets: [{
label: 'Line Dataset',
data: [50, 50, 50, 50],
fill: false,
backgroundColor: ['#000000', '#000000', '#000000', '#000000'],
// Changes this dataset to become a line
type: 'line'
},{
label: 'Bar Dataset',
data: [100, 70, 60, 40],
backgroundColor: ['red', 'red', 'red', 'red']
}],
labels: ['January', 'February', 'March', 'April']
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero: true
},
gridLines: {
display: false
}
}],
xAxes: [{
barThickness: 35,
gridLines: {
display: false
}
}]
}
}
});
PCTChart.data.datasets[1].borderColor = '#000000';
and it worked for me thankyou
score:6
I was facing the same issue. I found an option "order" in the dataset. https://www.chartjs.org/docs/latest/charts/mixed.html
Source: stackoverflow.com
Related Query
- Line chart is showing under bar in combochart in chartjs
- Chartjs Bar Chart showing old data when hovering
- Chartjs 2 - Stacked bar and unstacked line on same chart with same y axis
- How to draw Horizontal line on Bar Chart Chartjs
- ChartJS 2.9.4 can't overlay line data on Horizontal Bar chart
- Chartjs Bar Chart showing old data when hovering when use of ajax
- ChartJS not showing data for time series bar chart
- ChartJS line chart or bar graph from a Java program
- Draw stacked horizontal bar chart with Average line using ChartJS
- How to add vertical line in bar chart using chartJs and ng2-charts?
- Chartjs v2.0: stacked bar chart
- Changing fontFamily on ChartJS bar chart
- Display line chart with connected dots using chartJS
- chartjs : how to set custom scale in bar chart
- Chartjs Bar Chart Legend
- show label in tooltip but not in x axis for chartjs line chart
- chartjs show dot point on hover over line chart
- Click event on stacked bar chart - ChartJs
- ChartJS add tooltip to a grouped bar chart
- ChartJs line chart repaint glitch while hovering over
- How to add second Y-axis for Bar and Line chart in Chart.js?
- Chart.js Mixed Bar and Line chart with different scales
- How do I draw a vertical line on a horizontal bar chart with ChartJS?
- ChartJS bar chart with legend which corresponds to each bar
- ChartJs bar chart - keep bars left instead of equally spread across the width
- Border radius for the bar chart in ChartJS
- ChartJS - Line Chart with different size datasets
- Show data dynamically in line chart - ChartJS
- Chartjs - data format for bar chart with multi-level x-axes
- Can Chart.js combines Line Chart and Bar Chart in one canvas
More Query from same tag
- Charts.js how to have 2 different size y-axis
- Error with Chart.js : TypeError: t is undefined
- How do I add padding on the right of tooltip, but not the left in Chart.js?
- space before and after data points in chart.js
- Background color does not work when trying to create my data before using scatter chart with chart.js
- Chart.js stacked bar ordering depending on value
- Regarding stacked chart in chart.js
- Rendering charts using local Chart.js in overriding Django templates
- Visualizing intervals with range bar charts in chart.js
- Problem displaying two graphs on a single chart using javascript and chart.js
- How to set time scale zoom in ChartJS?
- chartjs-plugin-error-bars display error-bars without displaying label on a horizontalBar chart
- How to add dataset legend in chartjs tooltip
- Use chartjs with rails
- Set different color for each bars using ChartJS in Angular 4
- chart js graph not showing on canvas
- Chartjs fiddle not working
- How to align bars in bar chart - Chart.js
- How to set a minimum width on the values in a doughnut chart?
- Need help in figuring out config for a custom tooltip (chartjs)
- 2 or more charts on same page?
- Making angular-chartjs responsive with UI-Grid
- How can I highlight/format a specific date label (e.g. today) on a time axis using chart.js?
- Chart.JS - Couldn't add the margin/spacing between Y-axis labels
- react-chartjs: difference between `scales.x`/`xAxes`/`xAxes[]`
- How to create a multiline graph with differents labels
- Where do I use chartjs's destroy function?
- Chart js 2.x renders the canvas invisible
- angular 7 how to draw dynamic number of charts
- Can't get data into my Javascript function using Django