Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spread dot line dot+line switcher #150

Merged
merged 5 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 23 additions & 11 deletions davis_one/davis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,11 @@ const char kWarningIcon[] = R"davis_delimeter(<svg xmlns="http://www.w3.org/2000
const char kHtmlDateTimeModel[] = R"davis_delimeter(
<head>
<script src="%1" charset="utf-8"></script>
%7
</head>
<body><div style = "display: flex;
<body>
%8
<div style = "display: flex;
align-items:center;height:100%; width:100%;background:#dddfd4;
justify-content: center;"><div style="%5:99%; %6:99%; aspect-ratio: %3/%4;"
id="gd"></div></div>
Expand All @@ -379,7 +382,7 @@ id="gd"></div></div>
var data = [
%2
];

%9
var config = {
editable: true,
showLink: true,
Expand All @@ -398,7 +401,7 @@ const char kHtmlMultiChartBlock[] = R"davis_delimeter(
var trace%1 = {
x: [%2],
y: [%3],
type: 'scatter',
mode: 'lines',
name: '%4'
};
)davis_delimeter";
Expand All @@ -409,8 +412,10 @@ var trace%1 = {
const char kHtmlMultiChartModel[] = R"davis_delimeter(
<head>
<script src="%1" charset="utf-8"></script>
%11
</head>
<body>
%12
<div style = "display: flex;
align-items:center;height:100%; width:100%;background:#dddfd4;
justify-content: center;"><div style="%9:99%; %10:99%; aspect-ratio: %7/%8;"
Expand All @@ -420,7 +425,7 @@ id="gd"></div></div>
%2

var data = [%3];

%13
var layout = {
title: {
text:'%4'
Expand Down Expand Up @@ -504,7 +509,7 @@ Plotly.newPlot('gd', data,layout,config);
const char kHtmlSimpleDataBlock[]= R"davis_delimeter({
x: [%1],
y: [%2],
type: 'scatter'
mode: 'lines'
})davis_delimeter";


Expand Down Expand Up @@ -547,23 +552,25 @@ const char kHtmlComboboxSelectBlock[] =R"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;
for(let i=0;i<data.length;++i){
var obj = data[i];
switch (selectedOption) {
case 'line':
trace.mode='lines';
obj.mode='lines';
break;
case 'line + point':
trace.mode='lines+markers';
obj.mode='lines+markers';
break;
case 'point':
trace.mode='markers';
obj.mode='markers';
break;
default: console.log('uknown option');
}
Plotly.newPlot('gd', data, layout, config);
}
Plotly.newPlot('gd', data);
}

