Łukasz Rzeszotarski
Łukasz Rzeszotarski

Reputation: 6130

JFreeChart - ChartFactory.createXYStepChart with to-concept

By default XYStepChart in JFreeChart implements "from concept" what means that if we have following data: (1,4), (2,5) the step chart is drawn like this:

  1. horizontal line from x=1 to x=2 with y=4
  2. vertical line in x=2 (to value y=5).

I would like to draw those data on the step chart with "to concept" what means:

  1. horizontal line from x=0 to x=1 with y=4
  2. vertical line in x=1 (to value y=5)
  3. horizontal line from x=1 to x=2 with y=5

Does JFreeChart support such concept by default or I would have to implement it by myself (by modyfying input data for example)?

Maybe you know another Java charting library which supports mentioned to concept?

Upvotes: 0

Views: 337

Answers (1)

David Gilbert
David Gilbert

Reputation: 4477

You can get close to what you are looking for by using the setStepPoint() method in the XYStepRenderer class. This attribute is a value in the range from 0.0 to 1.0, with the default being 1.0. When making the transition between two points (x0, y0) and (x1, y1), at some point a vertical move needs to be made from y0 to y1. The stepPoint determines where, in the range from x0 to x1, the vertical transition will be made. If stepPoint == 1.0 (the default), the vertical transition is made at x1. If stepPoint == 0.0, the vertical transition is made at x0. If stepPoint is some value in between (say 0.5) then the vertical transition is made at that fractional point along the range (x0, x1).

Upvotes: 2

Related Questions