def __init__(self, parent=None): super().__init__() self.reader = FsaReader() self.treewidget = QTreeWidget() self.channel_view = qtc.QChartView() self.regression_view = qtc.QChartView() # setup tree self.treewidget.setColumnCount(2) self.treewidget.setHeaderLabels(["Rox size", "predicted"]) self.channel_view.setChart(qtc.QChart()) self.regression_view.setChart(qtc.QChart()) self.channel_serie = qtc.QLineSeries() self.regression_serie = qtc.QScatterSeries() self.buttons = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.channel_view.setChart(qtc.QChart()) self.regression_view.setChart(qtc.QChart()) v_splitter = QSplitter(Qt.Vertical) v_splitter.addWidget(self.regression_view) v_splitter.addWidget(self.channel_view) h_splitter = QSplitter(Qt.Horizontal) h_splitter.addWidget(self.treewidget) h_splitter.addWidget(v_splitter) v_layout = QVBoxLayout() v_layout.addWidget(h_splitter) v_layout.addWidget(self.buttons) self.setLayout(v_layout)
def __init__(self): super().__init__() self.setFixedSize(800, 400) self.setWindowTitle("Deck statistics") layout = QGridLayout() # graphs self.chartPieView = QtCharts.QChartView() self.chartPieView.setRenderHint(QPainter.Antialiasing) self.chartBarView = QtCharts.QChartView() # init layout.addWidget(self.chartPieView, 0, 0) layout.addWidget(self.chartBarView, 0, 1) self.setLayout(layout)
def generateUnitCharts(self): self.alliedAircraft = [d.allied_units.aircraft_count for d in self.game.game_stats.data_per_turn] self.enemyAircraft = [d.enemy_units.aircraft_count for d in self.game.game_stats.data_per_turn] self.alliedAircraftSerie = QtCharts.QLineSeries() self.alliedAircraftSerie.setName("Allied aircraft count") for a, i in enumerate(self.alliedAircraft): self.alliedAircraftSerie.append(QPoint(a, i)) self.enemyAircraftSerie = QtCharts.QLineSeries() self.enemyAircraftSerie.setColor(Qt.red) self.enemyAircraftSerie.setName("Enemy aircraft count") for a, i in enumerate(self.enemyAircraft): self.enemyAircraftSerie.append(QPoint(a, i)) self.chart = QtCharts.QChart() self.chart.addSeries(self.alliedAircraftSerie) self.chart.addSeries(self.enemyAircraftSerie) self.chart.setTitle("Aircraft forces over time") self.chart.createDefaultAxes() self.chart.axisX().setRange(0, len(self.alliedAircraft)) self.chart.axisY().setRange(0, max(max(self.alliedAircraft), max(self.enemyAircraft)) + 10) self.chartView = QtCharts.QChartView(self.chart) self.chartView.setRenderHint(QPainter.Antialiasing) self.layout.addWidget(self.chartView, 0, 0)
def __init__(self): super().__init__() self.items = 0 # Example data self._data = {"Water": 24.5, "Electricity": 55.1, "Rent": 850.0, "Supermarket": 230.4, "Internet": 29.99, "Bars": 21.85, "Public transportation": 60.0, "Coffee": 22.45, "Restaurants": 120} # Left self.table = QTableWidget() self.table.setColumnCount(2) self.table.setHorizontalHeaderLabels(['Description', 'Price']) self.table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch) # Chart self.chart_view = QtCharts.QChartView() self.chart_view.setRenderHint(QPainter.Antialiasing) # Right self.description = QLineEdit() self.price = QLineEdit() self.btn_add = QPushButton('Add') self.btn_clear = QPushButton('Clear') self.btn_quit = QPushButton('Quit') self.btn_plot = QPushButton('Plot') # Disabling 'Add' button self.btn_add.setEnabled(False) self.side_right = QVBoxLayout() self.side_right.setMargin(10) self.side_right.addWidget(QLabel('Description')) self.side_right.addWidget(self.description) self.side_right.addWidget(QLabel('Price')) self.side_right.addWidget(self.price) self.side_right.addWidget(self.btn_add) self.side_right.addWidget(self.btn_plot) self.side_right.addWidget(self.chart_view) self.side_right.addWidget(self.btn_clear) self.side_right.addWidget(self.btn_quit) # Widget Layout self.layout = QHBoxLayout() self.layout.addWidget(self.table) self.layout.addLayout(self.side_right) # Set Layout to Widget self.setLayout(self.layout) # Signals self.btn_add.clicked.connect(self.add_element) self.btn_quit.clicked.connect(self.close_application) self.btn_clear.clicked.connect(self.clear_table) self.btn_plot.clicked.connect(self.plot_data) self.description.textChanged[str].connect(self.check_disable) self.price.textChanged[str].connect(self.check_disable) self.fill_table()
def get_performace_chart(): # Graph is based on data of: # 'Total consumption of energy increased by 10 per cent in 2010' # Statistics Finland, 13 December 2011 # http://www.stat.fi/til/ekul/2010/ekul_2010_2011-12-13_tie_001_en.html series1 = QtCharts.QPieSeries() series1.setName("Business Logic") series1.append("User Input", 353295) series1.append("Card Processing", 188500) series1.append("Others", 148680) series2 = QtCharts.QPieSeries() series2.setName("Communications") series2.append("Payment ", 319663) series2.append("Reversal", 45875) series2.append("Advice", 1060) series2.append("DCC", 111060) series3 = QtCharts.QPieSeries() series3.setName("Printing") series3.append("Merchant Receipt", 238789) series3.append("Customer Receipt", 37802) donut_breakdown = DonutBreakdownChart() donut_breakdown.setAnimationOptions(QtCharts.QChart.AllAnimations) donut_breakdown.setTitle("Total Transaction time") donut_breakdown.legend().setAlignment(Qt.AlignRight) donut_breakdown.add_breakdown_series(series1, Qt.red) donut_breakdown.add_breakdown_series(series2, Qt.darkGreen) donut_breakdown.add_breakdown_series(series3, Qt.darkBlue) chart_view = QtCharts.QChartView(donut_breakdown) chart_view.setRenderHint(QPainter.Antialiasing) return chart_view
def __init__(self): QWidget.__init__(self) # Creating a QTableView self.table_view = QTableView() # QWidget Layout self.main_layout = QHBoxLayout() self.size = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) # generate the plot self.fig, self.ax = plt.subplots() self.fig.tight_layout = True self.fig.subplots_adjust(left=0.05, right=0.95, top=0.95, bottom=0.05) self.ax.margins(0, 0) self.canvas = FigureCanvas(self.fig) ## Left layout self.size.setHorizontalStretch(1) self.table_view.setSizePolicy(self.size) self.main_layout.addWidget(self.table_view) ## Right Layout self.size.setHorizontalStretch(4) self.canvas.setSizePolicy(self.size) self.main_layout.addWidget(self.canvas) # Creating QChartView self.chart_view = QtCharts.QChartView() self.chart_view.setRenderHint(QPainter.Antialiasing) # Set the layout to the QWidget self.setLayout(self.main_layout)
def __init__(self): QMainWindow.__init__(self) self.series = QtCharts.QPieSeries() self.series.append('Jane', 1) self.series.append('Joe', 2) self.series.append('Andy', 3) self.series.append('Barbara', 4) self.series.append('Axel', 5) self.slice = self.series.slices()[1] self.slice.setExploded() self.slice.setLabelVisible() self.slice.setPen(QPen(Qt.darkGreen, 2)) self.slice.setBrush(Qt.green) self.chart = QtCharts.QChart() self.chart.addSeries(self.series) self.chart.setTitle('Simple piechart example') self.chart.legend().hide() self.chartView = QtCharts.QChartView(self.chart) self.chartView.setRenderHint(QPainter.Antialiasing) self.setCentralWidget(self.chartView)
def __init__(self, parent=None): QWidget.__init__(self, parent) bar_set = QtCharts.QBarSet("ME") bar_set.setColor(QColor(231, 119, 32)) self.task_list = None self.setFont("Roboto Light") self.max_bound: datetime = datetime.datetime.now() self.setFixedSize(651, 421) self.interval = 7 self.series = QtCharts.QBarSeries() self.chart = QtCharts.QChart() self.chart.addSeries(self.series) self.chart.setFont("Roboto Light") self.chart.setTitle("Task Done") self.chart.setAnimationOptions(QtCharts.QChart.SeriesAnimations) self.axisX = QtCharts.QBarCategoryAxis() self.axisY = QtCharts.QValueAxis() self.chart.setAxisY(self.axisY, self.series) self.chart.setAxisX(self.axisX, self.series) self.chart.legend().setVisible(True) self.chart.legend().setAlignment(Qt.AlignBottom) self.chartView = QtCharts.QChartView(self.chart) self.chartView.setRenderHint(QPainter.Antialiasing) self.main_layout = QVBoxLayout(self) self.main_layout.addWidget(self.chartView) self.setLayout(self.main_layout)
def __init__(self, parent=None, f=None, *args, **kwargs): QtWidgets.QWidget.__init__(self) self.maxSize = 31 # 只存储最新的31个数据 self.maxX = 300 self.maxY = 100 self.data = [] #折线 self.splineSeries = QtCharts.QSplineSeries() #离散点 self.scatterSeries = QtCharts.QScatterSeries() self.scatterSeries.setMarkerSize(8) self.chart = QtCharts.QChart() self.chart.addSeries(self.splineSeries) self.chart.addSeries(self.scatterSeries) self.chart.legend().hide() self.chart.setTitle("实时动态曲线") self.chart.createDefaultAxes() self.chart.axisX().setRange(0, self.maxX) self.chart.axisY().setRange(0, self.maxY) self.chartView = QtCharts.QChartView(self.chart) #self.chartView.setRenderHint(QtGui.QPainter.Antialiasing) layout = QtWidgets.QHBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self.chartView) self.setLayout(layout) self.thread=None
def __init__(self): QWidget.__init__(self) self.model = CustomTableModel() self.table_view = QTableView() self.table_view.setModel(self.model) self.table_view.horizontalHeader().setSectionResizeMode( QHeaderView.Stretch) self.table_view.verticalHeader().setSectionResizeMode( QHeaderView.Stretch) self.chart = QtCharts.QChart() self.chart.setAnimationOptions(QtCharts.QChart.AllAnimations) self.series = QtCharts.QLineSeries() self.series.setName("Line 1") self.mapper = QtCharts.QVXYModelMapper(self) self.mapper.setXColumn(0) self.mapper.setYColumn(1) self.mapper.setSeries(self.series) self.mapper.setModel(self.model) self.chart.addSeries(self.series) # for storing color hex from the series seriesColorHex = "#000000" # get the color of the series and use it for showing the mapped area seriesColorHex = "{}".format(self.series.pen().color().name()) self.model.add_mapping(seriesColorHex, QRect(0, 0, 2, self.model.rowCount())) # series 2 self.series = QtCharts.QLineSeries() self.series.setName("Line 2") self.mapper = QtCharts.QVXYModelMapper(self) self.mapper.setXColumn(2) self.mapper.setYColumn(3) self.mapper.setSeries(self.series) self.mapper.setModel(self.model) self.chart.addSeries(self.series) # get the color of the series and use it for showing the mapped area seriesColorHex = "{}".format(self.series.pen().color().name()) self.model.add_mapping(seriesColorHex, QRect(2, 0, 2, self.model.rowCount())) self.chart.createDefaultAxes() self.chart_view = QtCharts.QChartView(self.chart) self.chart_view.setRenderHint(QPainter.Antialiasing) self.chart_view.setMinimumSize(640, 480) # create main layout self.main_layout = QGridLayout() self.main_layout.addWidget(self.table_view, 1, 0) self.main_layout.addWidget(self.chart_view, 1, 1) self.main_layout.setColumnStretch(1, 1) self.main_layout.setColumnStretch(0, 0) self.setLayout(self.main_layout)
def __init__(self): QMainWindow.__init__(self) self.series = QtCharts.QLineSeries() self.series.append(0, 6) self.series.append(2, 4) self.series.append(3, 8) self.series.append(7, 4) self.series.append(10, 5) self.series.append(QPointF(11, 1)) self.series.append(QPointF(13, 3)) self.series.append(QPointF(17, 6)) self.series.append(QPointF(18, 3)) self.series.append(QPointF(20, 2)) self.chart = QtCharts.QChart() self.chart.legend().hide() self.chart.addSeries(self.series) self.chart.createDefaultAxes() self.chart.setTitle("Simple line chart example") self.chartView = QtCharts.QChartView(self.chart) self.chartView.setRenderHint(QPainter.Antialiasing) self.setCentralWidget(self.chartView)
def __init__(self, parent=None): super().__init__() self.toolbar = QToolBar() self.view = qtc.QChartView() #self.view.setRenderHint(QPainter.Antialiasing) self.chart = qtc.QChart() self.reader = FsaReader() # build toolbar self.dye_menu = QMenu() self.dye_btn = QPushButton("Dye") self.dye_btn.setIcon(FIcon(0xf755)) self.dye_btn.setFlat(True) self.dye_btn.setMenu(self.dye_menu) self.toolbar.addWidget(self.dye_btn) self.toolbar.addAction(FIcon(0xf293), "rescale", self.chart.zoomReset) self.toolbar.addAction(FIcon(0xf6ec), "Zoom in", self.chart.zoomIn) self.toolbar.addAction(FIcon(0xf6eb), "Zoom out", self.chart.zoomOut) self.toolbar.addAction(FIcon(0xf01a), "configure", self._on_adjust_clicked) main_layout = QVBoxLayout() main_layout.addWidget(self.toolbar) main_layout.addWidget(self.view) self.setLayout(main_layout) # configure view self.view.setRubberBand(qtc.QChartView.RectangleRubberBand)
def __init__(self, frame): self.series = QtCharts.QLineSeries() self.series.setColor(Qt.red) self.axis_x = QtCharts.QDateTimeAxis() # Number of items to display self.axis_x.setTickCount(int(common.SETTINGS["DataCacheSize"])) self.axis_x.setFormat("hh:mm:ss:z") # Date format self.axis_x.setTitleText("Time") self.axis_y = QtCharts.QValueAxis() self.axis_y.setTitleText("Value") self.chart = QtCharts.QChart() self.chart.setTitle("") self.chart.addSeries(self.series) self.chart.addAxis(self.axis_x, QtCore.Qt.AlignBottom) self.chart.addAxis(self.axis_y, QtCore.Qt.AlignLeft) self.series.attachAxis(self.axis_x) self.series.attachAxis(self.axis_y) self.chart_view = QtCharts.QChartView(self.chart) self.layout = QVBoxLayout() self.layout.addWidget(self.chart_view) self.frame = frame self.frame.setLayout(self.layout)
def createScatterChart(data): chart = QtCharts.QChart() # chart.legend().hide() chart.setTitle("Spline chart (market shares)") series0 = QtCharts.QScatterSeries() series0.setName("height / weight") series0.setMarkerShape(QtCharts.QScatterSeries.MarkerShapeCircle) series0.setMarkerSize(5.0) #series0.append([0, 6, 6, 4]) pointsList = list( map(lambda hw: QPointF(hw[0], hw[1]), zip(data[0], data[1]))) series0.append(pointsList) chartView = QtCharts.QChartView(chart) chartView.setRenderHint(QPainter.Antialiasing) chart.addSeries(series0) chart.setTitle("Nba Players active as of 2018 height/weight") chart.createDefaultAxes() chart.setDropShadowEnabled(False) chart.axes(Qt.Vertical)[0].setTitleText("Weight") chart.axes(Qt.Horizontal)[0].setTitleText("Height") return chartView
def initUI(self): layout = QVBoxLayout() # Initialize chart chart = QtCharts.QChart() lineSeries = QtCharts.QLineSeries() # Make some random data points dataSeries = [(i + 1, randint(0, 99999)) for i in range(200)] # load data into chart: for point in dataSeries: lineSeries.append(point[0], point[1]) # Add Some Chart Options chart.addSeries(lineSeries) chart.setTitle("Random Numbers from 0-9000") chart.createDefaultAxes() # Create a container (similar to a widget) chartView = QtCharts.QChartView(chart) chartView.setRenderHint(QPainter.Antialiasing) # Some Chart Styling lineSeries.setColor(QtGui.QColor("darkgray")) chartView.chart().setBackgroundBrush(QtGui.QColor("ivory")) layout.addWidget(chartView) self.setLayout(layout)
def __init__(self, parent=None): QWidget.__init__(self, parent) self.series = QtCharts.QLineSeries() self.series.setName("Karma points") self.task_list = None self.max_bound: datetime = datetime.datetime.now() self.interval = 7 self.karma_point = 0 self.chart = QtCharts.QChart() self.chart.legend().setVisible(True) self.chart.legend().setAlignment(Qt.AlignBottom) self.chart.addSeries(self.series) self.chart.setTitle("Karma Points") self.chart.setAnimationOptions(QtCharts.QChart.SeriesAnimations) self.axisX = QtCharts.QDateTimeAxis() self.axisX.setFormat("dd MMM") self.axisX.setTickCount(self.interval) self.axisY = QtCharts.QValueAxis() self.chart.setAxisX(self.axisX, self.series) self.chart.setAxisY(self.axisY, self.series) self.chartView = QtCharts.QChartView(self.chart) self.chartView.setRenderHint(QPainter.Antialiasing) self.main_layout = QVBoxLayout(self) self.main_layout.addWidget(self.chartView) self.setLayout(self.main_layout) self.setFixedSize(651, 421)
def create_piechart(self): #Creates pie chart data. self.series = QtCharts.QPieSeries() self.series.append("DoS", 0) self.series.append("DDoS", 0) self.series.append("Benign", 0) self.series.append("SSH", 0) self.series.append("FTP", 0) #Adds slice. slice = QtCharts.QPieSlice() slice = self.series.slices()[2] slice.setExploded(True) slice.setLabelVisible(True) slice.setPen(QtGui.QPen(QtCore.Qt.darkGreen, 2)) slice.setBrush(QtCore.Qt.green) #Create chart. self.chart = QtCharts.QChart() self.chart.legend().hide() self.chart.addSeries(self.series) self.chart.createDefaultAxes() self.chart.setTitle("Attacks Pie Chart") #Adds legend. self.chart.legend().setVisible(True) self.chart.legend().setAlignment(QtCore.Qt.AlignBottom) self.chart.setBackgroundVisible(False) #Render pie chart. chartview = QtCharts.QChartView(self.chart) chartview.setRenderHint(QtGui.QPainter.Antialiasing) return chartview
def __init__(self): QWidget.__init__(self) self.setMinimumSize(800, 600) self.donuts = [] self.chart_view = QtCharts.QChartView() self.chart_view.setRenderHint(QPainter.Antialiasing) self.chart = self.chart_view.chart() self.chart.legend().setVisible(False) self.chart.setTitle("Nested donuts demo") self.chart.setAnimationOptions(QtCharts.QChart.AllAnimations) self.min_size = 0.1 self.max_size = 0.9 self.donut_count = 5 self.setup_donuts() # create main layout self.main_layout = QGridLayout(self) self.main_layout.addWidget(self.chart_view, 1, 1) self.setLayout(self.main_layout) self.update_timer = QTimer(self) self.update_timer.timeout.connect(self.update_rotation) self.update_timer.start(1250)
def __init_color_calibration_widget(self, parent=None): self.__color_calibration_widget = QGroupBox("Color Correction Options", parent) self.__color_calibration_widget.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) color_calibration_layout = QVBoxLayout(self.__color_calibration_widget) chart_widget = QWidget(self.__color_calibration_widget) chart_layout = QGridLayout(chart_widget) self.data_fit_chart = QtCharts.QChart() self.data_fit_chart_view = QtCharts.QChartView(self.data_fit_chart) self.axis_x = QtCharts.QValueAxis() self.axis_x.setTitleText("Pixel Intensity") self.axis_x.setRange(0, 1) self.data_fit_chart.addAxis(self.axis_x, Qt.AlignBottom) self.axis_y = QtCharts.QValueAxis() self.axis_y.setTitleText("Voxel Height (\u03BCm)") self.axis_y.setRange(0, 10) self.data_fit_chart.addAxis(self.axis_y, Qt.AlignLeft) chart_layout.addWidget(self.data_fit_chart_view, 0, 0, 1, 4) chart_widget.setLayout(chart_layout) buttons_widget = QWidget(self.__color_calibration_widget) buttons_layout = QHBoxLayout(buttons_widget) analyze_data_button = QPushButton("Analyze Data") analyze_data_button.clicked.connect(self.analyze_images) self.parameters_estimation_label = QLabel(f'Estimated parameters: \u03B1 = {self.dlp_color_calibrator.optimized_parameters[0]:.3f}, \u03B2 = {self.dlp_color_calibrator.optimized_parameters[1]:.3f}, \u03B3 = {self.dlp_color_calibrator.optimized_parameters[2]:.3f}', buttons_widget) buttons_layout.addWidget(analyze_data_button) buttons_layout.addWidget(self.parameters_estimation_label) buttons_widget.setLayout(buttons_layout) color_calibration_layout.addWidget(chart_widget) color_calibration_layout.addWidget(buttons_widget) self.__color_calibration_widget.setLayout(color_calibration_layout)
def __init__(self, nseries=1, series_names=None): super().__init__() if nseries < 1: raise ValueError( 'The number of serieses must be larger than zero.') self.nseries = nseries self.series_names = series_names layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) self.setLayout(layout) self.setMinimumHeight(110) self.setMinimumWidth(400) self.serieses = [QtCharts.QLineSeries() for _ in range(self.nseries)] self.chart = QtCharts.QChart() if self.series_names is None: self.chart.legend().hide() for idx, series in enumerate(self.serieses): self.chart.addSeries(series) if self.series_names is not None: series.setName(self.series_names[idx]) self.chart.createDefaultAxes() self.chart.layout().setContentsMargins(0, 0, 0, 0) # self.chart.setTheme(QChart.ChartThemeDark) self.chart.axisY().setTickCount(3) chart_view = QtCharts.QChartView(self.chart) chart_view.setRenderHint(QPainter.Antialiasing) layout.addWidget(chart_view) self.x_max = 2 self.y_pts = list()
def __init__(self, data): QWidget.__init__(self) self.model = CustomTableModel(data) self.table_view = QTableView() self.table_view.setModel(self.model) self.table_view.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch) self.table_view.verticalHeader().setSectionResizeMode(QHeaderView.Stretch) self.table_view.setMinimumSize(400, 600) self.chart = QtCharts.QChart() self.chart.setAnimationOptions(QtCharts.QChart.AllAnimations) self.init_data() self.chart.createDefaultAxes() self.chart_view = QtCharts.QChartView(self.chart) self.chart_view.setRenderHint(QPainter.Antialiasing) self.chart_view.setMinimumSize(800, 600) # create main layout self.main_layout = QGridLayout() self.main_layout.addWidget(self.table_view, 1, 0) self.main_layout.addWidget(self.chart_view, 1, 1) self.main_layout.setColumnStretch(1, 2) self.main_layout.setColumnStretch(0, 1) self.setLayout(self.main_layout)
def initUI(self): self.lineSeries = QtCharts.QLineSeries() # legend name # self.lineSeries.setName("trend") self.lineSeries.append(QtCore.QPoint(0, 0)) pen = QtGui.QPen(QtCore.Qt.red, 6, QtCore.Qt.SolidLine) self.lineSeries.setPen(pen) self.chart = QtCharts.QChart() self.chart.setAnimationOptions(QtCharts.QChart.AllAnimations) self.chart.setTitle("Airfoil contour analysis") self.chart.addSeries(self.lineSeries) self.chart.legend().setVisible(False) self.chart.legend().setAlignment(QtCore.Qt.AlignBottom) self.axisX = QtCharts.QValueAxis() self.axisY = QtCharts.QValueAxis() self.chart.setAxisX(self.axisX, self.lineSeries) self.chart.setAxisY(self.axisY, self.lineSeries) self.chartView = QtCharts.QChartView(self.chart) self.chartView.setRenderHint(QtGui.QPainter.Antialiasing) vlayout = QtWidgets.QVBoxLayout() vlayout.addWidget(self.chartView) self.setLayout(vlayout)
def createPieChart(data): chart = QtCharts.QChart() # chart.legend().hide() chart.setTitle("Pie chart (refugees as of 2017)") series = QtCharts.QPieSeries() sliceList = list( map(lambda nv: QtCharts.QPieSlice(nv[0], nv[1]), zip(data[0], data[1]))) series.append(sliceList) for s in series.slices(): s.setLabelVisible() chart = QtCharts.QChart() chart.addSeries(series) chart.setTitle("Simple piechart example") # chart.legend()->hide(); chartView = QtCharts.QChartView(chart) chartView.setRenderHint(QPainter.Antialiasing) return chartView
def __init__(self, device): super(MainWindow, self).__init__() self.series = QtCharts.QLineSeries() self.chart = QtCharts.QChart() self.chart.addSeries(self.series) self.axisX = QtCharts.QValueAxis() self.axisX.setRange(0, sampleCount) self.axisX.setLabelFormat("%g") self.axisX.setTitleText("Samples") self.axisY = QtCharts.QValueAxis() self.axisY.setRange(-1, 1) self.axisY.setTitleText("Audio level") self.chart.setAxisX(self.axisX, self.series) self.chart.setAxisY(self.axisY, self.series) self.chart.legend().hide() self.chart.setTitle("Data from the microphone ({})".format(device.deviceName())) formatAudio = QAudioFormat() formatAudio.setSampleRate(8000) formatAudio.setChannelCount(1) formatAudio.setSampleSize(8) formatAudio.setCodec("audio/pcm") formatAudio.setByteOrder(QAudioFormat.LittleEndian) formatAudio.setSampleType(QAudioFormat.UnSignedInt) self.audioInput = QAudioInput(device, formatAudio, self) self.ioDevice = self.audioInput.start() self.ioDevice.readyRead.connect(self._readyRead) self.chartView = QtCharts.QChartView(self.chart) self.setCentralWidget(self.chartView) self.buffer = [QPointF(x, 0) for x in range(sampleCount)] self.series.append(self.buffer)
def __init__(self, parent: Optional[QtWidgets.QWidget] = None, flags: Qt.WindowFlags = Qt.Widget): """Initialise a new instance of the class.""" super().__init__(parent, flags) self.chart_view = QtCharts.QChartView() self.chart_view.setRenderHint(QtGui.QPainter.Antialiasing) chart: QtCharts.QChart = self.chart_view.chart() chart.legend().setLabelColor(QtGui.QColor("#F0F0F0")) chart.setAnimationDuration(500) chart.setAnimationEasingCurve(QtCore.QEasingCurve.Linear) chart.setAnimationOptions(QtCharts.QChart.NoAnimation) chart.setBackgroundBrush(QtGui.QColor("transparent")) chart.setBackgroundRoundness(0.0) chart.setContentsMargins(-7, -7, -7, -7) chart.setMargins(QtCore.QMargins(10, 0, 10, 10)) self.chart: QtCharts.QChart = chart layout = QtWidgets.QVBoxLayout() layout.setMargin(0) layout.addWidget(self.chart_view) self.setLayout(layout) x_axis = QtCharts.QValueAxis() x_axis.setRange(-CHART_DURATION, 0.0) y_axis = QtCharts.QValueAxis() self.chart.addAxis(x_axis, QtCore.Qt.AlignBottom) self.chart.addAxis(y_axis, QtCore.Qt.AlignLeft) self._style_axes() self._largest_y_value: float = 0.0 self._smallest_y_value: float = sys.float_info.max self.__x_axis_maximum: float = 0.0
def __init__(self, parent=None): super(MainWindow, self).__init__(parent) file = QFile( os.path.abspath(os.path.dirname(sys.argv[0])) + "/dashboard.ui") file.open(QFile.ReadOnly) loader = QUiLoader(self) self.w = loader.load(file) self.setCentralWidget(self.w) self.setWindowTitle("Dashboard") self.w.SwitchOn.clicked.connect(self.StopThis) self.w.SwitchOn.setChecked(False) self.w.SwitchOn.setText("On") self.alreadyOn = False # Creating QChart self.w.label_0.setText("Speed") self.chart0 = QtCharts.QChart() #self.chart0.setAnimationOptions(QtCharts.QChart.SeriesAnimations) self.serie0 = QtCharts.QLineSeries(self.chart0) self.chart0.addSeries(self.serie0) self.chart0.createDefaultAxes() self.chart_view0 = QtCharts.QChartView(self.chart0) self.chart_view0.setRenderHint(QPainter.Antialiasing) self.w.verticalLayout_0.addWidget(self.chart_view0) # Creating QChart self.w.label_1.setText("RPM") self.chart1 = QtCharts.QChart() #self.chart1.setAnimationOptions(QtCharts.QChart.AllAnimations) self.serie1 = QtCharts.QLineSeries(self.chart1) self.chart1.addSeries(self.serie1) self.chart1.createDefaultAxes() self.chart_view1 = QtCharts.QChartView(self.chart1) self.chart_view1.setRenderHint(QPainter.Antialiasing) self.w.verticalLayout_1.addWidget(self.chart_view1) # Creating QChart self.w.label_2.setText("Throttle") self.chart2 = QtCharts.QChart() #self.chart2.setAnimationOptions(QtCharts.QChart.AllAnimations) self.serie2 = QtCharts.QLineSeries(self.chart2) self.chart2.addSeries(self.serie2) self.chart2.createDefaultAxes() self.chart_view2 = QtCharts.QChartView(self.chart2) self.chart_view2.setRenderHint(QPainter.Antialiasing) self.w.verticalLayout_2.addWidget(self.chart_view2)
def graph(self): chart = QtCharts.QChart() chart.setAnimationOptions(QtCharts.QChart.AllAnimations) chart_view = QtCharts.QChartView(chart) return chart_view
def __init__(self): QMainWindow.__init__(self) self.set0 = QtCharts.QBarSet("Jane") self.set1 = QtCharts.QBarSet("John") self.set2 = QtCharts.QBarSet("Axel") self.set3 = QtCharts.QBarSet("Mary") self.set4 = QtCharts.QBarSet("Sam") self.set0.append([1, 2, 3, 4, 5, 6]) self.set1.append([5, 0, 0, 4, 0, 7]) self.set2.append([3, 5, 8, 13, 8, 5]) self.set3.append([5, 6, 7, 3, 4, 5]) self.set4.append([9, 7, 5, 3, 1, 2]) self.barSeries = QtCharts.QBarSeries() self.barSeries.append(self.set0) self.barSeries.append(self.set1) self.barSeries.append(self.set2) self.barSeries.append(self.set3) self.barSeries.append(self.set4) self.lineSeries = QtCharts.QLineSeries() self.lineSeries.setName("trend") self.lineSeries.append(QPoint(0, 4)) self.lineSeries.append(QPoint(1, 15)) self.lineSeries.append(QPoint(2, 20)) self.lineSeries.append(QPoint(3, 4)) self.lineSeries.append(QPoint(4, 12)) self.lineSeries.append(QPoint(5, 17)) self.chart = QtCharts.QChart() self.chart.addSeries(self.barSeries) self.chart.addSeries(self.lineSeries) self.chart.setTitle("Line and barchart example") self.categories = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"] self.axisX = QtCharts.QBarCategoryAxis() self.axisX.append(self.categories) self.chart.setAxisX(self.axisX, self.lineSeries) self.chart.setAxisX(self.axisX, self.barSeries) self.axisX.setRange("Jan", "Jun") self.axisY = QtCharts.QValueAxis() self.chart.setAxisY(self.axisY, self.lineSeries) self.chart.setAxisY(self.axisY, self.barSeries) self.axisY.setRange(0, 20) self.chart.legend().setVisible(True) self.chart.legend().setAlignment(Qt.AlignBottom) self.chartView = QtCharts.QChartView(self.chart) self.chartView.setRenderHint(QPainter.Antialiasing) self.setCentralWidget(self.chartView)
def __init__(self): super(MainController, self).__init__() self.MainWindow = MainWindowClass() self.Network = NetworkConnectionClass() self.StepMotors = StepMotorControlClass() self.DCMotors = DCCMotorControlClass() self.SensorAccel = SensorAccelerationClass() self.MainTimer = QTimer self.Network.SignalFrameDataAvailable.connect(self.PerformNetworkData) self.SignalSendData.connect(self.Network.SendData) self.ChartPlot1 = LineGraphicsPlot() self.ChartPlot2 = LineGraphicsPlot() self.ChartPlot3 = LineGraphicsPlot() self.ChartPlot4 = LineGraphicsPlot() self.ChartView1 = QtCharts.QChartView(self.ChartPlot1) self.ChartView2 = QtCharts.QChartView(self.ChartPlot2) self.ChartView3 = QtCharts.QChartView(self.ChartPlot3) self.ChartView4 = QtCharts.QChartView(self.ChartPlot4) self.Group = GroupWindowModule() self.Group.addWidget(self.ChartView1) self.Group.addWidget(self.ChartView2) self.Group.addWidget(self.ChartView3) self.Group.addWidget(self.ChartView4) self.MainWindow.SetModuleWidget(-400, 590, self.Group) self.Group.show() self.MainWindow.SetModuleWidget(-400, 90, self.Network.Display) self.MainWindow.SetModuleWidget(100, 90, self.SensorAccel.Display) self.MainWindow.SetModuleWidget(390, 90, self.DCMotors.Display) self.MainWindow.SetModuleWidget(600, 90, self.StepMotors.Display) self.MainWindow.move(10, 10) self.MainWindow.show() self.MainWindow.resize(1900, 900)
def createStreamingGroup(self): self.streamingBox = QtWidgets.QGroupBox("data streams") layout = QtWidgets.QVBoxLayout() for i in self.curChannels: button = QtWidgets.QPushButton("Button %d" % (i + 1)) layout.addWidget(button) self.chartWidget = ZeStreamWidget(self.audioDevice, "Default mic", [0, sampleCount], [-1,1]) self.chart = self.chartWidget.chart self.chartView = QtCharts.QChartView(self.chart) layout.addWidget(self.chartView) self.chartWidget2 = ZeStreamWidget(self.audioDevice, "Default mic2", [0, sampleCount], [-1,1]) self.chart2 = self.chartWidget2.chart self.chartView2 = QtCharts.QChartView(self.chart2) layout.addWidget(self.chartView2) self.streamingBox.setLayout(layout)