I plotted a list into a line series graph. The length of the list may around 4000
- I want to color the values of Y axis in range above 1000 as RED and below as GREEN. Is that possible?
- In order to improve the performance, can i use any alternate instead using FOR loop. since the length is 4000, it is taking more time to plot. Kindly suggest some other instead of FOR loop
import QtQuick 2.9
import QtQuick.Window 2.2
import QtCharts 2.0
import QtQuick.Controls 2.15
Window {
visible: true
width: 640
height: 480
title: qsTr("ADC Chart")
ChartView {
id: chart
anchors.fill: parent
theme: ChartView.ChartThemeBrownSand
antialiasing: true
Component.onCompleted: {
line.clear();
for (let i = 0; i < r_manager.ADC1y.length; ++i) {
line.append(i, r_manager.ADC1y[i]);
}
}
LineSeries {
id: line
name: "ADC1"
axisX: ValueAxis {
titleText: "Sample"
min: 0
max: r_manager.ADC1y.length
}
axisY: ValueAxis {
titleText: "ADC"
min: -400
max: 400
}
}
}
}
- Line series multicolor. Is that possible?
- To improve performance.Kindly suggest some other instead of FOR loop
Draw both a green version and a red version of your chart. Put the red version inside an item and clip it to reveal some of it so that you see a mashup between your green and red chart.
As chart placeholders, I use SVG images, but, feel free to swap it with the actual chart:
You can Try it Online!