Skip to content

Commit

Permalink
add colorscale to conctructor
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonMrt committed Nov 25, 2023
1 parent 5495b19 commit f974d74
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 20 deletions.
3 changes: 1 addition & 2 deletions Tests/ArrayCoreTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ TEST(ArrayCore, showDefaultSettings) {
TEST(ArrayCore, showHeatMap1) {
EXPECT_EQ(davis::isPlotlyScriptExists(), true);
vector<vector<double>> 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);
}
Expand Down
12 changes: 4 additions & 8 deletions Tests/PlotlyLibTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,31 @@ TEST(PlotlyMaker, CreateDefaultHeatMapHtmlPageTest) {
TEST(PlotlyMaker, ShowGlamourHeatMapHtmlPageTest) {
std::vector<std::vector<double>>testValues = {{43, 400, 54, 980}, {200, 36, 400, 55}, {120, 4, 650, 5}};
std::string str_page = "veryGlamourPage";
auto settings = std::make_unique<davis::ShowSettingsHeatMap>();
settings->colorScale = davis::colorscales::GLAMOUR;
auto settings = std::make_unique<davis::ShowSettingsHeatMap>(davis::colorscales::GLAMOUR);
bool result = davis::showHeatMapInBrowser(testValues, str_page, settings.get());
EXPECT_EQ(result, true);
}

TEST(PlotlyMaker, ShowThermalHeatMapHtmlPageTest) {
std::vector<std::vector<double>>testValues = {{43, 400, 54, 980}, {200, 36, 400, 55}, {120, 4, 650, 5}};
std::string str_page = "veryHotPage";
auto settings = std::make_unique<davis::ShowSettingsHeatMap>();
settings->colorScale = davis::colorscales::THERMAL;
auto settings = std::make_unique<davis::ShowSettingsHeatMap>(davis::colorscales::THERMAL);
bool result = davis::showHeatMapInBrowser(testValues, str_page, settings.get());
EXPECT_EQ(result, true);
}

TEST(PlotlyMaker, ShowSunnyHeatMapHtmlPageTest) {
std::vector<std::vector<double>>testValues = {{43, 400, 54, 980}, {200, 36, 400, 55}, {120, 4, 650, 5}};
std::string str_page = "SunnyPage";
auto settings = std::make_unique<davis::ShowSettingsHeatMap>();
settings->colorScale = davis::colorscales::SUNNY;
auto settings = std::make_unique<davis::ShowSettingsHeatMap>(davis::colorscales::SUNNY);
bool result = davis::showHeatMapInBrowser(testValues, str_page, settings.get());
EXPECT_EQ(result, true);
}

TEST(PlotlyMaker, ShowThermalSurfaceHtmlPageTest) {
std::vector<std::vector<double>>testValues = {{43, 400, 54, 980}, {200, 36, 400, 55}, {120, 4, 650, 5}};
std::string str_page = "ThermalSurfacePage";
auto settings = std::make_unique<davis::ShowSettingsSurface>();
settings->colorScale = davis::colorscales::THERMAL;
auto settings = std::make_unique<davis::ShowSettingsSurface>(davis::colorscales::THERMAL);
bool result = davis::showSurfaceInBrowser(testValues, str_page, settings.get());
EXPECT_EQ(result, true);
}
Expand Down
8 changes: 4 additions & 4 deletions plotly_maker/plotly_maker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,12 @@ std::unique_ptr<ShowSettings> testF() {
}


std::unique_ptr<ShowSettingsHeatMap> createShowSettingsHeatMap() {
return std::make_unique<ShowSettingsHeatMap>();
std::unique_ptr<ShowSettingsHeatMap> createShowSettingsHeatMap(colorscales color) {
return std::make_unique<ShowSettingsHeatMap>(color);
}

std::unique_ptr<ShowSettingsSurface> createShowSettingsSurface() {
return std::make_unique<ShowSettingsSurface>();
std::unique_ptr<ShowSettingsSurface> createShowSettingsSurface(colorscales color) {
return std::make_unique<ShowSettingsSurface>(color);
}

std::unique_ptr<ShowSettingsChart> createShowSettingsChart() {
Expand Down
12 changes: 6 additions & 6 deletions plotly_maker/plotly_maker.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand All @@ -57,8 +57,8 @@ class ShowSettingsChart : public ShowSettings {
}
};

std::unique_ptr<ShowSettingsHeatMap> createShowSettingsHeatMap();
std::unique_ptr<ShowSettingsSurface> createShowSettingsSurface();
std::unique_ptr<ShowSettingsHeatMap> createShowSettingsHeatMap(colorscales color = colorscales::DEFAULT);
std::unique_ptr<ShowSettingsSurface> createShowSettingsSurface(colorscales color = colorscales::DEFAULT);
std::unique_ptr<ShowSettingsChart> createShowSettingsChart();

bool createHtmlPageWithPlotlyJS(const vector<vector<double>>& values,
Expand Down

0 comments on commit f974d74

Please sign in to comment.