Skip to content

Commit

Permalink
add colorscales
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonMrt committed Jul 21, 2024
1 parent fc5a526 commit 9fc940f
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 3 deletions.
7 changes: 5 additions & 2 deletions Tests/ArrayCoreTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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!!!";
Expand Down Expand Up @@ -198,7 +198,10 @@ TEST(ArrayCore, readAndShowMatrixFromFile) {
vector<vector<double>> 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);
}

Expand Down
7 changes: 6 additions & 1 deletion array_core/configurator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};


Expand Down
20 changes: 20 additions & 0 deletions plotly_maker/html_parts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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} <br>y:%{y} <br>val:%{z:.}<extra></extra>',
Expand Down
7 changes: 7 additions & 0 deletions plotly_maker/html_parts.h
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down
15 changes: 15 additions & 0 deletions plotly_maker/plotly_maker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,21 @@ bool createHtmlPageWithPlotlyJS(const std::vector<std::vector<double>>& 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:
Expand Down

0 comments on commit 9fc940f

Please sign in to comment.