Exemplo n.º 1
0
    def updateUI(self):
        theme = self.m_themeComboBox.itemData(
            self.m_themeComboBox.currentIndex())

        if self.m_charts[0].chart().theme() != theme:
            for chartView in self.m_charts:
                chartView.chart().setTheme(QChart.ChartTheme(theme))

            pal = self.window().palette()

            if theme == QChart.ChartThemeLight:
                pal.setColor(QPalette.Window, QColor(0xf0f0f0))
                pal.setColor(QPalette.WindowText, QColor(0x404044))
            elif theme == QChart.ChartThemeDark:
                pal.setColor(QPalette.Window, QColor(0x121218))
                pal.setColor(QPalette.WindowText, QColor(0xd6d6d6))
            elif theme == QChart.ChartThemeBlueCerulean:
                pal.setColor(QPalette.Window, QColor(0x40434a))
                pal.setColor(QPalette.WindowText, QColor(0xd6d6d6))
            elif theme == QChart.ChartThemeBrownSand:
                pal.setColor(QPalette.Window, QColor(0x9e8965))
                pal.setColor(QPalette.WindowText, QColor(0x404044))
            elif theme == QChart.ChartThemeBlueNcs:
                pal.setColor(QPalette.Window, QColor(0x018bba))
                pal.setColor(QPalette.WindowText, QColor(0x404044))
            elif theme == QChart.ChartThemeHighContrast:
                pal.setColor(QPalette.Window, QColor(0xffab03))
                pal.setColor(QPalette.WindowText, QColor(0x181818))
            elif theme == QChart.ChartThemeBlueIcy:
                pal.setColor(QPalette.Window, QColor(0xcee7f0))
                pal.setColor(QPalette.WindowText, QColor(0x404044))
            else:
                pal.setColor(QPalette.Window, QColor(0xf0f0f0))
                pal.setColor(QPalette.WindowText, QColor(0x404044))

            self.window().setPalette(pal)

        checked = self.m_antialiasCheckBox.isChecked()
        for chartView in self.m_charts:
            chartView.setRenderHint(QPainter.Antialiasing, checked)

        options = QChart.AnimationOptions(
            self.m_animatedComboBox.itemData(
                self.m_animatedComboBox.currentIndex()))

        if self.m_charts[0].chart().animationOptions() != options:
            for chartView in self.m_charts:
                chartView.chart().setAnimationOptions(options)

        alignment = self.m_legendComboBox.itemData(
            self.m_legendComboBox.currentIndex())

        for chartView in self.m_charts:
            legend = chartView.chart().legend()

            if alignment == 0:
                legend.hide()
            else:
                legend.setAlignment(Qt.Alignment(alignment))
                legend.show()
Exemplo n.º 2
0
    def chart_init(self,s_key):
        self.chart = QChart()
        self.x_Aix = QDateTimeAxis()#定义x轴,实例化
        #self.x_Aix.setRange(52665,52765)
        #self.x_Aix.setLabelFormat("%0.2f")
        self.x_Aix.setFormat("hh:mm:ss")
        self.x_Aix.setTickCount(6)
        #self.x_Aix.setTickCount(6)
        #self.x_Aix.setMinorTickCount(0)

        self.y_Aix = QValueAxis()#定义y轴
        #self.y_Aix.setRange(-50,50)
        self.y_Aix.setLabelFormat("%0.2f")
        #self.y_Aix.setTickCount(6)
        self.y_Aix.setMinorTickCount(0)

        self.chart.addAxis(self.x_Aix,Qt.AlignBottom)
        self.chart.addAxis(self.y_Aix,Qt.AlignLeft)

        self.s_key = s_key
        self.series_list={}
        color_list = [QColor("blue"),QColor("green"),QColor("red"),QColor(152,245,255),QColor(84,255,159),QColor(255,193,193)]
        for k,c in zip(self.s_key,color_list):
            self.q_point[k] = queue.Queue()
            self.series_list[k] = QScatterSeries()
            self.series_list[k].setMarkerSize(9.0)
            self.series_list[k].setColor(QColor(c))
            self.series_list[k].setPen(QPen(QtCore.Qt.PenStyle.NoPen))
            self.chart.addSeries(self.series_list[k])
            self.series_list[k].setName(k)
            self.series_list[k].attachAxis(self.x_Aix)
            self.series_list[k].attachAxis(self.y_Aix)

        self.setChart(self.chart)
Exemplo n.º 3
0
    def _get_connector_chart(self):  # type: (Display) -> QChartView
        # Create pen
        pen = QLineSeries().pen()
        pen.setColor(Qt.blue)
        pen.setWidthF(1)

        # Series
        self._connector_series = QLineSeries()
        self._connector_series.setPen(pen)
        self._connector_series.useOpenGL()

        # Chart
        self._connector_chart = QChart()
        self._connector_chart.legend().hide()
        self._connector_chart.addSeries(self._connector_series)
        self._connector_chart.createDefaultAxes()
        self._connector_chart.axisX().setMax(100)
        self._connector_chart.axisX().setMin(0)
        self._connector_chart.axisY().setMax(500)
        self._connector_chart.axisY().setMin(-500)

        # Chart View
        view = QChartView(self._connector_chart)
        view.setRenderHint(QPainter.Antialiasing)
        view.setStyleSheet('margin: 0px; height: 250%; width: 400%;')
        return view
Exemplo n.º 4
0
    def chart(self):
        self.pieseries = QPieSeries()  # 定义PieSeries
        self.pieseries.append("正常程序", 0.1)  # 插入第一个元素
        self.pieseries.append("恶意程序", 0.9)

        self.slice = self.pieseries.slices()[0]  # 得到饼图的某一个元素切片,在这取得为第一个
        #self.slice.setExploded()  # 设置为exploded
        self.slice.setLabelVisible()  # 设置Lable
        self.slice.setPen(QPen(Qt.darkGreen, 1))  # 设置画笔类型
        self.slice.setBrush(Qt.green)  # 设置笔刷
        self.slice1 = self.pieseries.slices()[1]  # 得到饼图的某一个元素切片,在这取得为第一个
        self.slice1.setExploded()  # 设置为exploded
        self.slice1.setLabelVisible()  # 设置Lable
        self.slice1.setPen(QPen(Qt.darkRed, 1))  # 设置画笔类型
        self.slice1.setBrush(Qt.red)  # 设置笔刷
        self.chart = QChart()  # 定义QChart
        self.chart.addSeries(self.pieseries)  # 将 pieseries添加到chart里
        self.chart.setTitle("恶意程序预测结果饼状图")  # 设置char的标题
        self.chart.legend().hide()  # 将char的legend设置为隐藏

        self.charview = QChartView(
            self.chart, self.left_down_widget
        )  # 定义charView窗口,添加chart元素,设置主窗口为父窗体,既将chartView嵌入到父窗体
        self.charview.setGeometry(0, 0, 800, 500)  # 设置charview在父窗口的大小、位置
        self.charview.setRenderHint(QPainter.Antialiasing)  # 设置抗锯齿
        self.charview.show()  # 将CharView窗口显示出来
Exemplo n.º 5
0
    def __init__(self, parent=None):
        super().__init__(parent=parent)

        self.cursor = QGraphicsLineItem()
        self.scene().addItem(self.cursor)

        self.xvalues = {}

        self.chart = QChart()
        self.setChart(self.chart)
        self.chart.legend().setVisible(True)
        self.chart.legend().setAlignment(Qt.AlignTop)
        self.ncurves = 0
        self.setRenderHint(QPainter.Antialiasing)

        # Selection features
        # self.setRubberBand(QChartView.HorizontalRubberBand)
        self.selectionBand = QRubberBand(QRubberBand.Rectangle, self)
        self.selecting = False
        self.initialClick = QPoint()

        # Track mouse
        self.setMouseTracking(True)

        self.labelValue = QLabel(self)
        self.labelValue.setStyleSheet(
            "background-color: rgba(255,255,255,75%); color: black;")
        self.labelValue.setAlignment(Qt.AlignCenter)
        self.labelValue.setMargin(5)
        self.labelValue.setVisible(False)

        self.build_style()
    def __init__(self, parent=None):
        super(Plot, self).__init__(parent)

        self.setFixedSize(PLOT_WIDTH, PLOT_HEIGHT)

        self.xMax = None
        self.yMin = None
        self.yMax = None

        self.xAutoRescale = True
        self.yMinAutoRescale = True
        self.yMaxAutoRescale = True

        self.seriesList = []

        self.chart = QChart()

        self.xAxis = QValueAxis()
        self.chart.addAxis(self.xAxis, Qt.AlignBottom)

        self.yAxis = QValueAxis()
        self.chart.addAxis(self.yAxis, Qt.AlignLeft)

        self.setSubplots(1)

        self.chart.legend().setVisible(False)
        self.chart.legend().setAlignment(Qt.AlignBottom)

        self.setChart(self.chart)
Exemplo n.º 7
0
    def __init__(self, parent=None, ticker="BTC"):
        super().__init__(parent)
        uic.loadUi("resource/chart.ui", self)
        self.ticker = ticker
        self.viewLimit = 128

        self.priceData = QLineSeries()
        self.priceChart = QChart()
        self.priceChart.addSeries(self.priceData)
        self.priceChart.legend().hide()

        axisX = QDateTimeAxis()
        axisX.setFormat("hh:mm:ss")
        axisX.setTickCount(4)
        dt = QDateTime.currentDateTime()
        axisX.setRange(dt, dt.addSecs(self.viewLimit))
        axisY = QValueAxis()
        axisY.setVisible(False)

        self.priceChart.addAxis(axisX, Qt.AlignBottom)
        self.priceChart.addAxis(axisY, Qt.AlignRight)
        self.priceData.attachAxis(axisX)
        self.priceData.attachAxis(axisY)
        self.priceChart.layout().setContentsMargins(0, 0, 0, 0)

        self.priceView.setChart(self.priceChart)
        self.priceView.setRenderHints(QPainter.Antialiasing)

        self.pw = PriceWorker(ticker)
        self.pw.dataSent.connect(self.appendData)
        self.pw.start()
Exemplo n.º 8
0
    def _get_processor_chart(self):  # type: (Display) -> QChartView
        # Create pen
        pen = QLineSeries().pen()
        pen.setColor(Qt.red)
        pen.setWidthF(1)

        # Series
        self._processor_series = QLineSeries()
        self._processor_series.setPen(pen)
        self._processor_series.useOpenGL()

        # Chart
        self._processor_chart = QChart()
        self._processor_chart.legend().hide()
        self._processor_chart.addSeries(self._processor_series)
        self._processor_chart.createDefaultAxes()
        self._processor_chart.axisX().setMax(100)
        self._processor_chart.axisX().setMin(0)
        self._processor_chart.axisY().setMax(5000)
        self._processor_chart.axisY().setMin(0)

        self._processor_x_axis = QValueAxis()
        self._processor_x_axis.setLabelFormat('%i')
        self._processor_chart.setAxisX(self._processor_x_axis,
                                       self._processor_series)

        self._processor_y_axis = QLogValueAxis()
        self._processor_y_axis.setLabelFormat('%g')
        self._processor_y_axis.setBase(8)

        # Chart View
        view = QChartView(self._processor_chart)
        view.setRenderHint(QPainter.Antialiasing)
        view.setStyleSheet('margin: 0px; height: 250%; width: 400%;')
        return view
Exemplo n.º 9
0
    def __init__(self):
        QChartView.__init__(self)
        #self.resize(300, 300)
        self.setRenderHint(QPainter.Antialiasing)  # 抗锯齿
        self.chart = QChart()
        self.seriesAcc = QLineSeries()
        self.seriesAcc.setName(CONF.leftUpNames[0])
        self.chart.addSeries(self.seriesAcc)
        #声明并初始化X轴,Y轴
        self.dtaxisX = QValueAxis()
        self.vlaxisY = QValueAxis()
        #设置坐标轴显示范围
        self.dtaxisX.setMin(0)
        #self.dtaxisX.setMax(100)
        self.vlaxisY.setMin(0)
        #self.vlaxisY.setMax(100)
        self.dtaxisX.setTickCount(3)
        self.vlaxisY.setTickCount(3)
        #设置坐标轴名称
        self.dtaxisX.setTitleText(CONF.leftUpNames[1])
        self.vlaxisY.setTitleText(CONF.leftUpNames[2])
        #设置网格不显示
        self.vlaxisY.setGridLineVisible(False)
        #把坐标轴添加到chart中
        self.chart.addAxis(self.dtaxisX, Qt.AlignBottom)
        self.chart.addAxis(self.vlaxisY, Qt.AlignLeft)

        self.seriesAcc.attachAxis(self.dtaxisX)
        self.seriesAcc.attachAxis(self.vlaxisY)

        self.initUI()
Exemplo n.º 10
0
    def __iniChart(self):
        self.chart = QChart()  #创建 Chart
        self.chart.setTitle("股票日线图")
        self.chart.setTheme(
            QChart.ChartThemeBlueCerulean
        )  #ChartThemeBlueCerulean, ChartThemeQt,ChartThemeBlueNcs,ChartThemeDark
        self.ui.chartView.setChart(self.chart)  #Chart添加到ChartView

        ## X 轴是QDateTimeAxis
        self.__axisX = QDateTimeAxis()
        dateFormat = self.ui.comboDateFormat.currentText()  #如"MM-dd"
        self.__axisX.setFormat(dateFormat)  #标签格式
        self.__axisX.setTickCount(10)  #主分隔个数
        self.__axisX.setTitleText("日期")  #标题

        dateMin = QDateTime.fromString("2018-01-01", "yyyy-MM-dd")
        self.__axisX.setMin(dateMin)
        dateMax = dateMin.addDays(150)
        self.__axisX.setMax(dateMax)
        self.chart.addAxis(self.__axisX, Qt.AlignBottom)

        ## Y 轴是 QValueAxis
        self.__axisY = QValueAxis()
        self.__axisY.setTitleText("Value")
        self.__axisY.setRange(0, 20)
        self.__axisY.setTickCount(5)
        self.__axisY.setLabelFormat("%.2f")  #标签格式
        self.chart.addAxis(self.__axisY, Qt.AlignLeft)
Exemplo n.º 11
0
    def __init__(self, barCount: int):
        super().__init__()

        self.chart = QChart()
        self.setChart(self.chart)
        self.setRenderHint(QPainter.Antialiasing)
        self.chart.setAnimationOptions(QChart.SeriesAnimations)
        self.chart.setBackgroundVisible(True)
        self.chart.legend().setVisible(False)

        self.series = QBarSeries()
        self.chart.addSeries(self.series)

        self.barValues = QBarSet('')
        self.series.append(self.barValues)
        for i in range(barCount):
            self.barValues << 0.

        self.xAxis = QBarCategoryAxis()
        self.chart.addAxis(self.xAxis, Qt.AlignBottom)
        self.series.attachAxis(self.xAxis)
        self.xAxis.setTitleText('yPlus ranges')

        self.yAxis = QValueAxis()
        self.chart.addAxis(self.yAxis, Qt.AlignLeft)
        self.series.attachAxis(self.yAxis)
        self.yAxis.setTitleText('% of surface area')
        self.yAxis.setRange(0, 100)
Exemplo n.º 12
0
    def init_ui(self):



        self.line_series = QLineSeries()
        self.chart = QChart()
        self.chart_view = QChartView(self.chart)
        self.chart_view.setMinimumSize(640,480)

        self.model = ItemModel()
        self.model.signal_update_models.connect(self.update_axes)

        self.table_view = TableView()

        self.table_view.setModel(self.model)
        self.table_view.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
        self.table_view.verticalHeader().setSectionResizeMode(QHeaderView.Stretch)

        self.chart.setAnimationOptions(QChart.AllAnimations)
        self.chart.setAnimationDuration(2000)

        self.line_series.setName("Line 1")

        self.mapper = QVXYModelMapper(self)
        self.mapper.setXColumn(0)
        self.mapper.setYColumn(1)
        self.mapper.setSeries(self.line_series)
        self.mapper.setModel(self.model)
        self.chart.addSeries(self.line_series)

        seriesColorHex = self.line_series.pen().color().name()
        self.model.add_mapping(seriesColorHex,
                               QRect(0,0,2, self.model.rowCount()))

        self.line_series2 = QLineSeries()
        self.line_series2.setName("Line 2")

        self.mapper2 = QVXYModelMapper(self)
        self.mapper2.setXColumn(2)
        self.mapper2.setYColumn(3)
        self.mapper2.setSeries(self.line_series2)
        self.mapper2.setModel(self.model)
        self.chart.addSeries(self.line_series2)


        seriesColorHex = self.line_series2.pen().color().name()
        self.model.add_mapping(seriesColorHex,
                               QRect(2, 0, 2, self.model.rowCount()))

        self.chart.createDefaultAxes()

        self.grid = QGridLayout()
        self.grid.addWidget(self.table_view,0,0)
        self.grid.addWidget(self.chart_view,0,1)

        self.chart_view.setRenderHint(QPainter.Antialiasing)
        self.cw = QWidget()
        self.cw.setLayout(self.grid)
        self.setCentralWidget(self.cw)
        self.resize(400,300)
Exemplo n.º 13
0
 def __init__(self):
     QDialog.__init__(self)
     self.setWindowTitle("Printen grafiek magazijnvoorraad bedragen")
     self.setWindowIcon(QIcon('./images/logos/logo.jpg'))
     self.setWindowFlags(self.windowFlags() | Qt.WindowSystemMenuHint
                         | Qt.WindowMinMaxButtonsHint)
     self.chart = QChart()
     self.chart_view = QChartView(self.chart)
     self.chart_view.setRenderHint(QPainter.Antialiasing)
     self.buttonPreview = QPushButton('Afdrukvoorbeeld', self)
     self.buttonPreview.setStyleSheet(
         "color: black;  background-color: gainsboro")
     self.buttonPreview.clicked.connect(self.handle_preview)
     self.buttonPrint = QPushButton('Printen', self)
     self.buttonPrint.setStyleSheet(
         "color: black;  background-color: gainsboro")
     self.buttonPrint.clicked.connect(self.handle_print)
     self.sluiten = QPushButton('Sluiten', self)
     self.sluiten.setStyleSheet(
         "color: black;  background-color: gainsboro")
     self.sluiten.clicked.connect(lambda: sluiten(self, m_email))
     layout = QGridLayout(self)
     layout.addWidget(self.buttonPrint, 1, 1)
     layout.addWidget(self.sluiten, 1, 0)
     layout.addWidget(self.chart_view, 0, 0, 1, 3)
     layout.addWidget(self.buttonPreview, 1, 2)
     self.create_chart()
Exemplo n.º 14
0
 def showRecords(self):
     self.w = QWidget()
     self.w.show()
     self.hide()
     self.gridLayout = QtWidgets.QVBoxLayout(self.w)
     self.text = QtWidgets.QLabel(self.w)
     self.chart = QChart()
     self.chart2 = QChart()
     self.chart3 = QChart()
     self.text.setText("none")
     self.backButton = QtWidgets.QPushButton(self.w)
     self.chartView = QChartView(self.chart)
     self.chartView.setRenderHint(QtGui.QPainter.Antialiasing)
     # self.chartView2.setRenderHint(QtGui.QPainter.Antialiasing)
     # self.chartView3.setRenderHint(QtGui.QPainter.Antialiasing)
     self.gridLayout.addWidget(self.chartView)
     # self.gridLayout.addWidget(self.chartView3)
     self.backButton.setText("Back")
     self.gridLayout.addWidget(self.backButton)
     self.backButton.clicked.connect(self.back)
     self.recive = True
     # self.series2 = QLineSeries(self.chart2)
     # self.series3 = QLineSeries(self.chart3)
     self.series = QLineSeries(self.chart)
     self.series2 = QLineSeries(self.chart)
     self.series3 = QLineSeries(self.chart)
     # self.series2.setUseOpenGL(True)
     # self.series3.setUseOpenGL(True)
     self.series.setUseOpenGL(True)
     self.series2.setUseOpenGL(True)
     self.series3.setUseOpenGL(True)
     # self.chart.addSeries(self.series)
     self.startServer()
Exemplo n.º 15
0
    def __init__(self, parent=None):
        super().__init__(parent)
        # Holds the raw input to be checked for actionable data to display.
        self.input_buffer = []
        # Holds the raw actionable data detected while plotting.
        self.raw_data = []
        self.setObjectName("plotterpane")
        self.max_x = 100  # Maximum value along x axis
        self.max_y = 1000  # Maximum value +/- along y axis
        self.flooded = False  # Flag to indicate if data flooding is happening.

        # Holds deques for each slot of incoming data (assumes 1 to start with)
        self.data = [deque([0] * self.max_x)]
        # Holds line series for each slot of incoming data (assumes 1 to start
        # with).
        self.series = [QLineSeries()]

        # Ranges used for the Y axis (up to 1000, after which we just double
        # the range).
        self.y_ranges = [1, 5, 10, 25, 50, 100, 250, 500, 1000]

        # Set up the chart with sensible defaults.
        self.chart = QChart()
        self.chart.legend().hide()
        self.chart.addSeries(self.series[0])
        self.axis_x = QValueAxis()
        self.axis_y = QValueAxis()
        self.axis_x.setRange(0, self.max_x)
        self.axis_y.setRange(-self.max_y, self.max_y)
        self.axis_x.setLabelFormat("time")
        self.axis_y.setLabelFormat("%d")
        self.chart.setAxisX(self.axis_x, self.series[0])
        self.chart.setAxisY(self.axis_y, self.series[0])
        self.setChart(self.chart)
        self.setRenderHint(QPainter.Antialiasing)
Exemplo n.º 16
0
    def __init__(self, pView, pModel):
        '''
            Initializes the chart
        '''
        self.model = pModel
        self.view = pView

        self.queries = {
            'Products by category': I.PRODUCTS_BY_CATEGORY,
            'Sellers by gender': I.SELLERS_BY_GENDER,
            'Sellers by age': I.SELLERS_BY_AGE,
            'Total sales by gender': I.SALES_BY_GENDER,
            'Total sales profit by gender': I.PROFITS_BY_GENDER
        }

        # Loads every admin statistic
        for key in self.queries:
            self.view.ui.Statistics_StatisticsInput.addItem(key)

        self.view.ui.Statistics_ShowButton.clicked.connect(self.loadQuery)

        # Sets up the chart
        self.chart = QChart()

        # Embeds the chart in the application
        layout = QVBoxLayout()

        chartView = QChartView(self.chart)

        layout.addWidget(chartView)
        chartView.show()

        self.view.ui.Statistics_StatisticsWidget.setLayout(layout)
Exemplo n.º 17
0
    def initChart(self):
        self._chart = QChart(title='蜡烛图悬浮提示')
        self._chart.setAnimationOptions(QChart.SeriesAnimations)
        series = QCandlestickSeries()
        series.setIncreasingColor(QColor(Qt.red))
        series.setDecreasingColor(QColor(Qt.green))
        series.setName(self.stocks['name'].iloc[0])
        for _, stock in self.stocks.iterrows():
            time_p = datetime.datetime.strptime(stock['trade_date'], '%Y%m%d')
            time_p = float(time.mktime(time_p.timetuple()))
            _set = QCandlestickSet(float(stock['open']), float(stock['high']), 
                float(stock['low']), float(stock['close']), time_p, series)
            _set.hovered.connect(self.handleBarHoverd)  # 鼠标悬停
            series.append(_set)
        self._chart.addSeries(series)

        self._chart.createDefaultAxes()
        self._chart.setLocalizeNumbers(True)
        axis_x = self._chart.axisX()
        axis_y = self._chart.axisY()
        axis_x.setGridLineVisible(False)
        axis_y.setGridLineVisible(False)
        # axis_y.setLabelFormat("%.2f")
        axis_x.setCategories(self.category)
        max_p = self.stocks[['high', 'low']].stack().max() + 10
        min_p = self.stocks[['high', 'low']].stack().min() - 10
        axis_y.setRange(min_p, max_p)

        # chart的图例
        legend = self._chart.legend()
        # 设置图例由Series来决定样式
        legend.setMarkerShape(QLegend.MarkerShapeFromSeries)

        self.setChart(self._chart)
Exemplo n.º 18
0
    def __init__(self, parent=None):
        super(widgetFDChart, self).__init__(parent)
        self.setupUi(self)
        tribchartmenustyle(self)
        # SetUp for Chart to Display Distribution curves and inputs.
        self.chart = QChart()
        self.chart.legend().setVisible(False)

        self.chart.axisX = QValueAxis()
        self.chart.axisY = QValueAxis()
        self.chart.axisX.setTickCount(10)
        self.chart.axisY.setTickCount(10)
        self.chart.axisX.setTitleText("Value")
        self.chart.axisY.setTitleText("Probability")

        self.chartview = QChartView(self.chart)
        self.verticalLayout.addWidget(self.chartview)
        #        self.setAxesMinMax(-3,3,0.01,1.5)
        self.chartview.setRenderHint(QPainter.Antialiasing)
        # self.legend().setVisible(True)
        # self.setAnimationOptions(QChart.SeriesAnimations)
        # self.legend().setAlignment(Qt.AlignBottom)

        # Connect Buttons
        self.pushButtonExportPNG.pressed.connect(self._onActionSavePNG)
Exemplo n.º 19
0
    def __init__(self, parent=None):
        super(DemoWindow, self).__init__(parent=parent)

        self.plotChart = QChart()
        self.plotChart.legend().hide()

        self.plotView = QChartView(self.plotChart)
        self.setCentralWidget(self.plotView)

        self.plotCurve = QLineSeries()
        self.plotCurve.setUseOpenGL(True)
        self.plotCurve.pen().setColor(Qt.red)
        self.plotChart.addSeries(self.plotCurve)

        self.plotChart.createDefaultAxes()
        self.plotChart.axisX().setLabelFormat('%d')

        self.RecvData = array.array('f')  # 存储接收到的传感器数据
        self.RecvIndx = 0

        self.tmrData = QTimer()  # 模拟传感器传送过来数据
        self.tmrData.setInterval(3)
        self.tmrData.timeout.connect(self.on_tmrData_timeout)
        self.tmrData.start()

        self.tmrPlot = QTimer()
        self.tmrPlot.setInterval(100)
        self.tmrPlot.timeout.connect(self.on_tmrPlot_timeout)
        self.tmrPlot.start()
Exemplo n.º 20
0
 def initChart(self):
     self._chart = QChart(title="柱状图堆叠")
     self._chart.setAcceptHoverEvents(True)
     # Series动画
     self._chart.setAnimationOptions(QChart.SeriesAnimations)
     self.categories = ["周一", "周二", "周三", "周四", "周五", "周六", "周日"]
     names = ["邮件营销", "联盟广告", "视频广告", "直接访问", "搜索引擎"]
     series = QBarSeries(self._chart)
     for name in names:
         bar = QBarSet(name)
         # 随机数据
         for _ in range(7):
             bar.append(randint(0, 10))
         series.append(bar)
         bar.hovered.connect(self.handleBarHoverd)  # 鼠标悬停
     self._chart.addSeries(series)
     self._chart.createDefaultAxes()  # 创建默认的轴
     # x轴
     axis_x = QBarCategoryAxis(self._chart)
     axis_x.append(self.categories)
     self._chart.setAxisX(axis_x, series)
     # chart的图例
     legend = self._chart.legend()
     legend.setVisible(True)
     # 遍历图例上的标记并绑定信号
     for marker in legend.markers():
         # 点击事件
         marker.clicked.connect(self.handleMarkerClicked)
         # 鼠标悬停事件
         marker.hovered.connect(self.handleMarkerHovered)
     self.setChart(self._chart)
Exemplo n.º 21
0
    def unlinkedChartDist(self, data):
        chart = QChart()
        chart.setAnimationOptions(QChart.SeriesAnimations)
        self.getCertainRangeList(data)

        chartView = QChartView(chart)
        return chartView
Exemplo n.º 22
0
        def __init__(self):
            QDialog.__init__(self)
            self.setWindowTitle(
                "Printen grafiek aantal externe werken per status over jaar " +
                jrwk[0:4])
            self.setWindowIcon(QIcon('./images/logos/logo.jpg'))
            self.setWindowFlags(self.windowFlags() | Qt.WindowSystemMenuHint
                                | Qt.WindowMinMaxButtonsHint)
            self.chart = QChart()
            self.chart_view = QChartView(self.chart)
            self.chart_view.setRenderHint(QPainter.Antialiasing)
            self.buttonPreview = QPushButton('Afdrukvoorbeeld', self)
            self.buttonPreview.clicked.connect(self.handle_preview)
            self.buttonPreview.setStyleSheet(
                "color: navy;  background-color: gainsboro")
            self.buttonPrint = QPushButton('Printen', self)
            self.buttonPrint.clicked.connect(self.handle_print)
            self.buttonPrint.setStyleSheet(
                "color: navy;  background-color: gainsboro")
            self.buttonSluit = QPushButton('Sluiten', self)
            self.buttonSluit.clicked.connect(lambda: sluit(self, m_email))
            self.buttonSluit.setStyleSheet(
                "color: navy;  background-color: gainsboro")
            self.buttonInfo = QPushButton('Info', self)
            self.buttonInfo.clicked.connect(lambda: info(self))
            self.buttonInfo.setStyleSheet(
                "color: navy;  background-color: gainsboro")

            layout = QGridLayout(self)
            layout.addWidget(self.chart_view, 0, 0, 1, 4)
            layout.addWidget(self.buttonInfo, 1, 0)
            layout.addWidget(self.buttonSluit, 1, 1)
            layout.addWidget(self.buttonPrint, 1, 2)
            layout.addWidget(self.buttonPreview, 1, 3)
            self.create_chart()
Exemplo n.º 23
0
    def __init__(self):
        QChartView.__init__(self)
        self.chart = QChart()
        self.candleSeries = QCandlestickSeries(self)
        self.candleSeries.setIncreasingColor(Qt.blue)
        self.candleSeries.setBodyOutlineVisible(False)
        self.candleSeries.setDecreasingColor(Qt.red)
        self.candleSeries.setMaximumColumnWidth(20)
        self.candleSeries.clicked.connect(lambda set: print(set.high()))

        self.xAxis = QDateTimeAxis()
        self.xAxis.setTickCount(10)
        self.xAxis.setFormat("h:mm")
        self.yAxis = QValueAxis()

        for candle in data:
            self.addCandle(
                self.get_integer_price(candle[0]),
                self.get_integer_price(candle[1]),
                self.get_integer_price(candle[2]),
                self.get_integer_price(candle[3]),
                datetime.strptime(candle[4], '%Y%m%d%H%M%S').timestamp() *
                1000)

        self.chart.addSeries(self.candleSeries)
        self.setChart(self.chart)
        self.chart.setAxisX(self.xAxis, self.candleSeries)
        self.chart.setAxisY(self.yAxis, self.candleSeries)
        self.chart.legend().setVisible(False)
Exemplo n.º 24
0
    def __init__(self, data: pd.DataFrame):
        super(VLineChartView, self).__init__()
        self._stocks = data
        self._category = self._stocks['trade_date']
        self._chart = QChart()
        self._chart.setAnimationOptions(QChart.SeriesAnimations)
        self._series = QStackedBarSeries()
        # 成交量以万股为单位
        self._vol_multiple = 10000
        self.init_chart()
        self._zero_value = (0, self._chart.axisY().min())
        self._max_value = (len(self._chart.axisX().categories()),
                           self._chart.axisY().max())
        self._zero_point = self._chart.mapToPosition(
            QPointF(self._zero_value[0], self._zero_value[1]))
        self._max_point = self._chart.mapToPosition(
            QPointF(self._max_value[0], self._max_value[1]))
        # 计算x轴单个cate的宽度,用来处理横线不能画到边界
        self._cate_width = (self._max_point.x() - self._zero_point.x()) / len(
            self._category)
        self._series.hovered.connect(self.on_series_hovered)

        x_index_list = np.percentile(range(len(self._category)),
                                     [0, 25, 50, 75, 100])
        self._x_axis_list = [
            QGraphicsSimpleTextItem(self._category[int(index)], self._chart)
            for index in x_index_list
        ]
        [axis.setText(axis.text()[4:]) for axis in self._x_axis_list[1:]]
        self._v_b = QGraphicsSimpleTextItem('B', self._chart)
        self._v_b.setZValue(100)
Exemplo n.º 25
0
    def create_donutchart(self, chartKey):
        series = QPieSeries()
        series.setHoleSize(0.35)

        for key, value in sample[chartKey].items():
            series.append(key, value)

        slice = QPieSlice()

        chart = QChart()
        #chart.legend().hide()
        chart.addSeries(series)

        # for the background and title
        chart.setAnimationOptions(QChart.SeriesAnimations)
        chart.setTitle("DonutChart Example")
        chart.setTheme(QChart.ChartThemeBlueCerulean)

        chartview = QChartView(chart)
        chartview.setRenderHint(QPainter.Antialiasing)

        # creating a widget object
        widget = QWidget()

        # Creating a grid layout
        layout = QGridLayout()

        # setting this layout to the widget
        widget.setLayout(layout)

        self.setCentralWidget(chartview)

        series.doubleClicked.connect(self.handle_double_clicked)
Exemplo n.º 26
0
    def __init__(self, parent=None):
        super(QChartView, self).__init__(parent=parent)

        self.reftime = datetime.datetime.now()
        self.cursor = QGraphicsLineItem()
        self.scene().addItem(self.cursor)
        self.decim_factor = 1

        # self.setScene(QGraphicsScene())
        self.chart = QChart()
        # self.scene().addItem(self.chart)
        self.setChart(self.chart)
        self.chart.legend().setVisible(True)
        self.chart.legend().setAlignment(Qt.AlignBottom)
        self.ncurves = 0
        self.setRenderHint(QPainter.Antialiasing)
        self.setRubberBand(QChartView.HorizontalRubberBand)

        # X, Y label on bottom
        # self.xTextItem = QGraphicsSimpleTextItem(self.chart)
        # self.xTextItem.setText('X: ')
        # self.yTextItem = QGraphicsSimpleTextItem(self.chart)
        # self.yTextItem.setText('Y: ')
        # self.update_x_y_coords()

        # Track mouse
        self.setMouseTracking(True)

        # Top Widgets
        newWidget = QWidget(self)
        newLayout = QHBoxLayout()
        newWidget.setLayout(newLayout)
        labelx = QLabel(self)
        labelx.setText('X:')
        self.labelXValue = QLabel(self)
        labely = QLabel(self)
        labely.setText('Y:')
        self.labelYValue = QLabel(self)

        # Test buttons
        newLayout.addWidget(QToolButton(self))
        newLayout.addWidget(QToolButton(self))
        newLayout.addWidget(QToolButton(self))

        # Spacer
        newLayout.addItem(QSpacerItem(10, 10, QSizePolicy.Expanding, QSizePolicy.Minimum))

        # Labels
        newLayout.addWidget(labelx)
        newLayout.addWidget(self.labelXValue)
        self.labelXValue.setMinimumWidth(200)
        self.labelXValue.setMaximumWidth(200)
        newLayout.addWidget(labely)
        newLayout.addWidget(self.labelYValue)
        self.labelYValue.setMinimumWidth(200)
        self.labelYValue.setMaximumWidth(200)

        if parent is not None:
            parent.layout().setMenuBar(newWidget)
Exemplo n.º 27
0
    def ALL(self):
        self.ind = 0
        set0 = QBarSet('Daya Tarik')
        set1 = QBarSet('Aksesbilitas')
        set2 = QBarSet('Kebersihan')
        set3 = QBarSet('Fasilitas')

        set0.setColor(QtGui.QColor("blue"))
        set1.setColor(QtGui.QColor("red"))
        set2.setColor(QtGui.QColor("green"))
        set3.setColor(QtGui.QColor("orange"))
        gf = Grafik_2()

        jml = gf.jumlah_per_pantai()
        jml_pantai = []
        for i in range(len(jml)):
            jml_pantai.append(jml[i])

        hasil = gf.hasil_dayatarik()
        for i in range(len(hasil)):
            set0.append((hasil[i] / jml_pantai[i]) * 100)

        hasil2 = gf.hasil_aksesbilitas()
        for i in range(len(hasil2)):
            set1.append((hasil2[i] / jml_pantai[i]) * 100)

        hasil3 = gf.hasil_kebersihan()
        for i in range(len(hasil3)):
            set2.append((hasil3[i] / jml_pantai[i]) * 100)

        hasil4 = gf.hasil_fasilitas()
        for i in range(len(hasil4)):
            set3.append((hasil4[i] / jml_pantai[i]) * 100)

        series = QBarSeries()
        series.append(set0)
        series.append(set1)
        series.append(set2)
        series.append(set3)
        series.setLabelsVisible(True)
        series.setLabelsPosition(QAbstractBarSeries.LabelsInsideEnd)
        series.setLabelsAngle(-90)

        self.chart = QChart()
        self.chart.addSeries(series)
        self.chart.setTitle('Grafik Prosentase Ulasan Pantai')
        self.chart.setAnimationOptions(QChart.SeriesAnimations)
        axisY = QValueAxis()
        axisY.setTitleText("Prosentase (%)")
        axisY.applyNiceNumbers()
        self.chart.addAxis(axisY, Qt.AlignLeft)
        series.attachAxis(axisY)
        self.chart.legend().setVisible(True)
        self.chart.legend().setAlignment(Qt.AlignBottom)
        self.chart.createDefaultAxes()
        self.graphicsView.setChart(self.chart)
        self.adjust_axes(0, 2)
        self.lims = np.array([0, 6])
        self.onAxisSliderMoved(self.verticalScrollBar.value())
Exemplo n.º 28
0
 def __init__(self, parent=None):
     super(TestWindow, self).__init__(parent=parent)
     self.ncurves = 0
     self.chart = QChart()
     self.chart.legend().hide()
     self.view = QChartView(self.chart)
     self.view.setRenderHint(QPainter.Antialiasing)
     self.setCentralWidget(self.view)
Exemplo n.º 29
0
    def __init__(self):
        self.model = QChart()
        self.view = QChartView()

        self.view.setChart(self.model)

        self.model.legend().setAlignment(Qt.AlignBottom)
        self.view.setRenderHint(QPainter.Antialiasing)
Exemplo n.º 30
0
    def init_graph(self):
        self.graph_chart = QChart(title="售出图")
        self.graph_chart.legend().setVisible(True)
        self.graph_chart.setAcceptHoverEvents(True)

        graph_view = QChartView(self.graph_chart)
        graph_view.setRenderHint(QPainter.Antialiasing)
        self.gridLayout_5.addWidget(graph_view)
Exemplo n.º 31
0
    def __init__(self, parent=None):
        super().__init__(parent)
        # Holds the raw input to be checked for actionable data to display.
        self.input_buffer = []
        # Holds the raw actionable data detected while plotting.
        self.raw_data = []
        self.setObjectName('plotterpane')
        self.max_x = 100  # Maximum value along x axis
        self.max_y = 1000  # Maximum value +/- along y axis
        self.flooded = False  # Flag to indicate if data flooding is happening.

        # Holds deques for each slot of incoming data (assumes 1 to start with)
        self.data = [deque([0] * self.max_x), ]
        # Holds line series for each slot of incoming data (assumes 1 to start
        # with).
        self.series = [QLineSeries(), ]

        # Ranges used for the Y axis (up to 1000, after which we just double
        # the range).
        self.y_ranges = [1, 5, 10, 25, 50, 100, 250, 500, 1000]

        # Set up the chart with sensible defaults.
        self.chart = QChart()
        self.chart.legend().hide()
        self.chart.addSeries(self.series[0])
        self.axis_x = QValueAxis()
        self.axis_y = QValueAxis()
        self.axis_x.setRange(0, self.max_x)
        self.axis_y.setRange(-self.max_y, self.max_y)
        self.axis_x.setLabelFormat("time")
        self.axis_y.setLabelFormat("%d")
        self.chart.setAxisX(self.axis_x, self.series[0])
        self.chart.setAxisY(self.axis_y, self.series[0])
        self.setChart(self.chart)
        self.setRenderHint(QPainter.Antialiasing)
Exemplo n.º 32
0
    def createAreaChart(self):
        chart = QChart()
        chart.setTitle("Area chart")

        # The lower series is initialized to zero values.
        lowerSeries = None
        y_points = []

        for i, data_list in enumerate(self.m_dataTable):
            upperSeries = QLineSeries(chart)
            for j, (value, _) in enumerate(data_list):
                y = value.y()

                if lowerSeries is None:
                    upperSeries.append(QPointF(j, y))
                    y_points.append(y)
                else:
                    new_y = y_points[i] + y
                    upperSeries.append(QPointF(j, new_y))
                    y_points[j] += new_y

            area = QAreaSeries(upperSeries, lowerSeries)
            area.setName("Series " + str(i))
            chart.addSeries(area)
            lowerSeries = upperSeries

        chart.createDefaultAxes()

        return chart
Exemplo n.º 33
0
    def createPieChart(self):
        chart = QChart()
        chart.setTitle("Pie chart")

        pieSize = 1.0 / len(self.m_dataTable)

        for i, data_list in enumerate(self.m_dataTable):
            series = QPieSeries(chart)
            for value, label in data_list:
                slice = series.append(label, value.y())
                if len(series) == 1:
                    slice.setLabelVisible()
                    slice.setExploded()

            hPos = (pieSize / 2) + (i / float(len(self.m_dataTable)))
            series.setPieSize(pieSize)
            series.setHorizontalPosition(hPos)
            series.setVerticalPosition(0.5)

            chart.addSeries(series)

        return chart
Exemplo n.º 34
0
    def createScatterChart(self):
        chart = QChart()
        chart.setTitle("Scatter chart")

        for i, data_list in enumerate(self.m_dataTable):
            series = QScatterSeries(chart)
            for value, _ in data_list:
                series.append(value)

            series.setName("Series " + str(i))
            chart.addSeries(series)

        chart.createDefaultAxes()

        return chart
Exemplo n.º 35
0
    def createBarChart(self, valueCount):
        chart = QChart()
        chart.setTitle("Bar chart")

        series = QStackedBarSeries(chart)

        for i, data_list in enumerate(self.m_dataTable):
            set = QBarSet("Bar set " + str(i))
            for value, _ in data_list:
                set << value.y()

            series.append(set)

        chart.addSeries(series)
        chart.createDefaultAxes()

        return chart
Exemplo n.º 36
0
    def addSeries(
            self, _x2idx: typing.Dict, _idx2x: list, _chart: QChart,
            _axis_x: QValueAxis, _axis_y: QValueAxis
    ):
        series = QLineSeries()
        series.setName(self.name)
        for x, y in zip(self.x_list, self.y_list):
            series.append(_x2idx[x], y)
        if self.color is not None:
            series.setColor(self.color)

        _chart.addSeries(series)
        _chart.setAxisX(_axis_x, series)
        _chart.setAxisY(_axis_y, series)

        if self.show_value:
            self.createShow()
Exemplo n.º 37
0
    def addSeries(
            self, _x2idx: typing.Dict, _idx2x: list, _chart: QChart,
            _axis_x: QValueAxis, _axis_y: QValueAxis
    ):
        bar_set = QBarSet(self.name)
        tmp_dict = dict(zip(self.x_list, self.y_list))
        for k in _idx2x:
            if k in tmp_dict.keys():
                bar_set.append(tmp_dict[k])
            else:
                bar_set.append(0)

        if self.color is not None:
            bar_set.setColor(self.color)

        bar_series = QBarSeries()
        bar_series.append(bar_set)
        _chart.addSeries(bar_series)
        _chart.setAxisX(_axis_x, bar_series)
        _chart.setAxisY(_axis_y, bar_series)

        if self.show_value:
            self.createShow()
Exemplo n.º 38
0
    def addSeries(
            self, _x2idx: typing.Dict, _idx2x: list, _chart: QChart,
            _axis_x: QValueAxis, _axis_y: QValueAxis
    ):
        series = QCandlestickSeries()
        series.setName(self.name)

        for x, y in zip(self.x_list, self.y_list):
            series.append(QCandlestickSet(*y, _x2idx[x]))
        if self.inc_color is not None:
            series.setIncreasingColor(self.inc_color)
        else:
            series.setIncreasingColor(QColor('#c41919'))
        if self.dec_color is not None:
            series.setDecreasingColor(self.dec_color)
        else:
            series.setDecreasingColor(QColor('#009f9f'))

        _chart.addSeries(series)
        _chart.setAxisX(_axis_x, series)
        _chart.setAxisY(_axis_y, series)

        if self.show_value:
            self.createShow()
