Edit Formula Full Gloss - warwickfoster/qurantools GitHub Wiki

File: app/charts/chart_tags.php

Purpose

This PHP script generates a column chart in FusionCharts that displays the number of verses tagged with each tag for a specific user.

Features

  • User authentication
  • Sortable by tag name or number of verses tagged
  • Mini and normal mode options
  • Tooltips and hyperlinks for tagged verses

Code Breakdown

1. Header and Configuration

  • Includes necessary PHP files for configuration, functions, and authentication.
  • Sets the window title.

2. Data Retrieval

  • Queries the database to fetch tag names, colors, lightness values, and the count of verses tagged with each tag.
  • Sorts the data based on the specified sort order.

3. FusionCharts JavaScript

  • Initializes a FusionCharts object with the following configurations:
    • Chart type: Column 2D
    • Data format: JSON
    • Chart dimensions and theme
    • Chart title, subtitle, and axis labels
    • Data points with label, value, color, and hyperlink

4. HTML Structure

  • Creates a HTML structure with the necessary JavaScript and CSS.
  • Displays the chart container, title, and navigation controls.

5. Chart Rendering

  • JavaScript code renders the FusionCharts chart based on the retrieved data.

Usage

  • Accessible through the chart_tags.php URL.
  • Mini mode can be accessed by adding ?VIEW=MINI to the URL.

Output

  • A column chart displaying the number of verses tagged with each tag.
  • Hyperlinks to the tagged verse browser for each tag.

Additional Notes

  • The $miniMode flag determines whether to display the chart in mini or normal mode.
  • The SORT GET parameter specifies the sorting order.
  • The theme attribute in the FusionCharts configuration can be changed to customize the chart theme.