Legend in JQuery PivotChart widget

Legend in JQuery PivotChart widget visibility

You can enable or disable the legend by using the visible property in the legend object. By default, the legend is enabled in the pivot chart.

NOTE

By default, the legend is visible in the pivot chart.

  • javascript
  • $(function()
    {
        $("#PivotChart1").ejPivotChart(
        {
            ....
            legend:
            {
                //Legend Visibility
                visible: true
            },
            ....
        });
    });

    Legend visibility in JavaScript pivot chart control

    Legend in JQuery PivotChart widget shape

    You can customize the legend shape in the pivot chart widget. The default value of legend shape is “Rectangle”. The following are the supported legend shapes:

    • Rectangle
    • Circle
    • Cross
    • Diamond
    • Pentagon
    • Hexagon
    • Star
    • Ellipse
    • Triangle.
  • javascript
  • $("#PivotChart1").ejPivotChart(
        {
            ....
            legend:
            {
                //Legend Visibility
                visible: true,
                //Applying Legend Shape
                shape: "Star"
            },
            ....
        });

    Legend shape in JavaScript pivot chart control

    Legend in JQuery PivotChart widget position

    By using the position property, you can place the legend at top, bottom, left, or right of the pivot chart.

    NOTE

    The default value of the legend position is bottom in the pivot chart.

  • javascript
  • $("#PivotChart1").ejPivotChart(
        {
            ....
            legend:
            {
                //Legend Visibility
                visible: true,
                //To place the legend at top of the Chart
                position: "top"
            },
            ....
        });

    Legend position in JavaScript pivot chart control

    Legend in JQuery PivotChart widget title

    To add a legend title, you should specify the title text in the title.text property.

  • javascript
  • $("#PivotChart1").ejPivotChart(
        {
            ....
            legend:
            {
                //Legend Visibility
                visible: true,
                //Add title to the Chart legend
                title:
                {
                    text: "Countries"
                }
            },
            ....
        });

    Legend title in JavaScript pivot chart control

    Legend in JQuery PivotChart widget alignment

    You can align the legend to center, far, and near based on its position in the chart area by using the alignment .

  • javascript
  • $("#PivotChart1").ejPivotChart(
        {
            ....
            legend:
            {
                //Legend Visibility
                visible: true,
                //Aligning the legend near to the Chart
                alignment: "Near"
            },
            ....
        });

    Legend alignment in JavaScript pivot chart control

    Legend in JQuery PivotChart widget items - size and border

    By using the itemStyle.width, itemStyle.height, and itemStyle.border properties of the legend, you can change the size and border of legend items.

  • javascript
  • $("#PivotChart1").ejPivotChart(
        {
            ....
            legend:
            {
                //Legend Visibility
                visible: true,
                //Changing legend items border, height and width
                itemStyle:
                {
                    height: 12,
                    width: 12,
                    border:
                    {
                        color: 'magenta',
                        width: 1.5
                    }
                }
            },
            ....
        });

    Size and border of legend in JavaScript pivot chart control

    Legend in JQuery PivotChart widget border

    By using the border in the legend, you can customize the color and width of the border.

  • javascript
  • $("#PivotChart1").ejPivotChart(
        {
            ....
            legend:
            {
                //Legend Visibility
                visible: true,
                //Setting border color and width to legend
                border:
                {
                    color: "#FFC342",
                    width: 2
                }
            },
            ....
        });

    Legend border in JavaScript pivot chart control

    Legend in JQuery PivotChart widget text

    By using the font, you can customize the font family, font style, font weight, and size of the legend text.

  • javascript
  • $("#PivotChart1").ejPivotChart(
        {
            ....
            legend:
            {
                //Legend Visibility
                visible: true,
                //Customizing the legend text
                font:
                {
                    fontFamily: 'Segoe UI',
                    fontStyle: 'italic',
                    fontWeight: 'bold',
                    size: '13px'
                },
            },
            ....
        });

    Legend text in JavaScript pivot chart control