반응형



처음에는 구글 라이브러리를 쓸려다 

혹시 VUE 라이브러리도 있을까? 하고 찾아봤더니 있었음 !!!! ㅎㅎㅎ


vue 컴퍼넌트 설치 방법 공유


우선 PC에 

- nodeJs 설치 필요 그래야 npm 사용 가능 !!!


설치 후 VS_CODE 나 CMD 로 

cmd 에서 node -v  버전 나오면 설치 된거임


Webpack 설치(vue 통합 프레임웍 이라고 생각)

https://github.com/vuejs-templates/webpack-simple


$ npm install -g vue-cli

$ vue init webpack-simple my-project

$ cd my-project

$ npm install

$ npm run dev


프로젝트 뜨는것 확인 후 !!! ( 자동으로 브라우저가 뜬다) 해당 설정은 webpack.config.js 에서 확인 가능


다시 VUE-D2B 설치 (생키 다이어그램을 위해서 )

https://github.com/d2bjs/vue-d2b 


$ npm install vue-d2b --save


http://localhost:8080 에서 제일 처음 호출 되는 Vue 찾아서

- my-project 에 App.vue 


소스 변경 ( 안에 데이터를 좀 변경해봄)


<template>

  <div class = 'chart'>

    <chart-sankey :data = 'chartData' :config = 'chartConfig'></chart-sankey>

  </div>

</template>


<script>

  import { ChartSankey } from 'vue-d2b'


  export default {

    data () {

      return {

        // The chart data varies from chart to chart. To see what type of data

        // to provide each chart type head over to the d2bjs.org docs.

        chartData: {

          nodes: [

            {name: 'Node A'},

            {name: 'Node A_1'},

            {name: 'Node A_2'},

            {name: 'Node A_3'},

            {name: 'Node A_4'},                                    

            {name: 'Node B'},

            {name: 'Node C'},

            {name: 'Node D'},

            {name: 'Node E'},

            {name: 'Node 1'}

          ],

          links: [

            {source: 'Node A', target: 'Node E', value: 200},

            {source: 'Node A', target: 'Node C', value: 2000},

            {source: 'Node B', target: 'Node C', value: 3200},

            {source: 'Node B', target: 'Node D', value: 300},

            {source: 'Node C', target: 'Node D', value: 200},

            {source: 'Node C', target: 'Node E', value: 1202},

            {source: 'Node C', target: 'Node 1', value: 2400},

            {source: 'Node 1', target: 'Node E', value: 2800},

            {source: 'Node A_1', target: 'Node C', value: 120},

            {source: 'Node A_2', target: 'Node C', value: 20},

            {source: 'Node A_3', target: 'Node C', value: 40},

            {source: 'Node A_4', target: 'Node C', value: 80},

            {source: 'Node D', target: 'Node E', value: 400}

          ]

        },


        // There are many configuration options for each chart type, checkout

        // the d2bjs.org docs for more information.

        chartConfig (chart) {

          chart

            // returns the d2b svg sankey generator

            .sankey()

            // returns the d3 sankey generator

            .sankey()

            // now configure the d3 sankey generator through method chaining

            .nodePadding(50)

        }

      }

    },


    components: {

      ChartSankey

    }

  }

</script>


<style scoped>

  .chart{

    height: 500px;

  }

</style>

소스 저장하는 순간 !!!

webpack 에서 설치된 hot reload? 여하튼 그걸로 인하여 

이미 변..경 ㅎㅎㅎ


샘플 적용 끄~읏

반응형
반응형
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
</head>
<body>

<div id="app">
<p>{{ message }}</p>
</div>
<div id="app-2">
<span v-bind:title="message">
내 위에 잠시 마우스를 올리면 동적으로 바인딩 된 title을 볼 수 있습니다!
</span>
</div>
<div id="app-3">
<p v-if="seen">이제 나를 볼 수 있어요</p>
</div>

<div id="app-4">
<ol>
<li v-for="todo in todos">
{{ todo.text }}
</li>
</ol>
</div>

<div id="app-5">
<p>{{ message }}</p>
<button v-on:click="reverseMessage">메시지 뒤집기</button>
</div>
<div id="app-6">
<p>{{ message }}</p>
<input v-model="message">
</div>
<script>
new Vue({
el: '#app',
data: {
message: '하이 Vue'
}
})

