This question is admittedly a little odd, and convoluted.
Let me start by acknowledging that it does not actually make sense to use a scatter/line/spline chart when there is no inherent relationship between y and x (i.e., y cannot reasonably be construed to be a function of x).
The non-scientific reality is that many people simply want to see a trend line. Consider the case wherein a measurement is collected every day, and we are interested in charting monthly averages. The x axis is the month, and the y axis is the average value. Clearly, this is best modelled with a BarSet because of the nature of the data (and this becomes clear when we consider that we prefer "Sept" over 9 on the x axis). But the Powers That Be are insisting on a trend line. The problem is that a LineSeries is composed of one or more instances of XYSeries, and XYSeries consists of two real numbers (x and y).
Can this be done using the QtChart module? If so, how might I go about it? Any insights are appreciated.
(I'll update (and hopefully answer!) this question as I go along, but figured I'd get things rolling on this front.)
Update:
Before:
BarSeries {
id: barSeries
axisX: BarCategoryAxis { categories: dummyData.months }
BarSet {
id: appetiteBars
label: "Appetite"
values: dummyData.appetite
}
}
BarSeries {
id: barSeries
axisX: BarCategoryAxis { categories: dummyData.months }
BarSet {
id: appetiteBars
label: "Appetite"
values: dummyData.appetite
}
}
To copy to clipboard, switch view to plain text mode
After:
LineSeries {
id: lineSeries
axisX: BarCategoryAxis { categories: dummyData.months }
XYPoint { x: 0; y: dummyData.appetite[0] }
XYPoint { x: 1; y: dummyData.appetite[1] }
XYPoint { x: 2; y: dummyData.appetite[2] }
XYPoint { x: 3; y: dummyData.appetite[3] }
XYPoint { x: 4; y: dummyData.appetite[4] }
XYPoint { x: 5; y: dummyData.appetite[5] }
}
LineSeries {
id: lineSeries
axisX: BarCategoryAxis { categories: dummyData.months }
XYPoint { x: 0; y: dummyData.appetite[0] }
XYPoint { x: 1; y: dummyData.appetite[1] }
XYPoint { x: 2; y: dummyData.appetite[2] }
XYPoint { x: 3; y: dummyData.appetite[3] }
XYPoint { x: 4; y: dummyData.appetite[4] }
XYPoint { x: 5; y: dummyData.appetite[5] }
}
To copy to clipboard, switch view to plain text mode
My brain still rebels against doing this, and it's much more cumbersome to implement as a line series (i.e., per value, rather than dumping the whole array into a BarSet) but it works...
Bookmarks