mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +01:00 
			
		
		
		
	chore(demo): move to right directory
This commit is contained in:
		| @@ -0,0 +1,46 @@ | ||||
| async function getChartData() { | ||||
|     const days = await api.runOnBackend(() => { | ||||
|         const notes = api.getNotesWithLabel('weight'); | ||||
|         const days = []; | ||||
|  | ||||
|         for (const note of notes) { | ||||
|             const date = note.getLabelValue('dateNote'); | ||||
|             const weight = parseFloat(note.getLabelValue('weight')); | ||||
|  | ||||
|             if (date && weight) { | ||||
|                 days.push({ date, weight }); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         days.sort((a, b) => a.date > b.date ? 1 : -1); | ||||
|  | ||||
|         return days; | ||||
|     }); | ||||
|  | ||||
|     const datasets = [ | ||||
|         { | ||||
|             label: "Weight (kg)", | ||||
|             backgroundColor: 'red', | ||||
|             borderColor: 'red', | ||||
|             data: days.map(day => day.weight), | ||||
|             fill: false, | ||||
|             spanGaps: true, | ||||
|             datalabels: { | ||||
|                 display: false | ||||
|             }, | ||||
|             tension: 0.3 | ||||
|         } | ||||
|     ]; | ||||
|  | ||||
|     return { | ||||
|         datasets: datasets, | ||||
|         labels: days.map(day => day.date) | ||||
|     }; | ||||
| } | ||||
|  | ||||
| const ctx = api.$container.find("canvas")[0].getContext("2d"); | ||||
|  | ||||
| new chartjs.Chart(ctx, { | ||||
|     type: 'line', | ||||
|     data: await getChartData() | ||||
| }); | ||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
		Reference in New Issue
	
	Block a user