Plotly.cpp 0.1.0
A C++ plotting library for expressive, interactive, real-time & streaming data visualization
Loading...
Searching...
No Matches
plotly.hpp
Go to the documentation of this file.
1#ifndef PLOTLY_PLOTLY_HPP
2#define PLOTLY_PLOTLY_HPP
3
13
14#include "plotly/abi_macros.hpp"
15
16#include <filesystem>
17#include <memory>
18#include <nlohmann/json.hpp>
19
24namespace plotly {
25
26using Object = nlohmann::json;
27using Array = std::vector<Object>;
28
49private:
50 class Impl;
51 std::unique_ptr<Impl> _pimpl;
52
53public:
57 Figure(const std::filesystem::path &webappPath =
58 std::filesystem::path(PLOTLY_CPP_WEBAPP_PATH));
59
61 Figure(const Figure &) = delete;
63 auto operator=(const Figure &) -> Figure & = delete;
66
72 auto openBrowser(bool headless = false) -> bool;
73
78 [[nodiscard]] auto isOpen() const -> bool;
79
85 void waitClose() const;
86
94 auto downloadImage(const Object &opts = Object()) -> bool;
95
105 auto newPlot(const Object &data, const Object &layout = Object(),
106 const Object &config = Object()) -> bool;
107
117 auto update(const Object &traceUpdate, const Object &layoutUpdate = Object())
118 -> bool;
119
128 auto relayout(const Object &layout = Object()) -> bool;
129
136 auto redraw() -> bool;
137
144 auto purge() -> bool;
145
154 auto restyle(const Object &aobj, const Object &traces = Object()) -> bool;
155
164 auto addTraces(const Object &traces, const Object &newIndices = Object())
165 -> bool;
166
174 auto deleteTraces(const Object &indices) -> bool;
175
184 auto moveTraces(const Object &currentIndices, const Object &newIndices)
185 -> bool;
186
196 auto extendTraces(const Object &update, const Object &indices,
197 const Object &maxPoints = Object()) -> bool;
198
207 auto prependTraces(const Object &update, const Object &indices) -> bool;
208
218 auto react(const Object &data, const Object &layout = Object(),
219 const Object &config = Object()) -> bool;
220
228 auto addFrames(const Object &frames) -> bool;
229
237 auto deleteFrames(const Object &frames) -> bool;
238
247 auto animate(const Object &frameOrGroupNameOrFrameList,
248 const Object &opts = Object()) -> bool;
249
259 auto on(const std::string &event,
260 const std::function<void(plotly::Object)> &callback) -> bool;
261
268 auto removeAllListeners(const std::string &event) -> bool;
269
280 auto setDownloadDirectory(const std::filesystem::path &directory,
281 int remoteDebuggingPort = 9222) -> bool;
282};
283
284} // namespace plotly
285
286#endif // PLOTLY_PLOTLY_HPP
Application Binary Interface compatibility macros for plotly.cpp.
#define PLOTLY_EXPORT
Definition abi_macros.hpp:19
Definition plotly.cpp:40
auto restyle(const Object &aobj, const Object &traces=Object()) -> bool
Restyle existing traces.
Definition plotly.cpp:430
void waitClose() const
Wait until the figure is closed (no client connected).
Definition plotly.cpp:406
auto relayout(const Object &layout=Object()) -> bool
Apply layout-only changes to the plot.
Definition plotly.cpp:422
auto isOpen() const -> bool
Check whether the figure is currently open.
Definition plotly.cpp:404
auto moveTraces(const Object &currentIndices, const Object &newIndices) -> bool
Move traces to new positions.
Definition plotly.cpp:442
auto downloadImage(const Object &opts=Object()) -> bool
Download the figure as an image.
Definition plotly.cpp:413
auto addTraces(const Object &traces, const Object &newIndices=Object()) -> bool
Add new traces to the plot.
Definition plotly.cpp:434
~Figure()
Destructor.
auto addFrames(const Object &frames) -> bool
Add animation frames to the plot.
Definition plotly.cpp:462
auto on(const std::string &event, const std::function< void(plotly::Object)> &callback) -> bool
Register a listener for a Plotly event.
Definition plotly.cpp:475
auto animate(const Object &frameOrGroupNameOrFrameList, const Object &opts=Object()) -> bool
Animate the plot.
Definition plotly.cpp:470
auto update(const Object &traceUpdate, const Object &layoutUpdate=Object()) -> bool
Update an existing plot.
Definition plotly.cpp:417
auto purge() -> bool
Purge the plot, removing all data and layout.
Definition plotly.cpp:428
Figure(const std::filesystem::path &webappPath=std::filesystem::path(PLOTLY_CPP_WEBAPP_PATH))
Construct a new Figure instance.
Definition plotly.cpp:399
auto newPlot(const Object &data, const Object &layout=Object(), const Object &config=Object()) -> bool
Create and render a new plot.
Definition plotly.cpp:408
auto operator=(const Figure &) -> Figure &=delete
Copy assignment is disabled.
Figure(const Figure &)=delete
Copy construction is disabled.
auto prependTraces(const Object &update, const Object &indices) -> bool
Prepend data to existing traces.
Definition plotly.cpp:452
auto setDownloadDirectory(const std::filesystem::path &directory, int remoteDebuggingPort=9222) -> bool
Set the download directory for the browser.
Definition plotly.cpp:533
auto openBrowser(bool headless=false) -> bool
Open the figure in the browser.
Definition plotly.cpp:529
auto deleteTraces(const Object &indices) -> bool
Delete traces from the plot.
Definition plotly.cpp:438
auto react(const Object &data, const Object &layout=Object(), const Object &config=Object()) -> bool
React-style update of the plot.
Definition plotly.cpp:457
auto extendTraces(const Object &update, const Object &indices, const Object &maxPoints=Object()) -> bool
Extend existing traces with new data.
Definition plotly.cpp:447
auto removeAllListeners(const std::string &event) -> bool
Remove all listeners for a specific Plotly event.
Definition plotly.cpp:511
auto redraw() -> bool
Redraw the plot.
Definition plotly.cpp:426
auto deleteFrames(const Object &frames) -> bool
Delete animation frames from the plot.
Definition plotly.cpp:466
C++ bindings for Plotly.
Definition logger.hpp:7
std::vector< Object > Array
Definition plotly.hpp:27
nlohmann::json Object
Definition plotly.hpp:26