- 💡 About
- 🔍 Examples
- 💻 Usage
- ⚒️ Setup
- ❓ FAQ
- 🚀 Room for Improvement
- ⭐ Used By
- 🐝 Authors
- 📞 Contacts
- 📝 Licence
DAVIS (Data Visualisation tool) is utility for data visualization. The visualization is based on Plotly javascript So DAVIS generate html page with injected data from code and after that launch browser to show it.
One of the main tasks we solve is to make it easier to debug your application. With Davis you can easy visualize your one- and two-dimensional data variables.
Davis is easy-to-use tool:
- one .h file, one .cpp file, one .js file
- only native c++11 functions, zero external dependences
- simple short syntaxis for minimize code you need to write
Example 1
#include "davis.h"
// vals - is user's 2d array
int rows = 20;
int cols = 20;
int** vals = new int* [rows];
for (int i = 0; i < rows; ++i) {
vals[i] = new int[cols];
for (int j = 0; j < cols; ++j) {
vals[i][j] = i * cols + j;
}
}
dv::show(vals, rows, cols); // pass varible and dimensions of 2d array
Example 2
#include "davis.h"
//it possible and std::list<std::vector<double>> values = ...
// std::vector<std::list<double>> values = ...
std::vector<std::vector<double>> values = {{30.3, 40, 98, 76}
, {99, 45, 20, 1}
, {5, 56, 93, 25}
, {45, 23, 90, 2}};
auto config = dv::Config();
config.typeVisual = dv::VISUALTYPE_SURFACE; // select surface visual mode
config.surf.colorSc = dv::COLORSCALE_THERMAL; // change colorscale
bool result = dv::show(values, "testSurfacePage", config); // pass 2d data, html page name, configuration structure
Example 3
#include "davis.h"
int vals[] = {2, 6, 4, -34, 56, 33, 2, 15};
auto config = dv::Config();
config.heatmap.title = "Custom title"; // change default settings to custom for heatmap
config.heatmap.xLabel = "Custom xLabel"; // change default settings to custom for heatmap
config.heatmap.yLabel = "Custom yLabel"; // change default settings to custom for heatmap
bool result = dv::show(vals, sizeof(vals) / sizeof(vals[0]), "htmlPageName", config);
All user's functions, structs, etc. are placed in dv::
namespace.
Show(...) function
There is one template overload function for visualization different types of data:
template <typename T>
dv::show(...)
First arguments of dv::show(...)
could be either pointer to array:
Arguments | Description |
---|---|
T** data, uint64_t arrRows, uint64_t arrCols |
2d array with arrRows × arrCols size. Data placed inside array of arrays |
const T* data, uint64_t arrRows, uint64_t arrCols |
2d array with arrRows × arrCols size. Data placed inside pseudo 2d array (element access [i*arrCols + j]) |
const T* data, uint64_t count |
1d array. Data placed inside array |
or container:
Arguments | Description |
---|---|
C const& container_of_containers |
2d array. Data placed inside container of containers. Containers can be std::vector , std::list , std::array , etc. Content of containers must be convertable to double |
C const& container |
1d array. Data placed inside container. Сontainer requirements are the same |
Two last arguments of dv::show(...)
are also the same: const std::string& htmlPageName
and const dv::Config& configuration
. Theese arguments have default values.
htmlPageName
- name of html page will be generatedconfiguration
- configuration structure with custom settings
using std::vector;
using std::string;
//! 2-dimensional array
template <typename T>
bool show(T** data, uint64_t arrRows, uint64_t arrCols,
const string& htmlPageName = dvs::kAppName, const Config& configuration = Config());
//! 1-dimensional array that simulates a 2-dimensional one (element access [i*cols+j])
template <typename T>
bool show(const T* data, uint64_t arrRows, uint64_t arrCols,
const string& htmlPageName = dvs::kAppName, const Config& configuration = Config());
//! 1-dimensional array
template <typename T>
bool show(const T* data, uint64_t count, const string& htmlPageName = dvs::kAppName, const Config& configuration = Config());
//! 1-dimensional container
template<typename C,
typename T = std::decay_t<decltype(*begin(std::declval<C>()))>,
typename = std::enable_if_t<std::is_convertible_v<T, double>> >
bool show(C const& container, const string& htmlPageName = dvs::kAppName, const Config& configuration = Config());
//! 2-dimensional container
template<typename C,
typename T = std::decay_t<decltype(*begin(std::declval<C>()))>,
typename E = std::decay_t<decltype(*begin(std::declval<T>()))>,
typename = std::enable_if_t<std::is_convertible_v<E, double>> >
bool show(C const& container_of_containers, const string& htmlPageName = dvs::kAppName, const Config& configuration = Config());
Configuration structure
Data vizuailisation can be tunned with using custom configuration dv::Config
.
Configuration storred 3 structures and 1 enumeration.
-
Create
dv::Config
object; -
Change it's type (or not, so it will be
VISUALTYPE_AUTO
)
enum config_visualizationTypes {
VISUALTYPE_AUTO, //if user not forces some specific type it will be recognized by context
VISUALTYPE_CHART,
VISUALTYPE_HEATMAP,
VISUALTYPE_SURFACE
};
- Change fields of neaded visualisation type
Name of structure | Description |
---|---|
chart | for chart settings |
heatmap | for heatmap settings |
surf | for surface settings |
Settings fields can be
title
- title at top of imagexLabel
- title of X axisyLabel
- title of Y axiszLabel
- title of Z axiscolorScale
- type of colorscale from enumconfig_colorscales
- Pass it to
dv::show(...)
;
- Download davis.cpp, davis.h and plotly-2.27.0.min.js from our last release
- Put them in one folder in your project
- Include davis.h to your project
- Now you can use Davis functionality
Check you building folder, find folder davis_htmls and check if plotly-2.27.0.min.js exists.
If it not exists copy this file manualy to this place.
And create bug issue :)
All our test are made for plotly .js file which is placed at our last release
But probably newer version will also work. So download newer .js file at plotly page, rename it to plotly-2.27.0.min.js and test by yorself.
Containers must support implementation of begin()
and end()
methods. Content of containers must be convertable to double
Our next steps will involve:
- template functions for saving arrays like text files with separators
- compiling Davis to exe-file which provide command line interface for visualisation text files or copypasted data
- adding some evaluated statistic information abou data to generated html page
This project is used by the following companies:
- A. N. Sevchenko Institute of Applied Physical Problems of Belarusian State University
AntonMrt, ValeryStk
You are welcome to our team!
For any questions please contact
[email protected]
License is MIT
Copyright 2024 Anton Martinov & Valery Stanchyk
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.