QCustomPlot Discussion and Comments

lsImpulse style but not to the zero-value-lineReturn to overview

given points (1, 4), (2,-8), (3, -2) for a graph(0)

with the setLineStyle(QCPGraph::lsImpulse) on a graph, the line are drawn from the data point to the zero-value-line. So some lines go up from 0 and other go down from 0.

I don't want that. I want the lines to be drawn to a different value-line. In my example of data points, I would want the line to be drawn down to -10 line. So it would appear that all the data point lines are going up from the -10 value line (y = -10).

This is the expected visual behavior of a graph my clients want. I inverted the axis, but that wasn't correct display (it put 4 on the bottom and -8 at top).

(1) Is there a way to change where the line is drawn to (instead of the zero-value-line)?

(2) Or is there a way to channel fill with lines between 2 graphs (graph(0) is the one above, and graph(1) is a solid line at -10 value)?

For anybody needing reference, I have solved this display problem.

I added a new line style to the header file (lsImpulseZeek), a new var (int mValueLine), and an overriden setLineStyle that took both the line style and valueLine.

Then, in dataToImpulseLines() I check if it's the new lineStyle and sets a valueLine to the what the user set earlier, or 0 (zero) the original coded value.

int valueLine = (mLineStyle == lsImpulseZeek) ? mValueLine : 0;

I use that valueLine value in the for loop where it transforms points to pixels.


Additional coding to make it all work together:
* Wherever you see lsImpulse, you must also add lsImpulseZeek


if (mLineStyle == lsImpulse) ==> 
if (mLineStyle == lsImpulse || if (mLineStyle == lsImpulseZeek) )

in getLines(), the switch statement needs a new case lsImpulseZeek:

case lsImpulseZeek: *lines = dataToImpulseLines(lineData); break;

You could also use a fake visible axis showing the real values range and plot a graph with shifted values and associated with an invisible axis.

Giving your example with an offset of 10

real data values : (1,4), (2,-8), (3,-2)
data set to graph : (1,14), (2,2), (3,8)
yAxis1 visible - range [-10,10]
yAxis2 invisible - range [0,20]

You don't need to modifiy QCP.