Let's determine the electric potential of a line of charge. The line of charge has total charge \(q\) and length \(2l\) along y-axis as shown in Figure 1. We determine the electric potential on the x-axis at point \(p\) at a distance \(x\) from the origin. Note that the middle point of the line of charge is at the origin our coordinate system.

Figure 1 Electric potential of a line of charge at a perpendicular distance from the mid-point of the line of charge.

Consider a small element of charge \(dq\) at \(y\) which has length of \(dy\). The linear charge density is the charge per unit length and therefore \(dq/dy = q/2l\) which implies \(dq = (q/2l)dy\). The charge \(dq\) is at distance \(\sqrt {{x^2} + {y^2}}\) from the point \(p\). To find the electric potential due to the line of charge we integrate the small electric potential \(dV\) due to the charge \(dq\) from \(-l\) to \(l\). The electric potential at the point \(p\) due to the element charge \(dq\) is,

\[dV = k\frac{{dq}}{{\sqrt {{x^2} + {y^2}} }} = k\frac{q}{{2l}}\frac{{dy}}{{\sqrt {{x^2} + {y^2}} }}\]

Now we integrate \(dV\) from \(-l\) to \(l\) to get the total electric potential due to the line of charge:

\[V = k\frac{q}{{2l}}\int_{ - l}^l {\frac{{dy}}{{\sqrt {{x^2} + {y^2}} }}} = k\frac{q}{{2l}}\ln \left( {\frac{{\sqrt {{l^2} + {x^2}} + l}}{{\sqrt {{l^2} + {x^2}} - l}}} \right)\]

Note that electric potential is a scalar quantity so we don't need to take the account of any components of electric potential.