@@ -241,36 +241,89 @@ const charts = computed(() => {
241241 return objs
242242})
243243
244+ // Add Blade Tip Deflection Chart with Local Line Data
244245const bladeTipChart = computed (() => {
245- const configs = [
246- { frequency: 0.05 , amplitude: 70 , phase: 0 , label: ' sin(x)' , color: ' #1f77b4' },
247- { frequency: 0.1 , amplitude: 50 , phase: 0 , label: ' sin(2x)' , color: ' #ff7f0e' },
248- { frequency: 0.15 , amplitude: 40 , phase: 0 , label: ' sin(3x)' , color: ' #2ca02c' },
249- { frequency: 0.08 , amplitude: 30 , phase: Math .PI / 4 , label: ' sin(1.6x)' , color: ' #d62728' }
250- ]
251-
252- let data = { datasets: [] } as ChartData <' scatter' >
246+ const currentModeData = project .modeViz [project .currentVizID ]
253247
254- // Generate data for each sine wave
255- configs .forEach (config => {
256- const points: {x: number , y: number }[] = []
257- for (let i = 0 ; i < 200 ; i ++ ) {
258- const x = (i - 100 ) * 0.1
259- const y = config .amplitude * Math .sin (x * (config .frequency / 0.05 ) + config .phase )
260- points .push ({ x , y })
248+ // Get Component names
249+ const componentNames = new Set <string >()
250+ for (const frame of currentModeData .Frames ) {
251+ for (const componentName in frame .Components ) {
252+ componentNames .add (componentName )
261253 }
262-
263- data .datasets .push ({
264- label: config .label ,
265- data: points ,
266- borderColor: config .color ,
267- backgroundColor: config .color ,
268- showLine: true ,
269- pointRadius: 0 ,
270- pointHoverRadius: 4 ,
271- borderWidth: 2 ,
272- })
273- })
254+ }
255+ console .log (" Component Names:" , Array .from (componentNames ))
256+
257+ const datasets: any [] = []
258+ const colors = [' #1f77b4' , ' #ff7f0e' , ' #2ca02c' , ' #d62728' , ' #9467bd' , ' #8c564b' ] // Expecting 3 blades with 2 series each (Flap and Edge)
259+ let colorIndex = 0
260+
261+ // Loop over each component (blade) - similar to PlotTipDeflection
262+ for (const componentName of componentNames ) {
263+ console .log (" Adding series for" , componentName )
264+
265+ // For the blade tip, we only need the last point of each frame
266+ const tipFlapData: {x: number , y: number }[] = []
267+ const tipEdgeData: {x: number , y: number }[] = []
268+
269+ for (let frameIndex = 0 ; frameIndex < currentModeData .Frames .length ; frameIndex ++ ) {
270+ const frame = currentModeData .Frames [frameIndex ]
271+
272+ if (frame .Components [componentName ]) {
273+ const component = frame .Components [componentName ]
274+
275+ // Check if LocalLine exists and has data
276+ if (component .LocalLine && component .LocalLine .length > 0 ) {
277+ // Get the last point (tip)
278+ const tipPoint = component .LocalLine [component .LocalLine .length - 1 ]
279+
280+ tipFlapData .push ({
281+ x: frameIndex + 1 , // Frame numbers start from 1
282+ y: tipPoint .XYZ [0 ] // X coordinate (Flap direction)
283+ })
284+
285+ tipEdgeData .push ({
286+ x: frameIndex + 1 , // Frame numbers start from 1
287+ y: tipPoint .XYZ [1 ] // Y coordinate (Edge direction)
288+ })
289+ }
290+ }
291+ }
292+
293+ console .log (" Tip Flap data:" , tipFlapData )
294+ console .log (" Tip Edge data:" , tipEdgeData )
295+
296+ // Create Flap series
297+ if (tipFlapData .length > 0 ) {
298+ datasets .push ({
299+ label: ` Flap_${componentName } ` ,
300+ data: tipFlapData ,
301+ borderColor: colors [colorIndex % colors .length ],
302+ backgroundColor: colors [colorIndex % colors .length ],
303+ showLine: true ,
304+ pointRadius: 2 ,
305+ pointHoverRadius: 4 ,
306+ borderWidth: 2 ,
307+ })
308+ }
309+
310+ // Create Edge series
311+ if (tipEdgeData .length > 0 ) {
312+ datasets .push ({
313+ label: ` Edge_${componentName } ` ,
314+ data: tipEdgeData ,
315+ borderColor: colors [(colorIndex + 1 ) % colors .length ],
316+ backgroundColor: colors [(colorIndex + 1 ) % colors .length ],
317+ showLine: true ,
318+ pointRadius: 2 ,
319+ pointHoverRadius: 4 ,
320+ borderWidth: 2 ,
321+ borderDash: [5 , 5 ], // Dashed line to distinguish from Flap
322+ })
323+ }
324+
325+ colorIndex += 2 // Increment by 2 since we use 2 colors per component
326+ }
274327
275328 const options: ChartOptions <' scatter' > = {
276329 responsive: true ,
@@ -280,12 +333,12 @@ const bladeTipChart = computed(() => {
280333 display: true ,
281334 position: ' right' ,
282335 labels: {
283- font: { size: 12 }
336+ font: { size: 10 }
284337 }
285338 },
286339 title: {
287340 display: true ,
288- text: ' Blade Tip Deflection across Frames ' ,
341+ text: ' Blade Tip Deflection' ,
289342 font: { size: 16 , weight: ' bold' }
290343 }
291344 },
@@ -312,11 +365,10 @@ const bladeTipChart = computed(() => {
312365 animation: { duration: 0 }
313366 }
314367
315- return { data , options }
368+ return { data: { datasets } , options }
316369})
317370
318371
319-
320372 </script >
321373
322374<template >
@@ -604,12 +656,12 @@ const bladeTipChart = computed(() => {
604656 <div class =" card-body" >
605657 <div class =" row" >
606658 <div class =" col-10" >
607- <!-- 3D Mode Visualization (80% height) -->
659+ <!-- 3D Mode Visualization -->
608660 <div style =" width :100% ; height : 80vh " >
609661 <ModeViz :ModeData =" project.modeViz[project.currentVizID]" :showNodePaths =" showNodePaths" >
610662 </ModeViz >
611663 </div >
612- <!-- 2D Blade Tip Deflection Chart (20% height) -->
664+ <!-- 2D Blade Tip Deflection Chart -->
613665 <div style =" width :100% ; height : 30vh " class =" mt-3" >
614666 <Scatter ref =" bladeTipChart" :options =" bladeTipChart.options" :data =" bladeTipChart.data" />
615667 </div >
0 commit comments