Ajax Tag Save Changes - warwickfoster/qurantools GitHub Wiki

File: app/selection_counts.php

Purpose

The provided PHP code displays a table and chart based on the selection of a single letter or all letters in the Quran. The table shows the occurrences of each letter in Meccan and Medina suras, along with the grand total. The chart visualizes the distribution of letter occurrences.

Functionality

  • The code first checks if the user selected a single letter or all letters.
  • If the user selected a single letter, it displays a table showing the occurrences of that letter in each sura.
  • If the user selected all letters, it displays a table showing the occurrences of each letter in Meccan and Medina suras, along with the grand total.
  • The code also generates a chart that visualizes the distribution of letter occurrences.

Features

  • Table showing letter occurrences in Meccan and Medina suras.
  • Grand total of letter occurrences.
  • Chart visualizing letter distribution.
  • Legends for the chart.

Additional Notes

  • The code uses the number_format() function to format the numbers in the table.
  • The DISPLAY variable controls whether to display the table or chart.
  • The SINGLE_LETTER variable stores the index of the selected letter.
  • The KeyNames array stores the names of the letters.
  • The shownMeccan and shownMedinan variables control whether to display legends for the chart.
  • The code includes a footer.

Example Usage

To display the table for all letters, set SINGLE_LETTER to -1. To display the chart for the letter 'ب', set SINGLE_LETTER to 2.

Conclusion

The provided PHP code provides a comprehensive way to analyze the distribution of letters in the Quran, both individually and collectively.