From 5e26636c627fd8cc9120f3f8c57535fcb6c33378 Mon Sep 17 00:00:00 2001 From: Russell Standish Date: Mon, 6 Nov 2023 18:22:09 +1100 Subject: [PATCH] Refurbished exportCSV from plots to use pen labels, and merge pen series. For ravel #411. --- src/plot.cc | 73 +++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 60 insertions(+), 13 deletions(-) diff --git a/src/plot.cc b/src/plot.cc index de51013..21bd5f5 100644 --- a/src/plot.cc +++ b/src/plot.cc @@ -1072,30 +1072,77 @@ namespace ecolab } } + string stripPangoMarkup(const string& markedUptext) + { + char *tmp=nullptr; + if (pango_parse_markup(markedUptext.c_str(),-1,0,nullptr,&tmp,nullptr,nullptr)) + { + string ret(tmp); + g_free(tmp); + return ret; + } + return markedUptext; // failed to parse, return original text + } + + struct Round + { + double scale, iscale; + // round data to 5 significant places + Round(const Plot& p): scale(1e5/(p.maxx-p.minx)), iscale(1/scale) {} + double operator()(double x) {return iscale*round(x*scale);} + }; + void Plot::exportAsCSV(const std::string& filename, const string& separator) const { + map tickLabels(xticks.begin(),xticks.end()); + + Round round(*this); + + // assemble the data into a map, keyed by the x values + map> values; + for (size_t i=0, j=0; i0? separator:"")<<"x"<0) of<first)first)) iter=prior; + of<second; + } + for (auto j: i.second) + { + of<