Skip to content

CanvasLinePlot's lack of support for color Property #42

Description

@pixelzoom

CanvasLinePlot does not support {Property} stroke because any change to CanvasLinePlot requires calling update for the parent ChartCanvasNode.

In practice, this is causing 2 problems:

(1) I'm constantly forgetting that stroke can't be a Property, and writing code like this that fails an assertion in CanvasLinePlot setStroke:

    const sumPlot = new CanvasLinePlot( this.chartTransform, [], {
      stroke: FMWColors.sumPlotStrokeProperty
    } );

(2) To use a color Property (e.g. a ProfileColorProperty) requires boilerplate like this, which occurs 3x in Fourier:

    const somePlot = new CanvasLinePlot( this.chartTransform, [], {
      stroke: someStrokeProperty.value
    } );

    const someChartCanvasNode = new ChartCanvasNode( this.chartTransform, [ somePlot ] );

    // CanvasLinePlot stroke does not support Property, so handle updates here.
    someStrokeProperty.link( stroke => {
      somePlot.setStroke( stroke );
      someChartCanvasNode.update();
    } );

I don't know how to resolve this, and maybe we don't. But I thought I'd create this issue, and do a little brainstorming, since this API is proving to be a little wonky in practice.

@samreid thoughts?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions