def create_chart(self, data: List[float] = None, labels: List[str] = None) -> None: """ Creates task chart window using base data :return: None """ # c. if data is not None: self.data = data if labels is not None: self.labels = labels c.add_plot( self.plot_label, no_mouse_pos=True, xaxis_no_gridlines=True, xaxis_no_tick_marks=True, xaxis_no_tick_labels=True, yaxis_no_gridlines=True, yaxis_no_tick_marks=True, yaxis_no_tick_labels=True, width=300, height=300, ) c.add_same_line() c.set_plot_xlimits(self.plot_label, 0, 1) c.set_plot_ylimits(self.plot_label, 0, 1)
def create_component(self): """ Creates window with structure for component. Used when combining with multiple components before running c.start_dearpygui() """ with s.window( "Example Component", width=485, height=335, x_pos=0, y_pos=0, ): self._create_menu() c.add_table( self._table_name, headers=self.labels, width=200, ) c.add_same_line() c.add_plot( self._plot_name, width=200, height=200, no_legend=True, ) self.update_data()
def generate_chart(self, data, labels): if data is not None: self.data = data if labels is not None: self.labels = labels core.add_plot(self.plot_label, width=500, height=500) self.draw_chart(data, labels)
def __init__(self): with simple.window(self.windowName, width=self.xSize, height=self.ySize, x_pos=self.xPos, y_pos=self.yPos): core.add_separator() core.add_plot(self.plotName) super().__init__()
def display_history_graph(self, historyDict, numberOfEpochs): with simple.window(self.learningGraph, width=300, height=300): core.add_separator() core.add_plot(self.historyPlotName) xAxis = range(0, numberOfEpochs) core.add_line_series(self.historyPlotName, "Dokładnosc", xAxis, historyDict['accuracy']) core.add_line_series(self.historyPlotName, "Strata", xAxis, historyDict['loss'])
def __init__(self): with simple.window(self.windowName, width=self.xSize, height=self.ySize, x_pos=self.xPos, y_pos=self.yPos): core.add_button(self.importButtonName, callback=self.open_file_dialog) core.add_label_text(name=self.fileStatus, label='##' + self.fileMissing, default_value=self.fileMissing) core.add_separator() core.add_same_line() core.add_plot(self.plotName) super().__init__()
def init_ui(self): """Initialize the container's UI""" # the monitor profile is in a tab with dpg_simple.tab(self._tab_id, parent=self.parent, no_tooltip=True): # Create 2 groups and put them on the same line with dpg_simple.group(self._left_panel_id, parent=self._tab_id): # The grid input dpg_core.add_input_int2( self._input_id, parent=self._left_panel_id, callback=self.input_callback, default_value=[1, 1], ) # snap button dpg_core.add_button(self._snap_id, parent=self._left_panel_id, callback=self.snap) # Customize grid with the plot dpg_core.add_plot( self._plot_id, parent=self._left_panel_id, height=-1, xaxis_lock_min=True, xaxis_lock_max=True, y2axis_lock_min=True, y2axis_lock_max=True, yaxis_no_tick_marks=True, yaxis_no_tick_labels=True, xaxis_no_tick_marks=True, xaxis_no_tick_labels=True, xaxis_no_gridlines=True, yaxis_no_gridlines=True, ) # Ensure the plot's limits are the work area dpg_core.set_plot_xlimits(self._plot_id, xmin=self.monitor.work.left, xmax=self.monitor.work.right) dpg_core.set_plot_ylimits(self._plot_id, ymin=self.monitor.work.top, ymax=self.monitor.work.bottom) # Put the application table on the right dpg_core.add_same_line(parent=self._tab_id) with dpg_simple.group(self._right_panel_id, parent=self._tab_id): self._app_table = AppTable(parent=self._right_panel_id)
def make_plot(): date_data_since = date - datetime.timedelta(30) scatter_plot_weekly_data = yfs.get_data(ticker, start_date=date_data_since, interval="1d") indecis = [x for x in scatter_plot_weekly_data.index] start_date = indecis[0] x_axis = [(x - start_date).days for x in indecis] y_axis_max = [scatter_plot_weekly_data.loc[x]['high'] for x in indecis] y_axis_min = [scatter_plot_weekly_data.loc[x]['low'] for x in indecis] gg.add_plot("30 Day Price Fluctuation", height=300, scale_max=.5, x_axis_name=f"Days since {start_date}", y_axis_name="Single share price") gg.add_scatter_series("30 Day Price Fluctuation", "Day High", x=x_axis, y=y_axis_max, size=3) gg.add_scatter_series("30 Day Price Fluctuation", "Day Low", x=x_axis, y=y_axis_min, marker=1, size=3) # Set initial plot view gg.set_plot_xlimits("30 Day Price Fluctuation", 0, 30) gg.set_plot_ylimits("30 Day Price Fluctuation", min(y_axis_min)*.97, max(y_axis_max)*1.03) gg.set_plot_ylimits_auto("30 Day Price Fluctuation") gg.set_plot_xlimits_auto("30 Day Price Fluctuation")
def generate_chart(self, data, labels): if data is not None: self.data = data if labels is not None: self.labels = labels core.add_plot( self.plot_label, no_mouse_pos=True, xaxis_no_gridlines=True, xaxis_no_tick_marks=True, xaxis_no_tick_labels=True, yaxis_no_gridlines=True, yaxis_no_tick_marks=True, yaxis_no_tick_labels=True, width=500, height=500, ) core.set_plot_xlimits(self.plot_label, 0, 1) core.set_plot_ylimits(self.plot_label, 0, 1) self.draw_chart(data, labels)
def create_model(sender, data): predict, original = model.create_model(model_company) print(predict.index) print(predict[0]) print(type(predict.index)) print(type(predict[0])) core.add_line_series("Pred", "Prediction", predict.index.tolist(), predict[0].tolist(), color=[255, 50, 50, 100]) with simple.window("Stock", width=650, height=300, x_pos=10, y_pos=110): core.add_plot("Plot", height=-1) with simple.window("Market Cap", width=650, height=300, x_pos=10, y_pos=415): core.add_plot("Cap", height=-1) with simple.window("Select Company", height=90, x_pos=10, y_pos=5): with simple.menu("Companies##plot"): for file in os.listdir("dataset"): filename = os.fsdecode(file) if filename.endswith(".csv"): core.add_menu_item(filename.split('_')[0] + "##plot", callback_data=filename, callback=plot_callback) with simple.menu("Cap Interval"): core.add_menu_item("Daily",
def construct(self): with simple.group(self.name, parent=self.parent): # GUI elements for the algorithm selection ######################## core.add_group("algorithm_input##labels", horizontal=True, horizontal_spacing=90) core.add_text("Available algorithms") core.add_text("Selected algorithms") core.end() # algorithm_input##labels core.add_group("algorithm_input#lists", horizontal=True, horizontal_spacing=0) core.add_listbox( "algorithm_selector##available", label="", items=self.available_algorithms, width=220, ) core.add_listbox( "algorithm_selector##selected", label="", items=self.selected_algorithms, width=220, ) core.end() # algorithm_input##lists def move(src, dest, gui_element): if len(src): current = core.get_value(gui_element) item = src.pop(current) dest.append(item) self.update_listbox() def move_all(src, dest): for i in src: dest.append(i) src.clear() self.update_listbox() def add(sender): move( self.available_algorithms, self.selected_algorithms, "algorithm_selector##available", ) def add_all(sender): move_all(self.available_algorithms, self.selected_algorithms) def remove(sender): move( self.selected_algorithms, self.available_algorithms, "algorithm_selector##selected", ) def remove_all(sender): move_all(self.selected_algorithms, self.available_algorithms) core.add_group("algorithm_input##buttons", horizontal=True) core.add_button("Add", width=107, callback=add) core.add_button("Add all", width=107, callback=add_all) core.add_button("Remove", width=107, callback=remove) core.add_button("Remove all", width=107, callback=remove_all) core.end() # algorithm_input##buttons core.add_button( "Execute", callback=self.execute_algorithms, callback_data=self.selected_algorithms, ) # GUI elements for the metrics display ################################ core.add_radio_button("metrics", items=["Elapsed times", "Expanded nodes"], callback=self.handle_metric, horizontal=True) core.add_plot("Metrics plot") core.add_bar_series("Metrics plot", "Metrics", [], []) core.set_plot_xlimits("Metrics plot", 0, 6)
def _setup_add_widget(self, dpg_args) -> None: dpgcore.add_plot(self.id, **dpg_args)
def show_demo(): _create_static_textures() _create_dynamic_textures() with cxt.collapsing_header(label="Textures & Images"): with cxt.tree_node(label="Help"): dpg.add_separator() dpg.add_text("ABOUT TEXTURES:") dpg.add_text("Textures are buffers of RGBA data.", bullet=True, indent=20) dpg.add_text("Textures are used by 'image based' widgets:", bullet=True, indent=20) dpg.add_text("add_image", bullet=True, indent=50) dpg.add_text("add_image_button", bullet=True, indent=50) dpg.add_text("draw_image", bullet=True, indent=50) dpg.add_text("add_image_series", bullet=True, indent=50) dpg.add_text("Textures are themselves widgets.", bullet=True, indent=20) dpg.add_text( "Textures must be a child of a texture container widget.", bullet=True, indent=20) dpg.add_text( "Textures can be either static or dynamic (see following sections).", bullet=True, indent=20) dpg.add_separator() dpg.add_text("PROGRAMMER GUIDE:") dpg.add_text( "'image based' widgets hold a reference to a texture widget.", bullet=True, indent=20) dpg.add_text( "Deleting the texture widget will not affect widget's using it.", bullet=True, indent=50) dpg.add_text( "Textures are only free'd from the GPU when the reference count reaches 0.", bullet=True, indent=50) dpg.add_text( "The texture container widget is a root (has no parent).", bullet=True, indent=20) dpg.add_text("The texture container widget is hidden by default.", bullet=True, indent=20) dpg.add_text( "'Showing' it, opens a manager to inspect the textures within.", bullet=True, indent=50) dpg.add_same_line() dpg.add_button(label="Press Here", small=True, callback=lambda: dpg.configure_item( demo_texture_container, show=True)) dpg.add_separator() with cxt.tree_node(label="Static Textures"): dpg.add_separator() dpg.add_text("ABOUT STATIC TEXTURES:") dpg.add_text("Can NOT be modified after creation.", bullet=True, indent=20) dpg.add_text("Can be loaded from a file using the 'file' keyword.", bullet=True, indent=20) dpg.add_separator() with cxt.group(horizontal=True): with cxt.group(): dpg.add_text("Image Button") dpg.add_image_button(demo_static_texture_1) with cxt.group(): dpg.add_text("Image") dpg.add_image(demo_static_texture_2) with cxt.group(): dpg.add_text("Image (texture size)") dpg.add_image(demo_static_texture_3) with cxt.group(): dpg.add_text("Image (2x texture size)") dpg.add_image(demo_static_texture_3, width=200, height=200) dpg.add_image("INTERNAL_DPG_FONT_ATLAS") with cxt.tree_node(label="Dynamic Textures"): dpg.add_separator() dpg.add_text("ABOUT DYNAMIC TEXTURES:") dpg.add_text("Can be modified after creation with 'set_value'.", bullet=True, indent=20) dpg.add_text( "New data must be the same dimensions as the original", bullet=True, indent=20) dpg.add_separator() with cxt.group(): dpg.add_color_picker(label="Texture 1", default_value=(255, 0, 255, 255), no_side_preview=True, alpha_bar=True, width=200, callback=_update_dynamic_textures, callback_data=1) dpg.add_text("Image Button") dpg.add_image_button(demo_dynamic_texture_1, width=100, height=100) dpg.add_same_line() with cxt.group(): dpg.add_color_picker(label="Texture 2", default_value=(255, 255, 0, 255), no_side_preview=True, alpha_bar=True, width=200, callback=_update_dynamic_textures, callback_data=2) dpg.add_text("Image") dpg.add_image(demo_dynamic_texture_2) with cxt.tree_node(label="Image Series (plots)"): plot_id = dpg.add_plot(label="Image Plot", height=400) dpg.add_image_series("INTERNAL_DPG_FONT_ATLAS", [300, 300], [400, 400], label="font atlas", parent=plot_id) dpg.add_image_series(demo_static_texture_1, [0, 0], [100, 100], label="static 1", parent=plot_id) dpg.add_image_series(demo_static_texture_2, [150, 150], [200, 200], label="static 2", parent=plot_id) dpg.add_image_series(demo_static_texture_3, [200, -150], [300, -50], label="static 3", parent=plot_id) dpg.add_image_series(demo_dynamic_texture_1, [-200, 100], [-100, 200], label="dynamic 1", parent=plot_id) dpg.add_image_series(demo_dynamic_texture_2, [-200, -100], [-150, -50], label="dynamic 2", parent=plot_id) with cxt.tree_node(label="Drawlists"): with cxt.drawlist(width=400, height=300): dpg.draw_rectangle((0, 0), (400, 300), color=(100, 100, 100, 250), thickness=2) dpg.draw_image(demo_static_texture_3, [0, 0], [100, 100]) dpg.draw_image(demo_dynamic_texture_1, [200, 100], [300, 200])