document.addEventListener('DOMContentLoaded', function() {
Expand Down Expand Up @@ -1341,6 +1348,9 @@ void showDateTimeChart(const string& date_time_values,
args[ARG_DATE_TIME_VALUES_BLOCK] = data_values_block;
args[ARG_DATE_TIME_ASPECT_RATIO_WIDTH] = "1";
args[ARG_DATE_TIME_ASPECT_RATIO_HEIGHT] = "1";
args[ARG_DATE_TIME_POINT_LINE_SWITCHER_STYLE] = kHtmlComboboxStyleBlock;
args[ARG_DATE_TIME_POINT_LINE_SWITCHER_SELECT] = kHtmlComboboxSelectBlock;
args[ARG_DATE_TIME_POINT_LINE_SWITCHER_UPDATE_FOO] = kHtmlComboboxUpdateFooBlock;
/*
string paramWH;
if(configuration.chart.aspectRatioWidth > configuration.chart.aspectRatioHeight){
Expand Down Expand Up @@ -1503,7 +1513,9 @@ void showDateTimeMultichart(const std::string& date_time_values,
all_data.append(",");
}
}

args[ARG_DATE_TIME_POINT_LINE_SWITCHER_STYLE] = kHtmlComboboxStyleBlock;
args[ARG_DATE_TIME_POINT_LINE_SWITCHER_SELECT] = kHtmlComboboxSelectBlock;
args[ARG_DATE_TIME_POINT_LINE_SWITCHER_UPDATE_FOO] = kHtmlComboboxUpdateFooBlock;
args[ARG_DATE_TIME_VALUES_BLOCK] = all_data;
args[ARG_DATE_TIME_ASPECT_RATIO_WIDTH] = "1";
args[ARG_DATE_TIME_ASPECT_RATIO_HEIGHT] = "1";
Expand Down
4 changes: 3 additions & 1 deletion davis_one/davis.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ enum ARGS_MULTI_CHARTS_PAGE {
ARG_MC_DATE_TIME_ASPECT_RATIO_HEIGHT, //%8
ARG_MC_DATE_ASPECT_WIDTH_OR_HEIGHT, //%9 "width" if ARG_ASPECT_RATIO_WIDTH > ARG_ASPECT_RATIO_HEIGHT and "height" if not
ARG_MC_DATE_ASPECT_WIDTH_OR_HEIGHT_FOR_AUTOSCALE, //%10 if value of it is equal to ARG_ASPECT_WIDTH_OR_HEIGHT it's mean no autoscale.

ARG_MC_POINT_LINE_SWITCHER_STYLE, //%11
ARG_MC_TIME_POINT_LINE_SWITCHER_SELECT, //%12
ARG_MC_TIME_POINT_LINE_SWITCHER_UPDATE_FOO, //%13
// ADD NEW ENUM BEFORE THIS COMMENT
ARGS_MULTI_CHARTS_PAGE_SIZE
};
Expand Down
10 changes: 7 additions & 3 deletions gui/davis_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,7 @@ bool DavisGUI::checkDateTimeVariant(const QStringList& lines) {

for (int i = 0; i < lines.size(); ++i) {
QString test = lines[i];
test.replace("'", "");
for (int j = 0; j < jarr.size(); ++j) {
int template_time_stamp_size = jarr[j].toString().size();
QString template_time_stamp = jarr[j].toString();
Expand Down Expand Up @@ -752,6 +753,7 @@ bool DavisGUI::checkDateTimeVariant(const QStringList& lines) {


}

void DavisGUI::selectAndShowFiles() {

QStringList fileNames = QFileDialog::getOpenFileNames(this,
Expand Down Expand Up @@ -921,7 +923,6 @@ void DavisGUI::visualizeFiles(const QStringList& file_list) {
QString outX, outY;
QString trace_block = dvs::kHtmlMultiChartBlock;
if (isFileContainsSingleChart(file_list[i], outX, outY)) {
//qDebug()<<file_list[i].toLocalFile();
QFileInfo fi(file_list[i]);
all_chart_blocks.append(trace_block.arg(QString::number(i + 1), outX, outY, fi.baseName()));
all_traces_names.append(QString(trace_name).arg(i + 1));
Expand Down Expand Up @@ -958,8 +959,11 @@ void DavisGUI::visualizeFiles(const QStringList& file_list) {
.arg(QString::number(aspectW))
.arg(QString::number(aspectH))
.arg(paramWH)
.arg(paramWHsecond);
qDebug() << multichartPage;
.arg(paramWHsecond)
.arg(dvs::kHtmlComboboxStyleBlock)
.arg(dvs::kHtmlComboboxSelectBlock)
.arg(dvs::kHtmlComboboxUpdateFooBlock);

dvs::saveStringToFile(dvs::kReportPagePath, multichartPage.toStdString());
dvs::openFileBySystem(dvs::kReportPagePath);
return;
Expand Down
27 changes: 17 additions & 10 deletions plotly_maker/html_parts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,11 @@ const char kWarningIcon[] = R"davis_delimeter(<svg xmlns="http://www.w3.org/2000
const char kHtmlDateTimeModel[] = R"davis_delimeter(
<head>
<script src="%1" charset="utf-8"></script>
%7
</head>
<body><div style = "display: flex;
<body>
%8
<div style = "display: flex;
align-items:center;height:100%; width:100%;background:#dddfd4;
justify-content: center;"><div style="%5:99%; %6:99%; aspect-ratio: %3/%4;"
id="gd"></div></div>
Expand All @@ -347,7 +350,7 @@ id="gd"></div></div>
var data = [
%2
];

%9
var config = {
editable: true,
showLink: true,
Expand All @@ -366,7 +369,7 @@ const char kHtmlMultiChartBlock[] = R"davis_delimeter(
var trace%1 = {
x: [%2],
y: [%3],
type: 'scatter',
mode: 'lines',
name: '%4'
};
)davis_delimeter";
Expand All @@ -377,8 +380,10 @@ var trace%1 = {
const char kHtmlMultiChartModel[] = R"davis_delimeter(
<head>
<script src="%1" charset="utf-8"></script>
%11
</head>
<body>
%12
<div style = "display: flex;
align-items:center;height:100%; width:100%;background:#dddfd4;
justify-content: center;"><div style="%9:99%; %10:99%; aspect-ratio: %7/%8;"
Expand All @@ -388,7 +393,7 @@ id="gd"></div></div>
%2

var data = [%3];

%13
var layout = {
title: {
text:'%4'
Expand Down Expand Up @@ -472,7 +477,7 @@ Plotly.newPlot('gd', data,layout,config);
const char kHtmlSimpleDataBlock[]= R"davis_delimeter({
x: [%1],
y: [%2],
type: 'scatter'
mode: 'lines'
})davis_delimeter";


Expand Down Expand Up @@ -515,23 +520,25 @@ const char kHtmlComboboxSelectBlock[] =R"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;
for(let i=0;i<data.length;++i){
var obj = data[i];
switch (selectedOption) {
case 'line':
trace.mode='lines';
obj.mode='lines';
break;
case 'line + point':
trace.mode='lines+markers';
obj.mode='lines+markers';
break;
case 'point':
trace.mode='markers';
obj.mode='markers';
break;
default: console.log('uknown option');
}
Plotly.newPlot('gd', data, layout, config);
}
Plotly.newPlot('gd', data);
}

document.addEventListener('DOMContentLoaded', function() {
Expand Down
4 changes: 3 additions & 1 deletion plotly_maker/html_parts.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ enum ARGS_MULTI_CHARTS_PAGE {
ARG_MC_DATE_TIME_ASPECT_RATIO_HEIGHT, //%8
ARG_MC_DATE_ASPECT_WIDTH_OR_HEIGHT, //%9 "width" if ARG_ASPECT_RATIO_WIDTH > ARG_ASPECT_RATIO_HEIGHT and "height" if not
ARG_MC_DATE_ASPECT_WIDTH_OR_HEIGHT_FOR_AUTOSCALE, //%10 if value of it is equal to ARG_ASPECT_WIDTH_OR_HEIGHT it's mean no autoscale.

ARG_MC_POINT_LINE_SWITCHER_STYLE, //%11
ARG_MC_TIME_POINT_LINE_SWITCHER_SELECT, //%12
ARG_MC_TIME_POINT_LINE_SWITCHER_UPDATE_FOO, //%13
// ADD NEW ENUM BEFORE THIS COMMENT
ARGS_MULTI_CHARTS_PAGE_SIZE
};
Expand Down
7 changes: 6 additions & 1 deletion plotly_maker/plotly_maker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,9 @@ void showDateTimeChart(const string& date_time_values,
args[ARG_DATE_TIME_VALUES_BLOCK] = data_values_block;
args[ARG_DATE_TIME_ASPECT_RATIO_WIDTH] = "1";
args[ARG_DATE_TIME_ASPECT_RATIO_HEIGHT] = "1";
args[ARG_DATE_TIME_POINT_LINE_SWITCHER_STYLE] = kHtmlComboboxStyleBlock;
args[ARG_DATE_TIME_POINT_LINE_SWITCHER_SELECT] = kHtmlComboboxSelectBlock;
args[ARG_DATE_TIME_POINT_LINE_SWITCHER_UPDATE_FOO] = kHtmlComboboxUpdateFooBlock;
/*
string paramWH;
if(configuration.chart.aspectRatioWidth > configuration.chart.aspectRatioHeight){
Expand Down Expand Up @@ -587,7 +590,9 @@ void showDateTimeMultichart(const std::string& date_time_values,
all_data.append(",");
}
}

args[ARG_DATE_TIME_POINT_LINE_SWITCHER_STYLE] = kHtmlComboboxStyleBlock;
args[ARG_DATE_TIME_POINT_LINE_SWITCHER_SELECT] = kHtmlComboboxSelectBlock;
args[ARG_DATE_TIME_POINT_LINE_SWITCHER_UPDATE_FOO] = kHtmlComboboxUpdateFooBlock;
args[ARG_DATE_TIME_VALUES_BLOCK] = all_data;
args[ARG_DATE_TIME_ASPECT_RATIO_WIDTH] = "1";
args[ARG_DATE_TIME_ASPECT_RATIO_HEIGHT] = "1";
Expand Down
Loading