var app2 = new Vue({
el: '#app-2',
data: {
message: '이 페이지는 ' + new Date() + ' 에 로드 되었습니다'
}
})

var app3 = new Vue({
el: '#app-3',
data: {
seen:false
}
})

var app4 = new Vue({
el: '#app-4',
data: {
todos: [
{ text: 'JavaScript 배우기' },
{ text: 'Vue 배우기' },
{ text: '무언가 멋진 것을 만들기' }
]
}
})

var app5 = new Vue({
el : '#app-5',
data:{
message : '안녕 하쇼'
},
methods : {
reverseMessage : function() {
this.message = this.message.split('').reverse().join('')
}
}
})

var app6 = new Vue({
el : '#app-6',
data:{
message : '안녕 하쇼'
}

})

</script>

</body>
</html>


반응형
반응형

html



<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  
  <div id="app">
    <h1>카운터 : {{ number }}</h1>
    <button v-on:click="increment">증가 +</button>
    <button v-on:click="decrement">감소 -</button>
  </div>
  
  <script src="https://unpkg.com/vue/dist/vue.js"></script>
</body>
</html>

Js

// 새로운 뷰를 정의합니다

var app = new Vue({

  el: '#app', 

  // 어떤 엘리먼트에 적용을 할 지 정합니다

  // data 는 해당 뷰에서 사용할 정보를 지닙니다

  data: {

    name: 'Vue',

    number: 0

  }   ,

  methods:{

    increment: function() {

      // 인스턴스 내부의 데이터모델에 접근 할 땐,

      // this 를 사용한다

      this.number++;

    },  

    decrement : function(){

      this.number--;

    }

 }

});



코드 테스트 사이트

https://jsbin.com

반응형
반응형

 

var lang = navigator.language || navigator.browserLanguage; 


심플하네 ㅋㅋ

 

2022-12-05 테스트 코드 스샷

2022-12-05 테스트 코드 스샷

반응형
반응형




for(var i = 0; i < resBody.data.length; i++) {

    // 셀렉트 박스에서 제외 시킬것

    if( resBody.data[i].NM == '제외조건'){

resBody.data.splice(0,1); // 배열 자르기

    }

}

//return resBody.data;


참고 URL :  http://programmingsummaries.tistory.com/140

반응형
반응형


문자 요구사항 처리


var test = "10/3";


var lastTxt     =   test.charAt(test.length -1 );               //마지막 문자

var sliceTxt    =   test.slice(0,-1);                               //마지막 문자 제외 가져옴


var sliceInTxt  =   test.substring(0,test.indexOf("/")+1);                  //특정 문자 이전 문자 가져오기  예) 10/3 에서 10/ 여기 까지만

var sliceLastTxt =  test.substring(test.indexOf("/")+1 ,test.length)    //특정 문자 이후 예) 10/3 에서 3 



charAt         : 한개만

Slice            : 영역 제외 잘라내기

substring      : 영역 지정아여 

indexOf        : 특정문자 검색




반응형
반응형


크롬에서 F12 누르면 보임


Sources > Event Listener Breakpoint  > Mouse > click 이벤트 모두 


소스 옆에 숫자 클릭으로 Break 잡을 수 있음


F8 이나 한단계식 승인 가능


Watch 로 변수 타입 확인가능


아래 Console로 변경해서 실행 가능


Sources 수정 후 Ctrl + s 눌러 임시 저장 실행 가능


아래쪽 링크 참고 


https://developers.google.com/web/tools/chrome-devtools/javascript/?hl=ko



반응형
반응형

액셀 데이터 특정 필드 추출


액셀 데이터 추출해서 스크립트로 가져오는 부분은 생략... 

가져와서 추출하는 부분만 정리!!


특정 데이터 타입만 추출하여야 한다

데이터 타입 별  CO2 컬럼에  VALUE 값을 추출해야 한다


첫번째 필드에 추출 타입이 명칭이 들어 있고 

그 이후 공백

다른 데이터 타입이 들어오고 ..

다시 공백..


으아 말로 하니까 엄청 힘드네요 ㅎㅎ



COL0 | COL1 |  COL2 | 

--------------------------------------------------------------------------------

DATA_TYPE | CODE | VALUE |

DATA1   | CD100 | 11 |

 |   | CD200 | 22 | 

 |   | CD300 | 22 | 

 |   | CD400 | 22 | 

DATA2   | CD100 | 11 |

 |   | CD200 | 22 | 

 |   | CD300 | 22 | 

 |   | CD400 | 22 | 


 .. 위 형식에 Excel 형태이다..


 데이터 타입에 공백말고 쭉~~ 넣어주면 개발이 편한데 ...바꿀 수가 없으니 

 스크립트로 삽질 시작..


데이터 타입 배열 변수 초기화

var  DATA1 = new Array;

var  DATA2 = new Array;


데이터 타입 전역 변수 초기화

var EXCEL_DATANAME ="";


가져온 액셀 리스트 루프


for (var i = 0;  i < Excellist.length;  i++) {


var data_type = $.trim(Excellist[i]["COL0"]);  //전체 데이터 타입


if( data_type == "" ){ //공백이면


if(EXCEL_DATANAME =='DATA1'){

DATA1.push($.trim(datalist[i]["COL2"]));

}


}else{ //공백이 아니면


EXCEL_DATANAME = data_type;  // 데이터 타입이름 저장

if(data_type == 'DATA1'){

DATA1.push($.trim(datalist[i]["COL2"]));

}


}


}

//만들어진 배열 확인

console.log("배열  DATA1 " , DATA1);


만들고 보니 간단한데..

머리가 나쁜지.. 삽질.. 실제데이터는 좀 더 복잡하긴 하지만... 


특이하게  아래코드가 배열 푸시가 안됨

ex) data_type.push($.trim(datalist[i]["COL2"]));

변수이름이.push 방법 찾아보다 포기...


해당 부분만 되었어도 코드가 깔금하고 여러 데이터 타입을 추려낼때도 노가다 코드가 필요없을것 같다.


오늘의 삽질기 종료

반응형
반응형

 

스크립트 object 를 출력 할 간단한 뭐 없을까~ 찾아보다

 

콘솔에 뿌리고 싶은 오브젝트를 

 

console.log(JSON.stringify(obj));

해주면 됩니다.. 캐간단~!!!

 

value below was evaluated just now ...

 

참고 사이트 :

https://stackoverflow.com/questions/44362783/value-below-was-evaluated-just-now-in-javascript-object

반응형
반응형

$(document).ready(function(){

 //기준 날짜 셋팅 yyyyMMDD 형식으로 셋팅

var settingDate = new Date();

settingDate.setDate(settingDate.getDate()); //오늘

//console.log( dateToYYYYMMDD(settingDate) );

var Today = dateToYYYYMMDD(settingDate);


settingDate.setMonth(settingDate.getMonth()-1); //1달 전

//console.log( dateToYYYYMMDD(settingDate) );

var oneMonth = dateToYYYYMMDD(settingDate);

 

settingDate.setMonth(settingDate.getMonth()-3); //3달 전

//console.log( dateToYYYYMMDD(settingDate) );

var threeMonth = dateToYYYYMMDD(settingDate);

 

settingDate.setMonth(settingDate.getMonth()-6); //6달 전

//console.log( dateToYYYYMMDD(settingDate) );

var sixMonth = dateToYYYYMMDD(settingDate);


//기간조회 클릭할때 이벤트..

$('.select_wrap li').click( function(){

  var index = $("li").index(this);

   //li 4번째가 1달

 switch (index) { 

case 4: 

 settingDate.setMonth(settingDate.getMonth()-1); 

$('.icon_sort').text( oneMonth +"-"+ Today );

$("#start_date").val(oneMonth ); 

      $("#end_date").val(Today );

break;

case 5: 

$('.icon_sort').text( threeMonth +"-"+ Today );

$("#start_date").val(threeMonth ); 

      $("#end_date").val(Today );

break;

case 6: 

$('.icon_sort').text( sixMonth +"-"+ Today );

$("#start_date").val(sixMonth ); 

      $("#end_date").val(Today );

break;

default:

$('.icon_sort').text( oneMonth +"-"+ Today );

$("#start_date").val(oneMonth ); 

      $("#end_date").val(Today );

//alert('Nobody Wins!');

}   


}); //기간조회 클릭할때 이벤트..END

});

function dateToYYYYMMDD(date){

   function pad(num) {

       num = num + '';

       return num.length < 2 ? '0' + num : num;

   }

   return date.getFullYear() + '-' + pad(date.getMonth()+1) + '-' + pad(date.getDate());

}

반응형

+ Recent posts