본문 바로가기

javascript

(75)
Chart.js Stacked Bar Chart 차트 BorderRadius 사방으로 둥글게 chart js에서 bar 막대 차트를 가로형으로 만들고 가장자리를 모두 둥글게 하고 싶었는데... 생각보다 오래걸림. 왜냐하면 데이터 시작하는 부분에서 자꾸 borderRadius가 안먹었다. 해결 방법은.... 시작하는 데이터에 borderSkipped:false를 해주어야 했다!!! 코드펜에서 테스트한 나의 결과물 : HTML 삽입 미리보기할 수 없는 소스 처음에 영문도 모를 때 도움 받았던 이슈 : https://github.com/chartjs/Chart.js/issues/9217 Stacked bar chart with borderRadius only rounds the last dataset · Issue #9217 · chartjs/Chart.js Expected Behavior All b..
Tabulator와 Chart.js 활용시, Chart.js 데이터를 Tabulator에 넣는 방법. Chart.js를 활용하여 차트를 먼저 만들어 놨는데, Tabulator를 추가할 일이 생겼다. 데이터를 처음부터 다시 가공하기 보다는 만들어 놓은 chart 데이터를 조금만 변형하면 되겠다. Chart.js에서 사용중인 데이터는 다음과 같다. ChartData : {"date":["2023-10-05 12:45:00","2023-10-05 13:00:00","2023-10-05 13:15:00","2023-10-05 13:30:00"],"TRF":[253,256,274,249],"WD_TRF":[268,261,275,274],"YD_TRF":[268,261,275,274],"PDST":[54,45,96,101],"WD_PDST":[58,25,74,101],"YD_PDST":[58,25,74,101],"..
chart js noData 안되는데.. 일단 저장 ㅠㅠ const noData = { id: 'noData', afterDatasetsDraw :((chart, args, plugins) => { const {ctx, data, chartArea : {top, bottom, left, right, width, height} } = chart; ctx.save(); if(mainMixedChart[propertyNM].data.datasets[0].data.length === 0){ ctx.fillStyle = 'rgba(102,102,102, 0.8)'; ctx.fillRect(left, top, width, height); ctx.font = 'bold 20px sans-serif'; ctx.fillStyle = 'black';..
Chart js MixedChart Chart.js MixedChart 막대차트와 라인차트. 테스트 코드지만.. 힘들게 짰는데.. 역시 필요가 없게 되었다. 코드 파기하기전에 복붙해놓고...나중에 공부해야지. 나중이 과연 오긴 할까.. 일단 복붙이라도 ㅠㅠ const mainMixedChart = { mainTrfByAcsr : null, // 시간대별 접근로 교통량 차트 mainTrfByAcsr15mi: null, // 시간대별 접근로 교통량 15분 데이터 차트 mainPdstByAcsr : null, // 시간대별 접근로 보행자 차트 mainLosByAcsr : null, // 시간대별 접근로 보행자 차트 init:function(){ mainMixedChart.getTrfByAcsr_1hh(); // 시간대별 접근로 교통량 1시간 테..
마우스 오버시 svg fill 변경하기 마우스 오버시 svg fill 변경하기. 이렇게 만들어 놓긴했는데 반응이 느려서..사용 안하기로 함. function handleHover(button) { const svgPath = button.getAttribute("data-svg-path"); const svgDiv = button.querySelector("div"); const originalHTML = button.innerHTML; // 초기 HTML 내용 저장\ // 버튼에 마우스 호버 이벤트 리스너 추가 button.addEventListener("mouseenter", () => { // SVG 파일 로드 fetch(svgPath) .then(response => response.text()) .then(svgData => { //..
Chart.js에서 차트 update할 때, 왜 함수로 makeMixedChart를 만들어 놨고, 함수호출해서 MixedChart 생성후에 필요한 옵션을 그때그때 추가하면서 update하는 식인데... 오늘 처음 안 사실.. 1번처럼 하면 안먹혔다. 2번처럼 하면 먹힌다. 함수를 안만들고 그냥 new해서 바로바로 할 때는 또 된다.. //1번 적용안됨. //mainMixedChart.chartNM.options = {plugins:{legend:{display:false}}, datalabels: { display: false }}; //2번 mainMixedChart.chartNM.options.plugins.legend = {display: false }; mainMixedChart.chartNM.options.plugins.datalabels =..
js 객체안에 프로퍼티 출력 방법 자바스크립트... 객체 안에 넣은놈들을 확인하고 싶다.. 어떻게 했더라? 엥? 기억이 안나...!!!! js 객체안에 프로퍼티 출력 방법! 친절한 블로그를 만났다!! 감사!! https://jigeumblog.tistory.com/70 Javascript] 객체의 key(프로퍼티 이름), value(프로퍼티 값) 출력하기 1. Object.keys - 특정 객체의 프로퍼티를 출력하기 const newStudent = { "1.name" : "jinee", "2.age" : 26, "3.class" : "A", "4.number" : "23", "5.birthday" : "1997-04-01", "6.emailAddress": "jinee@google.com", "7.phoneNumber": "010-12..
Chart.js 라인차트에 배경색 넣는 방법 블로그 글 모음 https://blog.vanila.io/chart-js-tutorial-how-to-make-gradient-line-chart-af145e5c92f9 Chart.js Tutorial — How To Make Gradient Line Chart Chart.js is a JavaScript library that allows you to create beautiful charts to represent different types of statistics. It is based on… blog.vanila.io https://www.chartjs.org/docs/latest/charts/area.html#filling-modes Area Chart | Chart.js Area Chart Both line..