diff --git a/davis_one/davis.cpp b/davis_one/davis.cpp index 39fd9d4..e083ff2 100644 --- a/davis_one/davis.cpp +++ b/davis_one/davis.cpp @@ -39,15 +39,18 @@ namespace dvs { R"( +%13
+%14 -
@@ -504,6 +508,70 @@ const char kHtmlSimpleDataBlock[]= R"davis_delimeter({ })davis_delimeter"; +const char kHtmlComboboxStyleBlock[] = R"davis_delimeter( + +)davis_delimeter"; + +const char kHtmlComboboxSelectBlock[] =R"davis_delimeter( + +)davis_delimeter"; + + +const char kHtmlComboboxUpdateFooBlock[] = R"davis_delimeter( +function updateBackground(select) { + + var selectedImage = select.options[select.selectedIndex].getAttribute('data-image'); + select.style.backgroundImage = 'url("data:image/svg+xml,' + encodeURIComponent(selectedImage) + '")'; + var selectedOption = select.options[select.selectedIndex].text; + switch (selectedOption) { + case 'line': + trace.mode='lines'; + break; + case 'line + point': + trace.mode='lines+markers'; + break; + case 'point': + trace.mode='markers'; + break; + default: console.log('uknown option'); + } + Plotly.newPlot('gd', data, layout, config); + } + + document.addEventListener('DOMContentLoaded', function() { + var dropdown = document.getElementById('dropdown'); + updateBackground(dropdown); + }); +)davis_delimeter"; + // *INDENT-ON* } // namespace dvs end @@ -1143,6 +1211,9 @@ bool showLineChartInBrowser(const vector& xValues, const vector& } args[ARG_ASPECT_WIDTH_OR_HEIGHT] = paramWH; args[ARG_ASPECT_WIDTH_OR_HEIGHT_FOR_AUTOSCALE] = paramWHsecond; + args[ARG_POINT_LINE_SWITCHER_STYLE] = kHtmlComboboxStyleBlock; + args[ARG_POINT_LINE_SWITCHER_SELECT] = kHtmlComboboxSelectBlock; + args[ARG_POINT_LINE_SWITCHER_UPDATE_FOO] = kHtmlComboboxUpdateFooBlock; make_string(kHtmlModel, args, page); string pageName; mayBeCreateJsWorkingFolder(); diff --git a/davis_one/davis.h b/davis_one/davis.h index def5b17..e207fcd 100644 --- a/davis_one/davis.h +++ b/davis_one/davis.h @@ -131,6 +131,9 @@ enum ARGS_INDEX { ARG_ASPECT_RATIO_HEIGHT, //%10 ARG_ASPECT_WIDTH_OR_HEIGHT, //%11 "width" if ARG_ASPECT_RATIO_WIDTH > ARG_ASPECT_RATIO_HEIGHT and "height" if not ARG_ASPECT_WIDTH_OR_HEIGHT_FOR_AUTOSCALE, //%12 if value of it is equal to ARG_ASPECT_WIDTH_OR_HEIGHT it's mean no autoscale. + ARG_POINT_LINE_SWITCHER_STYLE, //%13 + ARG_POINT_LINE_SWITCHER_SELECT, //%14 + ARG_POINT_LINE_SWITCHER_UPDATE_FOO, //%15 // ADD NEW ENUM BEFORE THIS COMMENT ARGS_SIZE }; @@ -158,7 +161,9 @@ enum ARGS_DATE_TIME_PAGE_INDEX { ARG_DATE_TIME_ASPECT_RATIO_HEIGHT, //%4 ARG_DATE_TIME_ASPECT_WIDTH_OR_HEIGHT, //%5 "width" if ARG_ASPECT_RATIO_WIDTH > ARG_ASPECT_RATIO_HEIGHT and "height" if not ARG_DATE_TIME_ASPECT_WIDTH_OR_HEIGHT_FOR_AUTOSCALE, //%6 if value of it is equal to ARG_ASPECT_WIDTH_OR_HEIGHT it's mean no autoscale. - + ARG_DATE_TIME_POINT_LINE_SWITCHER_STYLE, //%7 + ARG_DATE_TIME_POINT_LINE_SWITCHER_SELECT, //%8 + ARG_DATE_TIME_POINT_LINE_SWITCHER_UPDATE_FOO, //%9 // ADD NEW ENUM BEFORE THIS COMMENT ARGS_DATE_TIME_PAGE_SIZE }; @@ -229,6 +234,9 @@ extern const char kHtmlMultiChartModel[]; extern const char kHtmlCloudOfPoints[]; extern const char kHtmlSimpleDataBlock[]; +extern const char kHtmlComboboxStyleBlock[]; +extern const char kHtmlComboboxSelectBlock[]; +extern const char kHtmlComboboxUpdateFooBlock[]; } // namespace dvs end diff --git a/plotly_maker/html_parts.cpp b/plotly_maker/html_parts.cpp index f5fce29..0188a6b 100644 --- a/plotly_maker/html_parts.cpp +++ b/plotly_maker/html_parts.cpp @@ -7,15 +7,18 @@ namespace dvs { R"( +%13
+%14 -
@@ -472,6 +476,70 @@ const char kHtmlSimpleDataBlock[]= R"davis_delimeter({ })davis_delimeter"; +const char kHtmlComboboxStyleBlock[] = R"davis_delimeter( + +)davis_delimeter"; + +const char kHtmlComboboxSelectBlock[] =R"davis_delimeter( + +)davis_delimeter"; + + +const char kHtmlComboboxUpdateFooBlock[] = R"davis_delimeter( +function updateBackground(select) { + + var selectedImage = select.options[select.selectedIndex].getAttribute('data-image'); + select.style.backgroundImage = 'url("data:image/svg+xml,' + encodeURIComponent(selectedImage) + '")'; + var selectedOption = select.options[select.selectedIndex].text; + switch (selectedOption) { + case 'line': + trace.mode='lines'; + break; + case 'line + point': + trace.mode='lines+markers'; + break; + case 'point': + trace.mode='markers'; + break; + default: console.log('uknown option'); + } + Plotly.newPlot('gd', data, layout, config); + } + + document.addEventListener('DOMContentLoaded', function() { + var dropdown = document.getElementById('dropdown'); + updateBackground(dropdown); + }); +)davis_delimeter"; + // *INDENT-ON* //#STOP_GRAB_TO_DVS_NAMESPACE } // namespace dvs diff --git a/plotly_maker/html_parts.h b/plotly_maker/html_parts.h index c4291bf..3e9c55c 100644 --- a/plotly_maker/html_parts.h +++ b/plotly_maker/html_parts.h @@ -16,6 +16,9 @@ enum ARGS_INDEX { ARG_ASPECT_RATIO_HEIGHT, //%10 ARG_ASPECT_WIDTH_OR_HEIGHT, //%11 "width" if ARG_ASPECT_RATIO_WIDTH > ARG_ASPECT_RATIO_HEIGHT and "height" if not ARG_ASPECT_WIDTH_OR_HEIGHT_FOR_AUTOSCALE, //%12 if value of it is equal to ARG_ASPECT_WIDTH_OR_HEIGHT it's mean no autoscale. + ARG_POINT_LINE_SWITCHER_STYLE, //%13 + ARG_POINT_LINE_SWITCHER_SELECT, //%14 + ARG_POINT_LINE_SWITCHER_UPDATE_FOO, //%15 // ADD NEW ENUM BEFORE THIS COMMENT ARGS_SIZE }; @@ -43,7 +46,9 @@ enum ARGS_DATE_TIME_PAGE_INDEX { ARG_DATE_TIME_ASPECT_RATIO_HEIGHT, //%4 ARG_DATE_TIME_ASPECT_WIDTH_OR_HEIGHT, //%5 "width" if ARG_ASPECT_RATIO_WIDTH > ARG_ASPECT_RATIO_HEIGHT and "height" if not ARG_DATE_TIME_ASPECT_WIDTH_OR_HEIGHT_FOR_AUTOSCALE, //%6 if value of it is equal to ARG_ASPECT_WIDTH_OR_HEIGHT it's mean no autoscale. - + ARG_DATE_TIME_POINT_LINE_SWITCHER_STYLE, //%7 + ARG_DATE_TIME_POINT_LINE_SWITCHER_SELECT, //%8 + ARG_DATE_TIME_POINT_LINE_SWITCHER_UPDATE_FOO, //%9 // ADD NEW ENUM BEFORE THIS COMMENT ARGS_DATE_TIME_PAGE_SIZE }; @@ -114,6 +119,9 @@ extern const char kHtmlMultiChartModel[]; extern const char kHtmlCloudOfPoints[]; extern const char kHtmlSimpleDataBlock[]; +extern const char kHtmlComboboxStyleBlock[]; +extern const char kHtmlComboboxSelectBlock[]; +extern const char kHtmlComboboxUpdateFooBlock[]; //#STOP_GRAB_TO_DVS_NAMESPACE } diff --git a/plotly_maker/plotly_maker.cpp b/plotly_maker/plotly_maker.cpp index a262b73..84051bc 100644 --- a/plotly_maker/plotly_maker.cpp +++ b/plotly_maker/plotly_maker.cpp @@ -295,6 +295,9 @@ bool showLineChartInBrowser(const vector& xValues, const vector& } args[ARG_ASPECT_WIDTH_OR_HEIGHT] = paramWH; args[ARG_ASPECT_WIDTH_OR_HEIGHT_FOR_AUTOSCALE] = paramWHsecond; + args[ARG_POINT_LINE_SWITCHER_STYLE] = kHtmlComboboxStyleBlock; + args[ARG_POINT_LINE_SWITCHER_SELECT] = kHtmlComboboxSelectBlock; + args[ARG_POINT_LINE_SWITCHER_UPDATE_FOO] = kHtmlComboboxUpdateFooBlock; make_string(kHtmlModel, args, page); string pageName; mayBeCreateJsWorkingFolder();