#39 LineChart shape cannot be null

open
None
5
2004-10-18
2004-09-15
MoMaT
No

The following code from userGuide 0.3.0, true for 0.7.5
is no longer valid for 1.0.0-alpha-1 if the legend is used:

Shape[] shapes= { PointChartProperties.SHAPE_CIRCLE,
null };
LineChartProperties lineChartProperties= new
LineChartProperties( strokes, shapes );

Giving the one of shapes array shape value of null (to
render a flat line without any triangles, circles or
such) and setting the legend visible, makes the chart
impossible to render:
java.lang.NullPointerException
at org.krysalis.jcharts.Legend.render(Unknown Source)

I quess the new way of rendering the lineChart icon in
a legend (line+shape instead of box) is the cause of
this, since it is probably not null protected.

Discussion

  • Logged In: YES
    user_id=118938

    Yeah, i see the legend wants to have a Shape in there. I
    will make a fix for this.

     
    • assigned_to: nobody --> nathaniel_auvil
     
  • Logged In: YES
    user_id=118938

    A work-around for this would be to just use a shape and make
    the Paint transparent.

     
  • Logged In: YES
    user_id=118938

    Half way to having a fix to this.

     
  • MoMaT
    MoMaT
    2004-10-22

    Logged In: YES
    user_id=829758

    I've applied such a temporary patch in Legend.java line 506:
    >>
    if( this.shapes.size() > 0 && this.shapes.size() >
    labelIndex )
    <<
    if( chartType != ChartType.LINE && this.shapes.size() > 0
    && this.shapes.size() > labelIndex )

    It preserves v.0.7 legend behaviour.

    BTW, doesn't making the paint transparent prevent the line
    from being drawn?

     
  • Logged In: YES
    user_id=118938

    shit, you are right. I was getting mixed up with the Point
    Chart and how you have a fill Paint and an Outling Paint.

     
  • Logged In: YES
    user_id=118938

    sigh...

    This legend code is completely broken. The code people
    added to draw the line icons is just wrong. I am going to
    have to rewrite the code.

     
  • Logged In: NO

    can you plz look into this?