From 9fc940f978321d74d5cb9b131cdf5f2fec870274 Mon Sep 17 00:00:00 2001 From: AntonMrt Date: Sun, 21 Jul 2024 15:16:22 +0300 Subject: [PATCH] add colorscales --- Tests/ArrayCoreTest.cpp | 7 +++++-- array_core/configurator.h | 7 ++++++- plotly_maker/html_parts.cpp | 20 ++++++++++++++++++++ plotly_maker/html_parts.h | 7 +++++++ plotly_maker/plotly_maker.cpp | 15 +++++++++++++++ 5 files changed, 53 insertions(+), 3 deletions(-) diff --git a/Tests/ArrayCoreTest.cpp b/Tests/ArrayCoreTest.cpp index 01c76f9..8d85e76 100644 --- a/Tests/ArrayCoreTest.cpp +++ b/Tests/ArrayCoreTest.cpp @@ -111,7 +111,7 @@ TEST(ArrayCore, configurator) { config.heatmap.xLabel = "Столбцы"; config.heatmap.yLabel = "Строки"; config.heatmap.title = "Тестовая матрица"; - config.heatmap.colorSc = dv::COLORSCALE_GLAMOUR; + config.heatmap.colorSc = dv::COLORSCALE_YlGnBu; bool result1 = dv::show(values, "HeatMap", config); config.typeVisual = dv::VISUALTYPE_SURFACE; config.surf.title = "This is Surface!!!"; @@ -198,7 +198,10 @@ TEST(ArrayCore, readAndShowMatrixFromFile) { vector> values; bool readRes = dvs::readMatrix(values, "./data/2023_07_19-12_59_31_379_Baumer2_text.csv", ';'); EXPECT_EQ(readRes, true); - bool result = dv::show(values, "readAndShowMatrixFromFile"); + auto config = dv::Config(); + config.heatmap.xLabel = "english"; + config.heatmap.yLabel = "русский"; + bool result = dv::show(values, "readAndShowMatrixFromFile", config); EXPECT_EQ(result, true); } diff --git a/array_core/configurator.h b/array_core/configurator.h index a8b62a4..0a6fba9 100644 --- a/array_core/configurator.h +++ b/array_core/configurator.h @@ -17,7 +17,12 @@ enum config_colorscales { COLORSCALE_SUNNY, COLORSCALE_GLAMOUR, COLORSCALE_THERMAL, - COLORSCALE_GRAYSCALE + COLORSCALE_GRAYSCALE, + COLORSCALE_YlGnBu, + COLORSCALE_JET, + COLORSCALE_HOT, + COLORSCALE_ELECTRIC, + COLORSCALE_PORTLAND }; diff --git a/plotly_maker/html_parts.cpp b/plotly_maker/html_parts.cpp index d242eb6..9455c95 100644 --- a/plotly_maker/html_parts.cpp +++ b/plotly_maker/html_parts.cpp @@ -104,6 +104,26 @@ Plotly.newPlot('gd', data, layout, config); ['1.0', 'rgb(255, 255, 255)'] ],)"; + const char kColorMapYlGnBuPart[] = R"( + colorscale: 'YlGnBu', + )"; + + const char kColorMapJetPart[] = R"( + colorscale: 'Jet', + )"; + + const char kColorMapHotPart[] = R"( + colorscale: 'Hot', + )"; + + const char kColorMapElectricPart[] = R"( + colorscale: 'Electric', + )"; + + const char kColorMapPortlandPart[] = R"( + colorscale: 'Portland', + )"; + const char kHeatMapTypePart[] = R"( type: 'heatmap', hovertemplate: 'x:%{x}
y:%{y}
val:%{z:.}', diff --git a/plotly_maker/html_parts.h b/plotly_maker/html_parts.h index 6d799a8..c2d5c84 100644 --- a/plotly_maker/html_parts.h +++ b/plotly_maker/html_parts.h @@ -20,6 +20,13 @@ extern const char kColorMapSunnyPart[]; extern const char kColorMapGlamourPart[]; extern const char kColorMapThermalPart[]; extern const char kColorMapGrayscalePart[]; + +extern const char kColorMapYlGnBuPart[]; +extern const char kColorMapJetPart[]; +extern const char kColorMapHotPart[]; +extern const char kColorMapElectricPart[]; +extern const char kColorMapPortlandPart[]; + extern const char kHeatMapTypePart[]; extern const char kSurfaceTypePart[]; extern const char kWarningJSLibAbsentPage[]; diff --git a/plotly_maker/plotly_maker.cpp b/plotly_maker/plotly_maker.cpp index f1f9024..4bb74a4 100644 --- a/plotly_maker/plotly_maker.cpp +++ b/plotly_maker/plotly_maker.cpp @@ -151,6 +151,21 @@ bool createHtmlPageWithPlotlyJS(const std::vector>& values, case dv::config_colorscales::COLORSCALE_GRAYSCALE: args[ARG_COLOR_MAP] = kColorMapGrayscalePart; break; + case dv::config_colorscales::COLORSCALE_YlGnBu: + args[ARG_COLOR_MAP] = kColorMapYlGnBuPart; + break; + case dv::config_colorscales::COLORSCALE_JET: + args[ARG_COLOR_MAP] = kColorMapJetPart; + break; + case dv::config_colorscales::COLORSCALE_HOT: + args[ARG_COLOR_MAP] = kColorMapHotPart; + break; + case dv::config_colorscales::COLORSCALE_ELECTRIC: + args[ARG_COLOR_MAP] = kColorMapElectricPart; + break; + case dv::config_colorscales::COLORSCALE_PORTLAND: + args[ARG_COLOR_MAP] = kColorMapPortlandPart; + break; } switch (typeVisual) { case dv::VISUALTYPE_HEATMAP: