PlotDirector/PlotLine/Views/Writing/_WritingContextMetrics.cshtml

23 lines
3.7 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@model TimelineViewModel
@using System.Globalization
@{
var scenes=Model.OrderedScenes.ToArray();
string N(double value)=>value.ToString("0.###",CultureInfo.InvariantCulture);
}
<div data-writing-component-fragment data-context-story-chart="metrics">
<button type="button" class="btn btn-link btn-sm float-end" data-context-refresh title="Read updated saved information; does not request AI">Refresh saved data</button>
<p class="small text-muted">Recorded scene metrics · Missing values are gaps, not zero. These are saved values, not a new AI assessment.</p>
@if(Model.MetricGraphs.All(m=>m.Points.Count==0)||scenes.Length==0){<p>No recorded metrics are available. Enable metrics and record values in the existing scene or Timeline tools.</p>}
else{
<div class="writing-chart-controls"><label>Metric <select class="form-select form-select-sm" data-context-metric-select data-writing-view-state="context-metric">@foreach(var metric in Model.MetricGraphs){<option value="@metric.MetricTypeID">@metric.MetricName</option>}</select></label><button type="button" class="btn btn-sm btn-outline-secondary" data-context-center>Show current scene</button></div>
<div class="writing-story-scroll" tabindex="0" aria-label="Recorded metrics in manuscript order" data-writing-view-state="metric-scroll">
<div class="writing-story-chart writing-metric-chart" style="--scene-count:@scenes.Length;--scene-width:48px" data-context-chart>
<div class="writing-current-marker" data-context-current-marker aria-hidden="true"></div>
<div class="writing-plot-row writing-plot-index"><strong>Manuscript</strong>@for(var i=0;i<scenes.Length;i++){<button type="button" data-context-explore="@i" data-context-chart-scene="@scenes[i].SceneID" data-scene-index="@i" title="@scenes[i].SceneTitle">@(scenes[i].SceneNumber.ToString("0.##"))</button>}</div>
@foreach(var metric in Model.MetricGraphs){var points=metric.Points.ToDictionary(p=>p.SceneID);<div data-context-metric="@metric.MetricTypeID"><p>@metric.MetricName · scale @metric.MinValue–@metric.MaxValue</p><svg role="img" aria-label="@metric.MetricName across manuscript scenes" viewBox="0 0 @(scenes.Length*48) 180" style="margin-left:160px;width:@(scenes.Length*48)px;height:180px"><line x1="0" y1="165" x2="@(scenes.Length*48)" y2="165" stroke="currentColor" opacity=".25" />@for(var i=0;i<scenes.Length;i++){if(points.TryGetValue(scenes[i].SceneID,out var point)){var y=165d-150d*(point.Value-metric.MinValue)/Math.Max(1,metric.MaxValue-metric.MinValue);if(i>0&&points.TryGetValue(scenes[i-1].SceneID,out var previous)){var oldY=165d-150d*(previous.Value-metric.MinValue)/Math.Max(1,metric.MaxValue-metric.MinValue);<line x1="@((i-1)*48+24)" y1="@N(oldY)" x2="@(i*48+24)" y2="@N(y)" stroke="var(--plotline-accent)" stroke-width="2" />}<circle cx="@(i*48+24)" cy="@N(y)" r="5" fill="var(--plotline-accent)"><title>@scenes[i].SceneTitle: @point.Value</title></circle>}}</svg></div>}
</div></div>
<label class="writing-scrubber">Explore scenes <input type="range" min="0" max="@(scenes.Length-1)" value="0" data-context-scrubber data-writing-view-state="metric-scrub" /></label>
@for(var i=0;i<scenes.Length;i++){var scene=scenes[i];<article data-context-scene-card="@i" hidden="@(i!=0)"><h3 class="h5">@scene.SceneTitle</h3><p>Chapter @Model.ChapterOptions.FirstOrDefault(c=>c.Value==scene.ChapterID.ToString())?.Text · Scene @(scene.SceneNumber.ToString("0.##"))</p><dl class="writing-context-facts">@foreach(var metric in Model.MetricGraphs){var point=metric.Points.FirstOrDefault(p=>p.SceneID==scene.SceneID);<dt>@metric.MetricName</dt><dd>@(point==null?"Not recorded":$"{point.Value} ({metric.MinValue}–{metric.MaxValue})")</dd>}</dl><button type="button" class="btn btn-outline-primary btn-sm" data-context-go-scene="@scene.SceneID">Go to scene</button></article>}
}
</div>