'use strict' ; import type Legend from './Legend' ; import type LegendItemObject from './LegendItemObject' ; import type Point from '../Series/Point' ; import type Series from '../Series/Series' ; import type SVGAttributes from '../Renderer/SVG/SVGAttributes' ; import U from '../Utilities.js' ; const { merge , pick } = U ; declare module '../Axis/AxisLike' { interface AxisLike extends LegendItemObject { } } declare module '../Series/PointLike' { interface PointLike extends LegendItemObject { } } declare module '../Series/SeriesLike' { interface SeriesLike extends LegendItemObject { drawLegendSymbol : ( typeof LegendSymbol . drawLineMarker | typeof LegendSymbol . drawRectangle ) ; } } namespace LegendSymbol { private function param { Highcharts . Legend } legend export function drawLineMarker ( this , legend ) { const options = this . options , symbolWidth = legend . symbolWidth , symbolHeight = legend . symbolHeight , generalRadius = symbolHeight / 2 , renderer = this . chart . renderer , legendItemGroup = this . legendGroup , verticalCenter = ( legend . baseline as any ) - Math . round ( ( legend . fontMetrics as any ) . b * 0.3 ) ; let attr = { } , legendSymbol , markerOptions = options . marker ; if ( ! this . chart . styledMode ) { attr = { 'stroke-width' : options . lineWidth || 0 } ; if ( options . dashStyle ) { attr . dashstyle = options . dashStyle ; } } this . legendLine = renderer . path ( [ [ 'M' , 0 , verticalCenter ] , [ 'L' , symbolWidth , verticalCenter ] ] ) . addClass ( 'highcharts-graph' ) . attr ( attr ) . add ( legendItemGroup ) ; if ( markerOptions && markerOptions . enabled !== false && symbolWidth ) { let radius = Math . min ( pick ( markerOptions . radius , generalRadius ) , generalRadius ) ; if ( ( this . symbol as any ) . indexOf ( 'url' ) === 0 ) { markerOptions = merge ( markerOptions , { width : symbolHeight , height : symbolHeight } ) ; radius = 0 ; } this . legendSymbol = legendSymbol = renderer . symbol ( this . symbol as any , ( symbolWidth / 2 ) - radius , verticalCenter - radius , 2 * radius , 2 * radius , markerOptions ) . addClass ( 'highcharts-point' ) . add ( legendItemGroup ) ; legendSymbol . isMarker = true ; } } private function param { Highcharts . Legend } legend param { Highcharts . Point | Highcharts . Series } item export function drawRectangle ( this , legend , item ) { const options = legend . options , symbolHeight = legend . symbolHeight , square = options . squareSymbol , symbolWidth = square ? symbolHeight : legend . symbolWidth ; item . legendSymbol = this . chart . renderer . rect ( square ? ( legend . symbolWidth - symbolHeight ) / 2 : 0 , ( legend . baseline as any ) - symbolHeight + 1 , symbolWidth , symbolHeight , pick ( legend . options . symbolRadius , symbolHeight / 2 ) ) . addClass ( 'highcharts-point' ) . attr ( { zIndex : 3 } ) . add ( item . legendGroup ) ; } } export default LegendSymbol ;