jQuery UI Widgets Forums Chart Any open-source examples demonstrating: Chart?

This topic contains 1 reply, has 2 voices, and was last updated by  admin 1 week, 1 day ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author

  • vitorio
    Participant

    How can I customize jqxChart’s tooltip template in Angular to show additional data details?


    admin
    Keymaster

    Hi,

    For this purpose, the toolTipFormatFunction of the Chart can be used.

    
    export class AppComponent {
      source: any[] = [
        { year: 2020, value: 100, detail: 'Project A completed' },
        { year: 2021, value: 120, detail: 'Project B completed' },
        { year: 2022, value: 90, detail: 'Project C delayed' }
      ];
    
      dataAdapter: any;
    
      constructor() {
        this.dataAdapter = new jqx.dataAdapter({
          localData: this.source,
          dataType: 'json'
        });
      }
    
      // Custom tooltip function
      toolTipFormatFn = (value: any, itemIndex: number, serie: any, group: any, categoryValue: any, categoryAxis: any) => {
        const record = this.source[itemIndex];
        return 
    Year: ${record.year}
    Value: ${record.value}
    Details: ${record.detail}

    `;
    };
    }

    jqxChart
    [width]=”600″
    [height]=”400″
    [source]=”dataAdapter”
    [xAxis]=”{ dataField: ‘year’, type: ‘basic’ }”
    [seriesGroups]=”[{
    type: ‘column’,
    series: [{ dataField: ‘value’, displayText: ‘Value’,
    toolTipFormatFunction: toolTipFormatFn }]
    }]”>
    `

    toolTipFormatFunction allows you to override the default tooltip content.

    It receives multiple parameters:

    value → the value of the point
    itemIndex → index of the data point in your array
    serie → series object
    group → series group
    categoryValue → the category value (x-axis)
    categoryAxis → category axis object

    You can use itemIndex to pull additional details from your source array and display them in HTML format.

    jqxChart renders this as the tooltip, so you can include bold text, line breaks, or any HTML content.

    Best regards,
    Peter

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.