chart13 = {
const svg = d3.select(DOM.svg(width + margin.left + margin.right, height + margin.top + margin.bottom));
const pitch = svg.append('g')
.attr('transform', `translate(${margin.left},${margin.right})`)
const tooltip = d3tip()
.style('border', 'solid 3px black')
.style('background-color', 'white')
.style('border-radius', '10px')
.style('float', 'left')
.style('font-family', 'arial')
.html(d => `
Type: ${(typeconvert(d.type))} <br/>
Name: ${selected_player} <br/>
Home/Away: ${d.side} <br/>
xPosition: ${Math.round(d.x)} <br/>
yPosition: ${Math.round(d.y)} <br/>
Pass Distance : ${Math.round(finddistance(d.x,d.to_x,d.y,d.to_y))} <br/>
</div>`)
svg.call(tooltip)
pitch.append('rect')
.attr('x', -margin.left)
.attr('y', -margin.top)
.attr('width', width + margin.left + margin.right)
.attr('height', height + margin.top + margin.bottom)
.style('fill', 'green')
.attr('opacity', 0.7);
svg.append("defs")
.append("marker")
.attr("id", "arrow")
.attr("markerWidth", 10)
.attr("markerHeight", 10)
.attr("refX", 0)
.attr("refY", 3)
.attr("orient", "auto")
.attr("markerUnits", "strokeWidth")
.append("path")
.attr("d", "M0,0 L0,6 L9,3 z")
.attr("fill", "blue");
//arrow
const pitchLineData = getPitchLines;
pitch.selectAll('.pitchLines')
.data(pitchLineData)
.enter().append('line')
.attr('x1', d => d['x1'] * pitchMultiplier)
.attr('x2', d => d['x2'] * pitchMultiplier)
.attr('y1', d => d['y1'] * pitchMultiplier)
.attr('y2', d => d['y2'] * pitchMultiplier)
.style('stroke-width', lineWidth)
//.style('stroke', lineColor);
.style('stroke', 'white');
//all straight line
pitch.selectAll('.pitchLines')
.data(data_matched.filter(function(d){return (d.side == "H") && (d.play_id == selected_player_id) }))
.enter().append('line')
.attr('x1', d => d.x *8.4)
.attr('x2', d => d.to_x *8.4 )
.attr('y1', d => d.y *5.44 )
.attr('y2', d => d.to_y *5.44 )
.style('stroke-width', lineWidth)
.style('stroke', 'red')
.attr('opacity', 0.5)
.attr("marker-end", "url(#arrow)");
pitch.selectAll('.pitchCircles')
.data(data_matched.filter(function(d){return (d.side == "H") && (d.play_id == selected_player_id) }))
.enter().append('circle')
.attr('cx', d => d.x * 8.4)
.attr('cy', d => d.y * 5.44)
.attr('r', d => 8)
.style('stroke-width', lineWidth)
.style('stroke', lineColor)
.style('fill', d => 'SteelBlue')
.attr('opacity', 1)
.on('mouseover', tooltip.show)
.on('mouseout', tooltip.hide);
//type 1 , side = home team
pitch.selectAll('.pitchLines')
.data(data_matched.filter(function(d){return (d.side == "A") && (d.play_id == selected_player_id) }))
.enter().append('line')
.attr('x1', d => d.x *8.4)
.attr('x2', d => d.to_x *8.4 )
.attr('y1', d => d.y *5.44 )
.attr('y2', d => d.to_y *5.44 )
.style('stroke-width', lineWidth)
.style('stroke', 'red')
.attr('opacity', 0.75)
.attr("marker-end", "url(#arrow)");
pitch.selectAll('.pitchCircles')
.data(data_matched.filter(function(d){return (d.side == "A") && (d.play_id == selected_player_id) }))
.enter().append('circle')
.attr('cx', d => d.x * 8.4)
.attr('cy', d => d.y * 5.44)
.attr('r', d => 8)
.style('stroke-width', lineWidth)
.style('stroke', lineColor)
.style('fill', d => 'SteelBlue')
.attr('opacity', 1)
.on('mouseover', tooltip.show)
.on('mouseout', tooltip.hide);
//type 1 , side = away team
const pitchCircleData = getPitchCircles2;
pitch.selectAll('.pitchCircles')
.data(pitchCircleData)
.enter().append('circle')
.attr('cx', d => d['cx'] * pitchMultiplier)
.attr('cy', d => d['cy'] * pitchMultiplier)
.attr('r', d => d['r'] * pitchMultiplier)
.style('stroke-width', lineWidth)
//.style('stroke', lineColor)
.style('fill', d => d['color'])
.style('stroke', 'white');
//circle
const pitchArcData = getArcs;
const arc = d3.arc();
pitch.selectAll('.pitchCorners')
.data(pitchArcData)
.enter().append('path')
.attr('d', d => arc(d['arc']))
.attr('transform', d => `translate(${pitchMultiplier * d.x},${pitchMultiplier * d.y})`)
//.style('fill', lineColor)
.style('stroke', 'white');
//curve
return svg.node();
}