Exemplo n.º 39
0
class PlotterPane(QChartView):
    """
    This plotter widget makes viewing sensor data easy!

    This widget represents a chart that will look for tuple data from
    the MicroPython REPL, Python 3 REPL or Python 3 code runner and will
    auto-generate a graph.
    """

    data_flood = pyqtSignal()

    def __init__(self, parent=None):
        super().__init__(parent)
        # Holds the raw input to be checked for actionable data to display.
        self.input_buffer = []
        # Holds the raw actionable data detected while plotting.
        self.raw_data = []
        self.setObjectName('plotterpane')
        self.max_x = 100  # Maximum value along x axis
        self.max_y = 1000  # Maximum value +/- along y axis
        self.flooded = False  # Flag to indicate if data flooding is happening.

        # Holds deques for each slot of incoming data (assumes 1 to start with)
        self.data = [deque([0] * self.max_x), ]
        # Holds line series for each slot of incoming data (assumes 1 to start
        # with).
        self.series = [QLineSeries(), ]

        # Ranges used for the Y axis (up to 1000, after which we just double
        # the range).
        self.y_ranges = [1, 5, 10, 25, 50, 100, 250, 500, 1000]

        # Set up the chart with sensible defaults.
        self.chart = QChart()
        self.chart.legend().hide()
        self.chart.addSeries(self.series[0])
        self.axis_x = QValueAxis()
        self.axis_y = QValueAxis()
        self.axis_x.setRange(0, self.max_x)
        self.axis_y.setRange(-self.max_y, self.max_y)
        self.axis_x.setLabelFormat("time")
        self.axis_y.setLabelFormat("%d")
        self.chart.setAxisX(self.axis_x, self.series[0])
        self.chart.setAxisY(self.axis_y, self.series[0])
        self.setChart(self.chart)
        self.setRenderHint(QPainter.Antialiasing)

    def process_bytes(self, data):
        """
        Takes raw bytes and, if a valid tuple is detected, adds the data to
        the plotter.

        The the length of the bytes data > 1024 then a data_flood signal is
        emitted to ensure Mu can take action to remain responsive.
        """
        # Data flooding guards.
        if self.flooded:
            return
        if len(data) > 1024:
            self.flooded = True
            self.data_flood.emit()
            return
        data = data.replace(b'\r\n', b'\n')
        self.input_buffer.append(data)
        # Check if the data contains a Python tuple, containing numbers, on a
        # single line (i.e. ends with \n).
        input_bytes = b''.join(self.input_buffer)
        lines = input_bytes.split(b'\n')
        for line in lines:
            if line.startswith(b'(') and line.endswith(b')'):
                # Candidate tuple. Extract the raw bytes into a numeric tuple.
                raw_values = [val.strip() for val in line[1:-1].split(b',')]
                numeric_values = []
                for raw in raw_values:
                    try:
                        numeric_values.append(int(raw))
                        # It worked, so move onto the next value.
                        continue
                    except ValueError:
                        # Try again as a float.
                        pass
                    try:
                        numeric_values.append(float(raw))
                    except ValueError:
                        # Not an int or float, so ignore this value.
                        continue
                if numeric_values:
                    # There were numeric values in the tuple, so use them!
                    self.add_data(tuple(numeric_values))
        # Reset the input buffer.
        self.input_buffer = []
        if lines[-1]:
            # Append any bytes that are not yet at the end of a line, for
            # processing next time we read data from self.serial.
            self.input_buffer.append(lines[-1])

    def add_data(self, values):
        """
        Given a tuple of values, ensures there are the required number of line
        series, add the data to the line series, update the range of the chart
        so the chart displays nicely.
        """
        # Store incoming data to dump as CSV at the end of the session.
        self.raw_data.append(values)
        # Check the number of incoming values.
        if len(values) != len(self.series):
            # Adjust the number of line series.
            value_len = len(values)
            series_len = len(self.series)
            if value_len > series_len:
                # Add new line series.
                for i in range(value_len - series_len):
                    new_series = QLineSeries()
                    self.chart.addSeries(new_series)
                    self.chart.setAxisX(self.axis_x, new_series)
                    self.chart.setAxisY(self.axis_y, new_series)
                    self.series.append(new_series)
                    self.data.append(deque([0] * self.max_x))
            else:
                # Remove old line series.
                for old_series in self.series[value_len:]:
                    self.chart.removeSeries(old_series)
                self.series = self.series[:value_len]
                self.data = self.data[:value_len]

        # Add the incoming values to the data to be displayed, and compute
        # max range.
        max_ranges = []
        for i, value in enumerate(values):
            self.data[i].appendleft(value)
            max_ranges.append(max([max(self.data[i]), abs(min(self.data[i]))]))
            if len(self.data[i]) > self.max_x:
                self.data[i].pop()

        # Re-scale y-axis.
        max_y_range = max(max_ranges)
        y_range = bisect.bisect_left(self.y_ranges, max_y_range)
        if y_range < len(self.y_ranges):
            self.max_y = self.y_ranges[y_range]
        elif max_y_range > self.max_y:
            self.max_y += self.max_y
        elif max_y_range < self.max_y / 2:
            self.max_y = self.max_y / 2
        self.axis_y.setRange(-self.max_y, self.max_y)

        # Ensure floats are used to label y axis if the range is small.
        if self.max_y <= 5:
            self.axis_y.setLabelFormat("%2.2f")
        else:
            self.axis_y.setLabelFormat("%d")

        # Update the line series with the data.
        for i, line_series in enumerate(self.series):
            line_series.clear()
            xy_vals = []
            for j in range(self.max_x):
                val = self.data[i][self.max_x - 1 - j]
                xy_vals.append((j, val))
            for point in xy_vals:
                line_series.append(*point)

    def set_theme(self, theme):
        """
        Sets the theme / look for the plotter pane.
        """
        if theme == 'day':
            self.chart.setTheme(QChart.ChartThemeLight)
        elif theme == 'night':
            self.chart.setTheme(QChart.ChartThemeDark)
        else:
            self.chart.setTheme(QChart.ChartThemeHighContrast)