带有SplineSeries的{QML AreaSeries

时间:2017-12-19 08:48:35

标签: qml

我正在检查docs of AreaSeries, especialy its upperSeries property,很明显它只接受LineSeries个对象。但是,我想使用AreaSeries构建SplineSeries,如果我这样做的话:

ChartView
{
    Layout.fillWidth: true
    Layout.fillHeight: true

    antialiasing: true

    titleColor: "steelblue"

    title: qsTr("Sensor data")

    theme: ChartView.ChartThemeDark

    animationOptions: ChartView.AllAnimations

    dropShadowEnabled: true

    AreaSeries
    {
        name: qsTr("Air pressure [kPa]")

        color: "green"

        borderColor: "white"
        borderWidth: 4

        brushFilename: "qrc:/icons/UeGradient.svg"

        pointLabelsVisible: true

        axisX: DateTimeAxis
        {
            id: ueDateTimeAxisAirPressure

            format: "dd.MM.yyyy"

            min: ueSensorsData.ueGetMinimalDate()
            max: ueSensorsData.ueGetMaximalDate()
        }   // DateTimeAxis

        axisY: ValueAxis
        {
            id: ueAirpressureAxis

            min: ueSensorsData.ueGetMinimalAirPressure()
            max: ueSensorsData.ueGetMaximalAirPressure()
        }   // axisY

        upperSeries: SplineSeries
        {
            id: ueLineSeriesAirPressure

            Connections
            {
                target: ueSensorsData

                onUeSignalUpdateGraph:
                {
                    var valueX=ueSensorsData.ueGetLastTimeStamp();
                    var valueY=ueSensorsData.ueGetLastAirPressure();

                    ueLineSeriesAirPressure.append(valueX,
                                                   valueY);

                    ueDateTimeAxisAirPressure.min=ueSensorsData.ueGetMinimalDate();
                    ueDateTimeAxisAirPressure.max=ueSensorsData.ueGetMaximalDate();

                    ueAirpressureAxis.min=ueSensorsData.ueGetMinimalAirPressure();
                    ueAirpressureAxis.max=ueSensorsData.ueGetMaximalAirPressure();
                }   // onUeSignalUpdateGraph
            }   // Connections
        }   // upperSeries
    }   // AreaSeries
}   // ChartView

我收到以下错误:

QQmlApplicationEngine failed to load component
qrc:/main.qml:304 Cannot assign object to property

并且错误指向有问题的代码行upperSeries: SplineSeries。 是否有可能使用其他方法来完成这项任务,我还没有在网上找到它。

0 个答案:

没有答案