Cleans up most of the code of the html render
This commit is contained in:
parent
8825587e53
commit
f726b7ce15
|
|
@ -27,9 +27,9 @@ fn main() {
|
|||
finishing: args.finishing.then_some(()),
|
||||
})
|
||||
.unwrap();
|
||||
let refined_list = scenarios.generate_refined_recipes().unwrap();
|
||||
let mut refined_list = scenarios.generate_refined_recipes().unwrap();
|
||||
refined_list.inner_sort(|a, b| a.advanced.dps_safe.total_cmp(&b.advanced.dps_safe));
|
||||
|
||||
let b = RefinedEquipementList::default();
|
||||
// if args.html_export{}
|
||||
refined_list.write_html(&save_path).unwrap();
|
||||
|
||||
|
|
|
|||
|
|
@ -152,6 +152,14 @@ pub trait ToCSV {
|
|||
|
||||
/// This element can be converted to an interactive .html
|
||||
pub trait ToAnalysis {
|
||||
/// The explicit type of the underlying data
|
||||
type InnerData;
|
||||
|
||||
/// Sort the inner data with a given closure
|
||||
fn inner_sort<T>(&mut self, closure: T)
|
||||
where
|
||||
T: FnMut(&Self::InnerData, &Self::InnerData) -> std::cmp::Ordering;
|
||||
|
||||
/// Write as html
|
||||
fn write_html(&self, path: &str) -> Result<(), FatalEquipementError>;
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
use crate::{add_field_to_chart, export::initial_chart, interfaces::RecipeCollection};
|
||||
use core::f64;
|
||||
use std::fmt::Display;
|
||||
use std::{cmp::Ordering, fmt::Display};
|
||||
|
||||
use crate::{
|
||||
error::FatalEquipementError,
|
||||
|
|
@ -76,6 +76,15 @@ impl ToTex for RefinedEquipementList {
|
|||
}
|
||||
|
||||
impl ToAnalysis for RefinedEquipementList {
|
||||
type InnerData = RefinedEquipement;
|
||||
|
||||
fn inner_sort<T>(&mut self, closure: T)
|
||||
where
|
||||
T: FnMut(&RefinedEquipement, &RefinedEquipement) -> Ordering,
|
||||
{
|
||||
self.inner.sort_by(closure)
|
||||
}
|
||||
|
||||
// TODO[3]: Consider wether the naming should be a parameter,
|
||||
// or a config should be given or if the scenario should be fed again the Refined and ...
|
||||
fn write_html(&self, save_path: &str) -> Result<(), FatalEquipementError> {
|
||||
|
|
@ -88,33 +97,6 @@ impl ToAnalysis for RefinedEquipementList {
|
|||
// data.inner
|
||||
// .sort_by(|a, b| a.advanced.dps_safe.total_cmp(&b.advanced.dps_safe));
|
||||
|
||||
// let index: Vec<_>;
|
||||
// let data_list: Vec<_>;
|
||||
// (index, data_list) = self
|
||||
// .inner
|
||||
// .iter()
|
||||
// .map(|ref_equipement| {
|
||||
// (
|
||||
// &ref_equipement.advanced.display_name,
|
||||
// &ref_equipement.advanced.damage_per_turn,
|
||||
// )
|
||||
// })
|
||||
// .collect();
|
||||
|
||||
// // TODO[5]: This macro work is interesting while flawed and the optimisations are not worth more time invested now
|
||||
// // TODO: Add this as a function and a macro
|
||||
// // TODO: Convert to macro
|
||||
// // TODO: Call this iteratively with all elements in macro
|
||||
// let raw_data = self.inner.iter().map(|refeq| {
|
||||
// (
|
||||
// &refeq.advanced.display_name,
|
||||
// refeq.advanced.dps_safe,
|
||||
// refeq.advanced.max_damage_per_action,
|
||||
// refeq.advanced.damage_per_turn,
|
||||
// refeq.advanced.armor_break_per_turn,
|
||||
// )
|
||||
// });
|
||||
|
||||
add_field_to_chart!(
|
||||
self,
|
||||
initial_chart,
|
||||
|
|
@ -133,54 +115,6 @@ impl ToAnalysis for RefinedEquipementList {
|
|||
)
|
||||
}
|
||||
);
|
||||
// add_field_to_chart!(dps_safe, graph);
|
||||
|
||||
// let (data_list, dps_safe, max_damage_per_action, max_damage_per_turn, armor_break_per_turn) =
|
||||
// raw_data.collect::<(Vec<_>, Vec<_>, Vec<_>, Vec<_>, Vec<_>)>();
|
||||
// let mut data_list = vec![];
|
||||
// let mut dps_safe = vec![];
|
||||
// let mut max_damage_per_action = vec![];
|
||||
// let mut max_damage_per_turn = vec![];
|
||||
// let mut armor_break_per_turn = vec![];
|
||||
|
||||
// raw_data
|
||||
// .into_iter()
|
||||
// .for_each(|(index, dps_s, dpa, dpt, abpt)| {
|
||||
// data_list.push(index);
|
||||
// dps_safe.push(dps_s);
|
||||
// max_damage_per_action.push(dpa);
|
||||
// max_damage_per_turn.push(dpt);
|
||||
// armor_break_per_turn.push(abpt);
|
||||
// });
|
||||
|
||||
// TODO: End of macro conversion
|
||||
|
||||
// let initial_chart = initial_chart
|
||||
// .x_axis(
|
||||
// charming::component::Axis::new()
|
||||
// .data(data_list.to_vec())
|
||||
// .type_(charming::element::AxisType::Category),
|
||||
// )
|
||||
// .series(
|
||||
// charming::series::Line::new()
|
||||
// .data(dps_safe)
|
||||
// .name("dps_safe"), // .line_style(LineStyle::new().color("paleblue")),
|
||||
// )
|
||||
// .series(
|
||||
// charming::series::Line::new()
|
||||
// .data(max_damage_per_action)
|
||||
// .name("max_damage_per_action"),
|
||||
// )
|
||||
// .series(
|
||||
// charming::series::Line::new()
|
||||
// .data(max_damage_per_turn)
|
||||
// .name("max_damage_per_turn"),
|
||||
// )
|
||||
// .series(
|
||||
// charming::series::Line::new()
|
||||
// .data(armor_break_per_turn)
|
||||
// .name("armor_break_per_turn"),
|
||||
// );
|
||||
|
||||
renderer.save(&initial_chart, format!("{save_path}.html"))?;
|
||||
Ok(())
|
||||
|
|
|
|||
Loading…
Reference in New Issue