From f974d740fcea600fd33e076903681381ff095c88 Mon Sep 17 00:00:00 2001 From: AntonMrt Date: Sat, 25 Nov 2023 20:35:10 +0300 Subject: [PATCH] add colorscale to conctructor --- Tests/ArrayCoreTest.cpp | 3 +-- Tests/PlotlyLibTest.cpp | 12 ++++-------- plotly_maker/plotly_maker.cpp | 8 ++++---- plotly_maker/plotly_maker.h | 12 ++++++------ 4 files changed, 15 insertions(+), 20 deletions(-) diff --git a/Tests/ArrayCoreTest.cpp b/Tests/ArrayCoreTest.cpp index 2b25b25..244b687 100644 --- a/Tests/ArrayCoreTest.cpp +++ b/Tests/ArrayCoreTest.cpp @@ -17,8 +17,7 @@ TEST(ArrayCore, showDefaultSettings) { TEST(ArrayCore, showHeatMap1) { EXPECT_EQ(davis::isPlotlyScriptExists(), true); vector> values = {{30.3, 40, 98, 76}, {99, 45, 20, 1}, {5, 56, 93, 25}, {45, 23, 90, 2}}; - auto settings = davis::createShowSettingsHeatMap(); - settings->colorScale = davis::colorscales::GLAMOUR; + auto settings = davis::createShowSettingsHeatMap(davis::colorscales::GLAMOUR); bool result = davis::show(values, "showHeatMap1", settings.get()); EXPECT_EQ(result, true); } diff --git a/Tests/PlotlyLibTest.cpp b/Tests/PlotlyLibTest.cpp index 830b12a..eab0223 100644 --- a/Tests/PlotlyLibTest.cpp +++ b/Tests/PlotlyLibTest.cpp @@ -22,8 +22,7 @@ TEST(PlotlyMaker, CreateDefaultHeatMapHtmlPageTest) { TEST(PlotlyMaker, ShowGlamourHeatMapHtmlPageTest) { std::vector>testValues = {{43, 400, 54, 980}, {200, 36, 400, 55}, {120, 4, 650, 5}}; std::string str_page = "veryGlamourPage"; - auto settings = std::make_unique(); - settings->colorScale = davis::colorscales::GLAMOUR; + auto settings = std::make_unique(davis::colorscales::GLAMOUR); bool result = davis::showHeatMapInBrowser(testValues, str_page, settings.get()); EXPECT_EQ(result, true); } @@ -31,8 +30,7 @@ TEST(PlotlyMaker, ShowGlamourHeatMapHtmlPageTest) { TEST(PlotlyMaker, ShowThermalHeatMapHtmlPageTest) { std::vector>testValues = {{43, 400, 54, 980}, {200, 36, 400, 55}, {120, 4, 650, 5}}; std::string str_page = "veryHotPage"; - auto settings = std::make_unique(); - settings->colorScale = davis::colorscales::THERMAL; + auto settings = std::make_unique(davis::colorscales::THERMAL); bool result = davis::showHeatMapInBrowser(testValues, str_page, settings.get()); EXPECT_EQ(result, true); } @@ -40,8 +38,7 @@ TEST(PlotlyMaker, ShowThermalHeatMapHtmlPageTest) { TEST(PlotlyMaker, ShowSunnyHeatMapHtmlPageTest) { std::vector>testValues = {{43, 400, 54, 980}, {200, 36, 400, 55}, {120, 4, 650, 5}}; std::string str_page = "SunnyPage"; - auto settings = std::make_unique(); - settings->colorScale = davis::colorscales::SUNNY; + auto settings = std::make_unique(davis::colorscales::SUNNY); bool result = davis::showHeatMapInBrowser(testValues, str_page, settings.get()); EXPECT_EQ(result, true); } @@ -49,8 +46,7 @@ TEST(PlotlyMaker, ShowSunnyHeatMapHtmlPageTest) { TEST(PlotlyMaker, ShowThermalSurfaceHtmlPageTest) { std::vector>testValues = {{43, 400, 54, 980}, {200, 36, 400, 55}, {120, 4, 650, 5}}; std::string str_page = "ThermalSurfacePage"; - auto settings = std::make_unique(); - settings->colorScale = davis::colorscales::THERMAL; + auto settings = std::make_unique(davis::colorscales::THERMAL); bool result = davis::showSurfaceInBrowser(testValues, str_page, settings.get()); EXPECT_EQ(result, true); } diff --git a/plotly_maker/plotly_maker.cpp b/plotly_maker/plotly_maker.cpp index d0be799..ec1947e 100644 --- a/plotly_maker/plotly_maker.cpp +++ b/plotly_maker/plotly_maker.cpp @@ -253,12 +253,12 @@ std::unique_ptr testF() { } -std::unique_ptr createShowSettingsHeatMap() { - return std::make_unique(); +std::unique_ptr createShowSettingsHeatMap(colorscales color) { + return std::make_unique(color); } -std::unique_ptr createShowSettingsSurface() { - return std::make_unique(); +std::unique_ptr createShowSettingsSurface(colorscales color) { + return std::make_unique(color); } std::unique_ptr createShowSettingsChart() { diff --git a/plotly_maker/plotly_maker.h b/plotly_maker/plotly_maker.h index 40c79e9..2c4627b 100644 --- a/plotly_maker/plotly_maker.h +++ b/plotly_maker/plotly_maker.h @@ -34,18 +34,18 @@ class ShowSettings { class ShowSettingsHeatMap : public ShowSettings { public: - ShowSettingsHeatMap() { + ShowSettingsHeatMap(colorscales color = colorscales::DEFAULT) { visualType = visualizationTypes::HEATMAP; - colorScale = colorscales::DEFAULT; + colorScale = color; } colorscales colorScale; }; class ShowSettingsSurface : public ShowSettings { public: - ShowSettingsSurface() { + ShowSettingsSurface(colorscales color = colorscales::DEFAULT) { visualType = visualizationTypes::SURFACE; - colorScale = colorscales::DEFAULT; + colorScale = color; } colorscales colorScale; }; @@ -57,8 +57,8 @@ class ShowSettingsChart : public ShowSettings { } }; -std::unique_ptr createShowSettingsHeatMap(); -std::unique_ptr createShowSettingsSurface(); +std::unique_ptr createShowSettingsHeatMap(colorscales color = colorscales::DEFAULT); +std::unique_ptr createShowSettingsSurface(colorscales color = colorscales::DEFAULT); std::unique_ptr createShowSettingsChart(); bool createHtmlPageWithPlotlyJS(const vector>& values,