def __init__(self):
        super().__init__()
        # add color area
        self.top_line = QtChart.QLineSeries()
        self.bottom_line = QtChart.QLineSeries()
        self.top_line.setColor(QtGui.QColor(0, 127, 255, 150))
        self.bottom_line.setColor(QtGui.QColor(0, 127, 255, 150))
        self.area = QtChart.QAreaSeries(self.top_line, self.bottom_line)
        self.area.setColor(QtGui.QColor(0, 127, 255, 35))
        self.area.setBorderColor(QtGui.QColor(0, 127, 255, 35))
        self.addSeries(self.area)

        self.fastK = QtChart.QLineSeries()
        self.fastD = QtChart.QLineSeries()
        self.fastK.setColor(QtCore.Qt.magenta)
        self.fastD.setColor(QtCore.Qt.blue)
        self.addSeries(self.fastK)
        self.addSeries(self.fastD)
    def __init__(self):
        super().__init__()
        # add color area
        self.top_line = QtChart.QLineSeries()
        self.bottom_line = QtChart.QLineSeries()
        self.top_line.setColor(QtGui.QColor(0, 127, 255, 100))
        self.bottom_line.setColor(QtGui.QColor(0, 127, 255, 100))
        self.area = QtChart.QAreaSeries(self.top_line, self.bottom_line)
        self.area.setColor(QtGui.QColor(0, 127, 255, 30))
        self.area.setBorderColor(QtGui.QColor(0, 127, 255, 30))
        self.addSeries(self.area)

        self.cci = QtChart.QLineSeries()
        pen = QtGui.QPen(QtCore.Qt.SolidLine)
        pen.setWidthF(0.75)
        pen.setColor(QtCore.Qt.magenta)
        self.cci.setPen(pen)
        self.addSeries(self.cci)
示例#3
0
 def __init__(self,
              widget,
              unit_system,
              area=False,
              series_count=1,
              **kwargs):
     """Add a line chart to widget."""
     seriess = []
     for _ in range(series_count):
         series = QtChart.QLineSeries()
         if area:
             area = QtChart.QAreaSeries()
             area.setUpperSeries(series)
             # Save series so it doesn't get garbage collected
             series_gc_prevent.append(series)
             series = area
         seriess.append(series)
     super().__init__(seriess, widget, unit_system, **kwargs)
示例#4
0
    def __init__(self):
        super().__init__()
        # add color area
        self.top_line = QtChart.QLineSeries()
        self.bottom_line = QtChart.QLineSeries()
        self.top_line.setColor(QtGui.QColor(0, 102, 85, 150))
        self.bottom_line.setColor(QtGui.QColor(0, 102, 85, 150))
        self.area = QtChart.QAreaSeries(self.top_line, self.bottom_line)
        self.area.setColor(QtGui.QColor(0, 102, 85, 60))
        self.area.setBorderColor(QtGui.QColor(0, 102, 85, 60))
        self.addSeries(self.area)

        self.index_line = QtChart.QLineSeries()
        pen = QtGui.QPen(QtCore.Qt.SolidLine)
        pen.setWidthF(0.75)
        pen.setColor(QtCore.Qt.green)
        self.index_line.setPen(pen)
        self.addSeries(self.index_line)
示例#5
0
    def __init__(self,
                 parent,
                 value_label_format="%i",
                 date_time_format="hh:mm"):
        super().__init__(parent)

        self.chart = QtChart.QChart()
        self.chart.setTheme(QtChart.QChart.ChartThemeDark)
        self.chart.setMargins(QtCore.QMargins(0, 0, 0, 0))
        self.chart.setBackgroundVisible(False)
        self.chart.legend().hide()

        self.value_series = QtChart.QLineSeries()
        self.lower_series = QtChart.QLineSeries()
        area_series = QtChart.QAreaSeries(self.value_series, self.lower_series)
        self.chart.addSeries(area_series)

        axis_x = QtChart.QDateTimeAxis()
        axis_x.setFormat(date_time_format)
        axis_x.setTitleText("Time")
        self.chart.addAxis(axis_x, QtCore.Qt.AlignBottom)
        area_series.attachAxis(axis_x)

        axis_y = QtChart.QValueAxis()
        axis_y.setLabelFormat(value_label_format)
        axis_y.setTitleText("Value")
        self.chart.addAxis(axis_y, QtCore.Qt.AlignLeft)
        area_series.attachAxis(axis_y)

        self.chart_view = QtChart.QChartView(self.chart)
        self.chart_view.setRenderHint(QtGui.QPainter.Antialiasing)

        layout = QtWidgets.QVBoxLayout()
        layout.addWidget(self.chart_view)
        self.setLayout(layout)

        self.resize(800, 500)
