mirror of
https://github.com/morrisjs/morris.js.git
synced 2024-11-10 21:36:34 +01:00
pointSizes accepts an array of value, one per serie
This commit is contained in:
parent
b98ae8ab1d
commit
ace9fafaa6
@ -7,8 +7,11 @@ class Morris.Line extends Morris.Grid
|
|||||||
|
|
||||||
init: ->
|
init: ->
|
||||||
# Some instance variables for later
|
# Some instance variables for later
|
||||||
@pointGrow = Raphael.animation r: @options.pointSize + 3, 25, 'linear'
|
@pointGrow = []
|
||||||
@pointShrink = Raphael.animation r: @options.pointSize, 25, 'linear'
|
@pointShrink = []
|
||||||
|
for pointSize in @options.pointSizes
|
||||||
|
@pointGrow.push Raphael.animation r: pointSize + 3, 25, 'linear'
|
||||||
|
@pointShrink.push Raphael.animation r: pointSize, 25, 'linear'
|
||||||
|
|
||||||
if @options.hideHover isnt 'always'
|
if @options.hideHover isnt 'always'
|
||||||
@hover = new Morris.Hover(parent: @el)
|
@hover = new Morris.Hover(parent: @el)
|
||||||
@ -20,7 +23,7 @@ class Morris.Line extends Morris.Grid
|
|||||||
#
|
#
|
||||||
defaults:
|
defaults:
|
||||||
lineWidth: 3
|
lineWidth: 3
|
||||||
pointSize: 4
|
pointSizes: [4]
|
||||||
lineColors: [
|
lineColors: [
|
||||||
'#0b62a4'
|
'#0b62a4'
|
||||||
'#7A92A3'
|
'#7A92A3'
|
||||||
@ -198,7 +201,7 @@ class Morris.Line extends Morris.Grid
|
|||||||
for row in @data
|
for row in @data
|
||||||
circle = null
|
circle = null
|
||||||
if row._y[index]?
|
if row._y[index]?
|
||||||
circle = @drawLinePoint(row._x, row._y[index], @options.pointSize, @colorFor(row, index, 'point'), index)
|
circle = @drawLinePoint(row._x, row._y[index], @options.pointSizes[index % @options.pointSizes.length], @colorFor(row, index, 'point'), index)
|
||||||
@seriesPoints[index].push(circle)
|
@seriesPoints[index].push(circle)
|
||||||
|
|
||||||
_drawLineFor: (index) ->
|
_drawLineFor: (index) ->
|
||||||
@ -259,11 +262,11 @@ class Morris.Line extends Morris.Grid
|
|||||||
if @prevHilight isnt null and @prevHilight isnt index
|
if @prevHilight isnt null and @prevHilight isnt index
|
||||||
for i in [0..@seriesPoints.length-1]
|
for i in [0..@seriesPoints.length-1]
|
||||||
if @seriesPoints[i][@prevHilight]
|
if @seriesPoints[i][@prevHilight]
|
||||||
@seriesPoints[i][@prevHilight].animate @pointShrink
|
@seriesPoints[i][@prevHilight].animate @pointShrink[i]
|
||||||
if index isnt null and @prevHilight isnt index
|
if index isnt null and @prevHilight isnt index
|
||||||
for i in [0..@seriesPoints.length-1]
|
for i in [0..@seriesPoints.length-1]
|
||||||
if @seriesPoints[i][index]
|
if @seriesPoints[i][index]
|
||||||
@seriesPoints[i][index].animate @pointGrow
|
@seriesPoints[i][index].animate @pointGrow[i]
|
||||||
@prevHilight = index
|
@prevHilight = index
|
||||||
|
|
||||||
colorFor: (row, sidx, type) ->
|
colorFor: (row, sidx, type) ->
|
||||||
|
@ -181,6 +181,7 @@ describe 'Morris.Line', ->
|
|||||||
gridStrokeWidth: 0.5
|
gridStrokeWidth: 0.5
|
||||||
gridTextColor: '#888'
|
gridTextColor: '#888'
|
||||||
gridTextSize: 12
|
gridTextSize: 12
|
||||||
|
pointSizes: [5]
|
||||||
|
|
||||||
it 'should have circles with configured fill color', ->
|
it 'should have circles with configured fill color', ->
|
||||||
chart = Morris.Line $.extend {}, defaults
|
chart = Morris.Line $.extend {}, defaults
|
||||||
@ -205,3 +206,7 @@ describe 'Morris.Line', ->
|
|||||||
it 'should have text with configured font size', ->
|
it 'should have text with configured font size', ->
|
||||||
chart = Morris.Line $.extend {}, defaults
|
chart = Morris.Line $.extend {}, defaults
|
||||||
$('#graph').find("text[fill='#888888']").size().should.equal 9
|
$('#graph').find("text[fill='#888888']").size().should.equal 9
|
||||||
|
|
||||||
|
it 'should have circle with configured size', ->
|
||||||
|
chart = Morris.Line $.extend {}, defaults
|
||||||
|
$('#graph').find("circle[r='5']").size().should.equal 2
|
||||||
|
Loading…
Reference in New Issue
Block a user