Merge pull request 'proposition of some fixes' (#1) from PGL/Clyde:tonitch/max/front/fix/vue into master
Reviewed-on: #1
This commit is contained in:
		| @ -6,10 +6,11 @@ | |||||||
| -----------------------------------------------------> | -----------------------------------------------------> | ||||||
|  |  | ||||||
| <script setup> | <script setup> | ||||||
| import { ref } from "vue"; | import { ref, reactive } from "vue"; | ||||||
| const input = ref(""); | const input = ref(""); | ||||||
| const statsOf = ref(""); | const statsOf = ref(""); | ||||||
| const statsBy = ref(""); | const statsBy = ref(""); | ||||||
|  | let chart; | ||||||
|  |  | ||||||
| const jsonMockViewsByYears= [ | const jsonMockViewsByYears= [ | ||||||
|   {label: "2004", y:4}, |   {label: "2004", y:4}, | ||||||
| @ -39,9 +40,7 @@ function inputKeyUp() { | |||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
| const mydata = { | const options = reactive({ | ||||||
|   chart:null, |  | ||||||
|   options: { |  | ||||||
|     backgroundColor:null, |     backgroundColor:null, | ||||||
|     theme: "light2", |     theme: "light2", | ||||||
|     animationEnabled: true, |     animationEnabled: true, | ||||||
| @ -57,33 +56,21 @@ const mydata = { | |||||||
|         indexLabelFontColor: "white", |         indexLabelFontColor: "white", | ||||||
|         toolTipContent: |         toolTipContent: | ||||||
|           "<span style='\"'color: {color};'\"'>{label}</span> {y}(#percent%)", |           "<span style='\"'color: {color};'\"'>{label}</span> {y}(#percent%)", | ||||||
|       }, |       }] | ||||||
|     ], | 	}); | ||||||
|   }, |  | ||||||
|   styleOptions: { | function update(){ | ||||||
|     width: "100%", |       options.title = { | ||||||
|     height: "100%", |  | ||||||
|   }, |  | ||||||
|   methods : { |  | ||||||
|     chartInstance(chart){ |  | ||||||
|       mydata.chart = chart; |  | ||||||
|     }, |  | ||||||
|     update(){ |  | ||||||
|       mydata.options.title = { |  | ||||||
|         fontColor: "white", |         fontColor: "white", | ||||||
|         text: statsOf.value + " By "+ statsBy.value, |         text: statsOf.value + " By "+ statsBy.value, | ||||||
|       } |       } | ||||||
|       if (statsOf.value === "views" && statsBy.value === "years") { |       if (statsOf.value === "views" && statsBy.value === "years") { | ||||||
|         console.log("yeasear") |         options.data[0].dataPoints = jsonMockViewsByYears; | ||||||
|         mydata.options.data[0].dataPoints = jsonMockViewsByYears; |  | ||||||
|       } |       } | ||||||
|  |  | ||||||
|       console.log(mydata.options.data) |       options.title.text = statsOf.value + " By "+ statsBy.value; | ||||||
|       mydata.options.title.text = statsOf.value + " By "+ statsBy.value; |       chart.render() | ||||||
|       mydata.chart.render() |  | ||||||
|     } |     } | ||||||
|   } |  | ||||||
| }; |  | ||||||
| </script> | </script> | ||||||
|  |  | ||||||
| <template> | <template> | ||||||
| @ -106,7 +93,7 @@ const mydata = { | |||||||
|     <div id="stats"> |     <div id="stats"> | ||||||
|       <div class="surrounded"> |       <div class="surrounded"> | ||||||
|         Stat type : |         Stat type : | ||||||
|         <select @change="mydata.methods.update()" name="stats" id="stats-select" v-model="statsOf"> |         <select @change="update()" id="stats-select" v-model="statsOf"> | ||||||
|           <option value="views">Views</option> |           <option value="views">Views</option> | ||||||
|           <option value="co-authors">Co-authors</option> |           <option value="co-authors">Co-authors</option> | ||||||
|           <option value="articles">Articles</option> |           <option value="articles">Articles</option> | ||||||
| @ -115,21 +102,21 @@ const mydata = { | |||||||
|       </div> |       </div> | ||||||
|       <div class="surrounded"> |       <div class="surrounded"> | ||||||
|         Class by: |         Class by: | ||||||
|         <select @change="mydata.methods.update()"  name="classedBy" id="classed-select" v-model="statsBy"> |         <select @change="update()" id="classed-select" v-model="statsBy"> | ||||||
|           <option selected="selected" value="years">Years</option> |           <option selected="selected" value="years">Years</option> | ||||||
|           <option value="months">Months</option> |           <option value="months">Months</option> | ||||||
|           <option value="topics">Topics</option> |           <option value="topics">Topics</option> | ||||||
|         </select> |         </select> | ||||||
|       </div> |       </div> | ||||||
|       <div id="statsPie"> |       <div id="statsPie"> | ||||||
|         <CanvasJSChart :options="mydata.options" :style="mydata.styleOptions"  @chart-ref="mydata.methods.chartInstance"/> | 		  <CanvasJSChart :options="options" id=chart @chart-ref="c => chart = c "/> | ||||||
|       </div> |       </div> | ||||||
|     </div> |     </div> | ||||||
|     <div id="articles"> |     <div id="articles"> | ||||||
|       <input |       <input | ||||||
|         type="text" |         type="text" | ||||||
|         id="search-input" |         id="search-input" | ||||||
|         :onkeyup="inputKeyUp()" |         @keyup="inputKeyUp()" | ||||||
|         placeholder="search articles" |         placeholder="search articles" | ||||||
|         v-model="input" |         v-model="input" | ||||||
|       /> |       /> | ||||||
| @ -241,4 +228,9 @@ const mydata = { | |||||||
| #myUL li a:hover:not(.header) { | #myUL li a:hover:not(.header) { | ||||||
|   background-color: #eee; |   background-color: #eee; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | #Chart{ | ||||||
|  |     width: "100%"; | ||||||
|  |     height: "100%"; | ||||||
|  | } | ||||||
| </style> | </style> | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user