Giter Site home page Giter Site logo

fair-acc / chart-qt Goto Github PK

View Code? Open in Web Editor NEW
5.0 7.0 0.0 223 KB

ChartQt is a charting library written in C++ focusing on performance. It uses the Qt libraries but has a dedicated rendering system running on top of QtQuick which gives it great performance and a wide platform support, being able to use any of the 3D rendering APIs OpenGL, Vulkan, Direct3D and Metal. Still in early development.

CMake 6.70% C++ 85.80% QML 5.83% GLSL 1.67%
data-visualization scientific-visualization charting-library qt qt6 qtquick rhi cpp shader

chart-qt's Introduction

ChartQt

โ— ChartQt is still in a very early phase of its development. There are still many rough edges, missing functionalities and bugs.

ChartQt is a charting library written in C++ focusing on performance. It uses the Qt libraries but has a dedicated rendering system running on top of QtQuick which gives it great performance and a wide platform support, being able to use any of the 3D rendering APIs OpenGL, Vulkan, Direct3D and Metal.

Building

ChartQt can be built like any other CMake-based project:

$ git clone https://github.com/fair-acc/chart-qt.git
$ cd chart-qt
$ mkdir build
$ cd build
$ cmake ..
$ cmake --build .

Usage

ChartQt is written in C++ but it can also be used by a QML application:

import QtQuick.Controls 2.3
import ChartQt 1.0
import QtQuick 2.0

ApplicationWindow {
    visible: true
    width: 1980
    height: 450

    menuBar: MenuBar {
        Menu {
            title: qsTr("File")
            Action {
                text: "foo"
            }
        }
    }

    header: ToolBar {
        ToolButton {
            text: chart.paused ? "Resume" : "Pause"
            onClicked: chart.paused = !chart.paused
        }
    }

    SinDataSet
    {
        id: sinDataSet
    }

    ChartLayout {
        anchors.top: parent.top
        anchors.left: parent.left
        anchors.right: parent.right
        anchors.bottom: parent.bottom
        orientation: Qt.Vertical

        ChartItem {
            id: chart
            clip: true

            DefaultZoomHandler {}

            XYPlot {
                id: xy
                xAxis: bottomAxis
                yAxis: leftAxis
                dataSet: sinDataSet
            }

            Axis {
                id: bottomAxis
                position: Axis.Bottom
                max: 10
            }

            Axis {
                id: leftAxis
                position: Axis.Left
                min: -1
                max: 1
            }

            Axis {
                id: leftAxis1
                position: Axis.Left
                min: 0
                max: 10
            }

            MouseArea {
                id: topHandle
                width: 20
                height: 10
                anchors.right: parent.right
                y: parent.height * 0.2 - height / 2
                cursorShape: Qt.SizeVerCursor

                property real pressY
                onPressed: (mouse) => pressY = mouse.y
                onPositionChanged: (mouse) => {
                    y += mouse.y - pressY
                }
            }

            MouseArea {
                id: bottomHandle
                width: 20
                anchors.right: parent.right
                cursorShape: Qt.SizeVerCursor
                y: parent.height * 0.8 - height / 2
                height: 10

                property real pressY
                onPressed: (mouse) => pressY = mouse.y
                onPositionChanged: (mouse) => {
                    y += mouse.y - pressY
                }
            }

            Rectangle {
                anchors.right: parent.right
                width: 20
                anchors.top: topHandle.verticalCenter
                anchors.bottom: bottomHandle.verticalCenter


                gradient: Gradient {
                    GradientStop { position: 0.0; color: "green" }
                    GradientStop { position: 1.0; color: "red" }
                }
            }
        }
        ChartItem {
            id: waterfall

            Component.onCompleted: waterfall.addAxis(bottomAxis)
                Axis {
                position: Axis.Right
                min: 0
                max: 10
            }

            WaterfallPlot {
                id: wf

                gradientStart: 1 - (bottomHandle.y + bottomHandle.height / 2) / chart.height
                gradientStop: 1 - (topHandle.y + topHandle.height / 2) / chart.height

                xAxis: bottomAxis
                dataSet: sinDataSet
            }
        }
    }
}

This code will produce this output:

simple ChartQt example

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.