Anonymous
Как я добавляю свой скриптchart.js в административную панель
Сообщение
Anonymous » 01 фев 2026, 06:07
Я хочу создать страницу администратора с помощью adminLTE. Мне нужно вставить диаграмму с помощьюchart.js на мою страницу в админке. Но когда я попытался вставить свой код, диаграмма не отображается, а просто пустая.
Затем мне нужно отредактировать скрипт adminltechartjs, но диаграмма по-прежнему не отображается.
Это мой код наchartjs
Код: Выделить всё
var myChart1 = document.getElementById('myChart1').getContext('2d');
// Global Options
Chart.defaults.global.defaultFontFamily = 'Lato';
Chart.defaults.global.defaultFontSize = 18;
Chart.defaults.global.defaultFontColor = '#777';
var massPopChart = new Chart(myChart1, {
type:'bar', // bar, horizontalBar, pie, line, doughnut, radar, polarArea
data:{
labels:['Boston', 'Worcester', 'Springfield', 'Lowell', 'Cambridge', 'New Bedford'],
datasets:[{
label:'Population',
data:[
617594,
181045,
153060,
106519,
105162,
95072
],
//backgroundColor:'green',
backgroundColor:[
'rgba(255, 99, 132, 0.6)',
'rgba(54, 162, 235, 0.6)',
'rgba(255, 206, 86, 0.6)',
'rgba(75, 192, 192, 0.6)',
'rgba(153, 102, 255, 0.6)',
'rgba(255, 159, 64, 0.6)',
'rgba(255, 99, 132, 0.6)'
],
borderWidth:1,
borderColor:'#777',
hoverBorderWidth:3,
hoverBorderColor:'#000'
}]
},
options:{
title:{
display:true,
text:'Largest Cities In Massachusetts',
fontSize:25,
responsive: true
},
legend:{
display:true,
position:'right',
labels:{
fontColor:'#000'
}
},
layout:{
padding:{
left:50,
right:0,
bottom:0,
top:0
}
},
tooltips:{
enabled:true
}
}
});
var myChart2 = document.getElementById('myChart2').getContext('2d');
var massPopChart = new Chart(myChart2, {
type:'horizontalBar', // bar, horizontalBar, pie, line, doughnut, radar, polarArea
data:{
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
datasets:[{
label:'Population',
data:[
617594,
181045,
153060,
106519,
105162,
95072
],
//backgroundColor:'green',
backgroundColor:[
'rgba(255, 99, 132, 0.6)',
'rgba(54, 162, 235, 0.6)',
'rgba(255, 206, 86, 0.6)',
'rgba(75, 192, 192, 0.6)',
'rgba(153, 102, 255, 0.6)',
'rgba(255, 159, 64, 0.6)',
'rgba(255, 99, 132, 0.6)'
],
borderWidth:1,
borderColor:'#777',
hoverBorderWidth:3,
hoverBorderColor:'#000'
}]
},
options:{
title:{
display:true,
text:'Largest Cities In Massachusetts',
fontSize:25
},
legend:{
display:true,
position:'right',
labels:{
fontColor:'#000'
}
},
responsive: true,
tooltips:{
enabled:true
}
}
});
Вот HTML-скрипт
Код: Выделить всё
Area Chart
[i][/i]
[i][/i]
Chart Bar
[i][/i]
[i][/i]
Спасибо
Подробнее здесь:
https://stackoverflow.com/questions/572 ... -admin-lte
1769915275
Anonymous
Я хочу создать страницу администратора с помощью adminLTE. Мне нужно вставить диаграмму с помощьюchart.js на мою страницу в админке. Но когда я попытался вставить свой код, диаграмма не отображается, а просто пустая. Затем мне нужно отредактировать скрипт adminltechartjs, но диаграмма по-прежнему не отображается. Это мой код наchartjs [code] var myChart1 = document.getElementById('myChart1').getContext('2d'); // Global Options Chart.defaults.global.defaultFontFamily = 'Lato'; Chart.defaults.global.defaultFontSize = 18; Chart.defaults.global.defaultFontColor = '#777'; var massPopChart = new Chart(myChart1, { type:'bar', // bar, horizontalBar, pie, line, doughnut, radar, polarArea data:{ labels:['Boston', 'Worcester', 'Springfield', 'Lowell', 'Cambridge', 'New Bedford'], datasets:[{ label:'Population', data:[ 617594, 181045, 153060, 106519, 105162, 95072 ], //backgroundColor:'green', backgroundColor:[ 'rgba(255, 99, 132, 0.6)', 'rgba(54, 162, 235, 0.6)', 'rgba(255, 206, 86, 0.6)', 'rgba(75, 192, 192, 0.6)', 'rgba(153, 102, 255, 0.6)', 'rgba(255, 159, 64, 0.6)', 'rgba(255, 99, 132, 0.6)' ], borderWidth:1, borderColor:'#777', hoverBorderWidth:3, hoverBorderColor:'#000' }] }, options:{ title:{ display:true, text:'Largest Cities In Massachusetts', fontSize:25, responsive: true }, legend:{ display:true, position:'right', labels:{ fontColor:'#000' } }, layout:{ padding:{ left:50, right:0, bottom:0, top:0 } }, tooltips:{ enabled:true } } }); var myChart2 = document.getElementById('myChart2').getContext('2d'); var massPopChart = new Chart(myChart2, { type:'horizontalBar', // bar, horizontalBar, pie, line, doughnut, radar, polarArea data:{ labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'], datasets:[{ label:'Population', data:[ 617594, 181045, 153060, 106519, 105162, 95072 ], //backgroundColor:'green', backgroundColor:[ 'rgba(255, 99, 132, 0.6)', 'rgba(54, 162, 235, 0.6)', 'rgba(255, 206, 86, 0.6)', 'rgba(75, 192, 192, 0.6)', 'rgba(153, 102, 255, 0.6)', 'rgba(255, 159, 64, 0.6)', 'rgba(255, 99, 132, 0.6)' ], borderWidth:1, borderColor:'#777', hoverBorderWidth:3, hoverBorderColor:'#000' }] }, options:{ title:{ display:true, text:'Largest Cities In Massachusetts', fontSize:25 }, legend:{ display:true, position:'right', labels:{ fontColor:'#000' } }, responsive: true, tooltips:{ enabled:true } } }); [/code] Вот HTML-скрипт [code] Area Chart [i][/i] [i][/i] Chart Bar [i][/i] [i][/i] [/code] Спасибо Подробнее здесь: [url]https://stackoverflow.com/questions/57288297/how-i-include-my-chart-js-script-to-admin-lte[/url]