示例#6
0
    def __init__(self, weather_points: List[Weather], settings, main_ui):
        QtWidgets.QWidget.__init__(self)

        # set up  window style and size
        # frameless modal window fullscreen (same as main ui)
        self.setWindowFlags(Qt.WindowType(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint))
        self.setWindowModality(Qt.WindowModal)
        self.setGeometry(main_ui.geometry())

        # create series from weather points
        series = QtChart.QLineSeries(self)
        self._weather_points = weather_points

        # sort weather points dataset?

        for point in weather_points:
            series.append(QtCore.QPointF(point.date_time.timestamp() * 1000, point.temp))

        self.begin_hour = (min([point.date_time for point in weather_points])).timestamp() * 1000
        self.end_hour = (max([point.date_time for point in weather_points])).timestamp() * 1000
        # get min and max temp
        min_temp = min([point.temp for point in weather_points])
        max_temp = max([point.temp for point in weather_points])

        # start displaying from -20 - so that the icons have enough space
        begin_temp = min_temp - 20

        # this is a dummy which marks the bottom of the areas series - so we can color the whole thing
        series_dummy = QtChart.QLineSeries(self)
        series_dummy.append(self.begin_hour, begin_temp)
        series_dummy.append(self.end_hour, begin_temp)

        area = QtChart.QAreaSeries(series, series_dummy)
        area.setBrush(QtGui.QColor(self.AREA_COLOR))

        # init a generic font
        font = QtGui.QFont()
        font.setPixelSize(16)

        # PointLabels do not work on area - we need to draw both
        series.setPointLabelsVisible(True)
        series.setPointLabelsColor(Qt.white)
        series.setPointLabelsFont(font)
        series.setPointLabelsFormat("@yPoint")
        series.setPointLabelsClipping(True)

        # draw a dashed line at the first tick of y axis
        pen = QtGui.QPen(Qt.DashLine)
        pen.setColor(Qt.white)
        pen.setStyle(Qt.DashLine)
        dashed_line_series = QtChart.QLineSeries(self)  # QSplineSeries()
        dashed_line_series.setPen(pen)
        self.first_tick = round((max_temp - round(begin_temp)) / (5 - 1) +
                                round(begin_temp), 1)  # chart.axisY().tickCount()

        dashed_line_series.append(QtCore.QPointF(self.begin_hour, self.first_tick))
        dashed_line_series.append(QtCore.QPointF(self.end_hour, self.first_tick))

        # chart setup
        chart = QtChart.QChart()
        self._chart = chart
        chart.addSeries(series)
        chart.addSeries(area)
        chart.addSeries(dashed_line_series)

        # visual style
        chart.legend().setVisible(False)
        chart.setTitle(f"{settings.get(LOCATION)} " +
                       common.get_localized_date(weather_points[0].date_time, settings))
        font.setPixelSize(24)
        chart.setTitleFont(font)

        # chart axis
        chart.createDefaultAxes()
        chart.axisY().setTitleText("Temperature [Celsius]")
        chart.axisY().setGridLineVisible(False)
        chart.axisY().setVisible(False)
        chart.axisY().setLineVisible(False)

        chart.axisY(series).setRange(begin_temp, round(max_temp) + 5)

        chart.axisX().setRange(self.begin_hour - 1800000, self.end_hour + 1800000)
        axisX = QtChart.QDateTimeAxis()
        axisX.setFormat("h:mm")
        chart.setAxisX(axisX, series)
        chart.axisX().setGridLineVisible(False)

        # gradient for background
        gradient = QtGui.QLinearGradient(0, 0, 0, self.height())
        gradient.setColorAt(0, QtGui.QColor(13, 119, 167))  # light blue
        gradient.setColorAt(1, QtGui.QColor(115, 158, 201))  # lighetr blue
        pen = QtGui.QPen()
        pen.setColor(QtGui.QColor(Qt.transparent))
        brush = QtGui.QBrush(gradient)
        brush.setStyle(Qt.LinearGradientPattern)
        chart.setBackgroundBrush(brush)
        geo = main_ui.geometry()
        chart.setGeometry(geo.x(), geo.y(), SCREEN_WIDTH, SCREEN_HEIGHT)

        # display on a chart view
        chart_view = QtChart.QChartView(chart)
        self._chart_view = chart_view
        chart_view.setRenderHint(QtGui.QPainter.Antialiasing)
        chart_view.setSizeAdjustPolicy(QtChart.QChartView.AdjustToContents)

        # Button to close
        ok_button = QtWidgets.QPushButton("OK", self)
        ok_button.clicked.connect(self.close)

        self._layout = QtWidgets.QVBoxLayout(self)
        self._layout.setGeometry(geo)
        self._layout.setSizeConstraint(QtWidgets.QLayout.SetMinAndMaxSize)

        self._layout.addWidget(chart_view)
        self._layout.addWidget(ok_button)

        self.installEventFilter(self)