Sha256: 2171cf5bdd507612e15213893b5206b67329d762b615f3c99f9db45ea2ccc303

Contents?: true

Size: 1.26 KB

Versions: 8

Compression:

Stored size: 1.26 KB

Contents

Rev.registerComponent 'LineChart',
  propTypes:
    data: React.PropTypes.array.isRequired
    options: React.PropTypes.object
    width: React.PropTypes.number
    height: React.PropTypes.number
    title: React.PropTypes.string

  getDefaultProps: ->
    title: "Line Chart"
    width: 300
    height: 300

  componentDidMount: ->
    ctx = @refs.canvas.getDOMNode().getContext('2d')
    @_chart = @renderChart(ctx)

  componentWillUnmount: ->
    @_chart.destroy()

  renderChart: (ctx) ->
    new Chart(ctx).Line(@props.data, @getDefaultOptions())

  getDefaultOptions: ->
    defaultOptions =
      scaleShowGridLines : true
      scaleGridLineColor : "rgba(0,0,0,.05)"
      scaleGridLineWidth : 1
      scaleShowHorizontalLines: true
      scaleShowVerticalLines: false
      bezierCurve : false
      bezierCurveTension : 0.4
      pointDot : true
      pointDotRadius : 4
      pointDotStrokeWidth : 1
      pointHitDetectionRadius : 20
      datasetStroke : true
      datasetStrokeWidth : 2
      datasetFill : false

    defaultOptions = Object.assign(defaultOptions, @props.options)

  render: ->
    <div>
      <h3 className="ChartTitle">{ @props.title }</h3>
      <canvas
        ref="canvas"
        width={ @props.width }
        height={ @props.height }
      />
    </div>

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
revelry_core-0.1.12.6 app/assets/javascripts/revelry/ui/charts/LineChart.js.cjsx
revelry_core-0.1.12.5 app/assets/javascripts/revelry/ui/charts/LineChart.js.cjsx
revelry_core-0.1.12.4 app/assets/javascripts/revelry/ui/charts/LineChart.js.cjsx
revelry_core-0.1.12.3 app/assets/javascripts/revelry/ui/charts/LineChart.js.cjsx
revelry_core-0.1.12.2 app/assets/javascripts/revelry/ui/charts/LineChart.js.cjsx
revelry_core-0.1.12.0 app/assets/javascripts/revelry/ui/charts/LineChart.js.cjsx
revelry_core-0.1.11.6 app/assets/javascripts/revelry/ui/charts/LineChart.js.cjsx
revelry_core-0.1.11.5 app/assets/javascripts/revelry/ui/charts/LineChart.js.cjsx