# graph_gui.cpp File Reference

`#include "stdafx.h"`
`#include "openttd.h"`
`#include "gui.h"`
`#include "window_gui.h"`
`#include "player_base.h"`
`#include "player_gui.h"`
`#include "economy_func.h"`
`#include "variables.h"`
`#include "cargotype.h"`
`#include "strings_func.h"`
`#include "core/alloc_func.hpp"`
`#include "window_func.h"`
`#include "date_func.h"`
`#include "gfx_func.h"`
`#include "table/strings.h"`
`#include "table/sprites.h"`

Go to the source code of this file.

## Data Structures

struct | GraphDrawer

## Enumerations

enum | { GRAPH_MAX_DATASETS = 32, GRAPH_AXIS_LABEL_COLOUR = TC_BLACK, GRAPH_AXIS_LINE_COLOUR = 215, GRAPH_X_POSITION_BEGINNING = 44, GRAPH_X_POSITION_SEPARATION = 22, GRAPH_NUM_LINES_Y = 9 }

## Functions

static void | DrawGraph (const GraphDrawer *gw)
static void | GraphLegendWndProc (Window *w, WindowEvent *e)
static void | ShowGraphLegend ()
static void | SetupGraphDrawerForPlayers (GraphDrawer *gd)
static void | OperatingProfitWndProc (Window *w, WindowEvent *e)
void | ShowOperatingProfitGraph ()
static void | IncomeGraphWndProc (Window *w, WindowEvent *e)
void | ShowIncomeGraph ()
static void | DeliveredCargoGraphWndProc (Window *w, WindowEvent *e)
void | ShowDeliveredCargoGraph ()
static void | PerformanceHistoryWndProc (Window *w, WindowEvent *e)
void | ShowPerformanceHistoryGraph ()
static void | CompanyValueGraphWndProc (Window *w, WindowEvent *e)
void | ShowCompanyValueGraph ()
static void | CargoPaymentRatesWndProc (Window *w, WindowEvent *e)
void | ShowCargoPaymentRates ()
static StringID | GetPerformanceTitleFromValue (uint value)
static int CDECL | PerfHistComp (const void *elem1, const void *elem2)
static void | CompanyLeagueWndProc (Window *w, WindowEvent *e)
void | ShowCompanyLeagueTable ()
static void | PerformanceRatingDetailWndProc (Window *w, WindowEvent *e)
void | ShowPerformanceRatingDetail ()

## Variables

static uint | _legend_excluded_players
static uint | _legend_excluded_cargo
static const OverflowSafeInt64 | INVALID_DATAPOINT (INT64_MAX)
static const uint | INVALID_DATAPOINT_POS = UINT_MAX
static const Widget | _graph_legend_widgets []
static const WindowDesc | _graph_legend_desc
static const Widget | _operating_profit_widgets []
static const WindowDesc | _operating_profit_desc
static const Widget | _income_graph_widgets []
static const WindowDesc | _income_graph_desc
static const Widget | _delivered_cargo_graph_widgets []
static const WindowDesc | _delivered_cargo_graph_desc
static const Widget | _performance_history_widgets []
static const WindowDesc | _performance_history_desc
static const Widget | _company_value_graph_widgets []
static const WindowDesc | _company_value_graph_desc
static const Widget | _cargo_payment_rates_widgets []
static const WindowDesc | _cargo_payment_rates_desc
static const StringID | _performance_titles []
static const Widget | _company_league_widgets []
static const WindowDesc | _company_league_desc
static const Widget | _performance_rating_detail_widgets []
static const WindowDesc | _performance_rating_detail_desc

## Detailed Description

Definition in file graph_gui.cpp.

## Enumeration Type Documentation

anonymous enum

Enumerator:

  GRAPH_X_POSITION_BEGINNING | Start the graph 44 pixels from gw->left.
  GRAPH_X_POSITION_SEPARATION | There are 22 pixels between each X value.
  GRAPH_NUM_LINES_Y | How many horizontal lines to draw.

Definition at line 31 of file graph_gui.cpp.

## Function Documentation

static void DrawGraph | ( | const GraphDrawer * | gw | ) | `[static]`

< Reused whenever x and y coordinates are needed.

< Highest value to be drawn.

< Distance from the top of the graph to the x axis.

Definition at line 73 of file graph_gui.cpp.

References _colour_gradient, abs(), FindLastBit(), GRAPH_NUM_LINES_Y, GRAPH_X_POSITION_BEGINNING, GRAPH_X_POSITION_SEPARATION, HasBit(), max(), and MAX_PLAYERS.

## Variable Documentation

const WindowDesc _cargo_payment_rates_desc`[static]`

Initial value:

     {
      WDP_AUTO, WDP_AUTO, 568, 46, 568, 46,
      WC_PAYMENT_RATES, WC_NONE,
      WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
      _cargo_payment_rates_widgets,
      CargoPaymentRatesWndProc
    }

Definition at line 799 of file graph_gui.cpp.

const Widget _cargo_payment_rates_widgets[]`[static]`

Initial value:

     {
    {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                     STR_018B_CLOSE_WINDOW},
    {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   567,     0,    13, STR_7061_CARGO_PAYMENT_RATES, STR_018C_WINDOW_TITLE_DRAG_THIS},
    {      WWT_PANEL, RESIZE_BOTTOM,    14,     0,   567,    14,    45, 0x0,                          STR_NULL},
    {   WIDGETS_END},
    }

Definition at line 792 of file graph_gui.cpp.

const WindowDesc _company_league_desc`[static]`

Initial value:

     {
      WDP_AUTO, WDP_AUTO, 400, 97, 400, 97,
      WC_COMPANY_LEAGUE, WC_NONE,
      WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
      _company_league_widgets,
      CompanyLeagueWndProc
    }

Definition at line 921 of file graph_gui.cpp.

const Widget _company_league_widgets[]`[static]`

Initial value:

     {
    {   WWT_CLOSEBOX, RESIZE_NONE, 14,   0,  10,  0, 13, STR_00C5,                      STR_018B_CLOSE_WINDOW},
    {    WWT_CAPTION, RESIZE_NONE, 14,  11, 387,  0, 13, STR_7053_COMPANY_LEAGUE_TABLE, STR_018C_WINDOW_TITLE_DRAG_THIS},
    {  WWT_STICKYBOX, RESIZE_NONE, 14, 388, 399,  0, 13, STR_NULL,                      STR_STICKY_BUTTON},
    {      WWT_PANEL, RESIZE_NONE, 14,   0, 399, 14, 96, 0x0,                           STR_NULL},
    {   WIDGETS_END},
    }

Definition at line 913 of file graph_gui.cpp.

const WindowDesc _company_value_graph_desc`[static]`

Initial value:

     {
      WDP_AUTO, WDP_AUTO, 576, 238, 576, 238,
      WC_COMPANY_VALUE, WC_NONE,
      WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
      _company_value_graph_widgets,
      CompanyValueGraphWndProc
    }

Definition at line 702 of file graph_gui.cpp.

const Widget _company_value_graph_widgets[]`[static]`

Initial value:

     {
    {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                STR_018B_CLOSE_WINDOW},
    {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   525,     0,    13, STR_7052_COMPANY_VALUES, STR_018C_WINDOW_TITLE_DRAG_THIS},
    { WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   526,   575,     0,    13, STR_704C_KEY,            STR_704D_SHOW_KEY_TO_GRAPHS},
    {      WWT_PANEL,   RESIZE_NONE,    14,     0,   575,    14,   237, 0x0,                     STR_NULL},
    {   WIDGETS_END},
    }

Definition at line 694 of file graph_gui.cpp.

const WindowDesc _delivered_cargo_graph_desc`[static]`

Initial value:

     {
      WDP_AUTO, WDP_AUTO, 576, 142, 576, 142,
      WC_DELIVERED_CARGO, WC_NONE,
      WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
      _delivered_cargo_graph_widgets,
      DeliveredCargoGraphWndProc
    }

Definition at line 566 of file graph_gui.cpp.

const Widget _delivered_cargo_graph_widgets[]`[static]`

Initial value:

     {
    {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                          STR_018B_CLOSE_WINDOW},
    {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   525,     0,    13, STR_7050_UNITS_OF_CARGO_DELIVERED, STR_018C_WINDOW_TITLE_DRAG_THIS},
    { WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   526,   575,     0,    13, STR_704C_KEY,                      STR_704D_SHOW_KEY_TO_GRAPHS},
    {      WWT_PANEL,   RESIZE_NONE,    14,     0,   575,    14,   141, 0x0,                               STR_NULL},
    {   WIDGETS_END},
    }

Definition at line 558 of file graph_gui.cpp.

const WindowDesc _graph_legend_desc`[static]`

Initial value:

     {
      WDP_AUTO, WDP_AUTO, 250, 114, 250, 114,
      WC_GRAPH_LEGEND, WC_NONE,
      WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
      _graph_legend_widgets,
      GraphLegendWndProc
    }

Definition at line 332 of file graph_gui.cpp.

const Widget _graph_legend_widgets[]`[static]`

Initial value:

     {
    {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                       STR_018B_CLOSE_WINDOW},
    {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   249,     0,    13, STR_704E_KEY_TO_COMPANY_GRAPHS, STR_018C_WINDOW_TITLE_DRAG_THIS},
    {      WWT_PANEL,   RESIZE_NONE,    14,     0,   249,    14,   113, 0x0,                            STR_NULL},
    {      WWT_PANEL,   RESIZE_NONE,    14,     2,   247,    16,    27, 0x0,                            STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
    {      WWT_PANEL,   RESIZE_NONE,    14,     2,   247,    28,    39, 0x0,                            STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
    {      WWT_PANEL,   RESIZE_NONE,    14,     2,   247,    40,    51, 0x0,                            STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
    {      WWT_PANEL,   RESIZE_NONE,    14,     2,   247,    52,    63, 0x0,                            STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
    {      WWT_PANEL,   RESIZE_NONE,    14,     2,   247,    64,    75, 0x0,                            STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
    {      WWT_PANEL,   RESIZE_NONE,    14,     2,   247,    76,    87, 0x0,                            STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
    {      WWT_PANEL,   RESIZE_NONE,    14,     2,   247,    88,    99, 0x0,                            STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
    {      WWT_PANEL,   RESIZE_NONE,    14,     2,   247,   100,   111, 0x0,                            STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
    {   WIDGETS_END},
    }

Definition at line 317 of file graph_gui.cpp.

const WindowDesc _income_graph_desc`[static]`

Initial value:

     {
      WDP_AUTO, WDP_AUTO, 576, 142, 576, 142,
      WC_INCOME_GRAPH, WC_NONE,
      WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
      _income_graph_widgets,
      IncomeGraphWndProc
    }

Definition at line 499 of file graph_gui.cpp.

const Widget _income_graph_widgets[]`[static]`

Initial value:

     {
    {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,              STR_018B_CLOSE_WINDOW},
    {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   525,     0,    13, STR_7022_INCOME_GRAPH, STR_018C_WINDOW_TITLE_DRAG_THIS},
    { WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   526,   575,     0,    13, STR_704C_KEY,          STR_704D_SHOW_KEY_TO_GRAPHS},
    {      WWT_PANEL,   RESIZE_NONE,    14,     0,   575,    14,   141, 0x0,                   STR_NULL},
    {   WIDGETS_END},
    }

Definition at line 491 of file graph_gui.cpp.

const WindowDesc _operating_profit_desc`[static]`

Initial value:

     {
      WDP_AUTO, WDP_AUTO, 576, 174, 576, 174,
      WC_OPERATING_PROFIT, WC_NONE,
      WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
      _operating_profit_widgets,
      OperatingProfitWndProc
    }

Definition at line 430 of file graph_gui.cpp.

const Widget _operating_profit_widgets[]`[static]`

Initial value:

     {
    {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                        STR_018B_CLOSE_WINDOW},
    {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   525,     0,    13, STR_7025_OPERATING_PROFIT_GRAPH, STR_018C_WINDOW_TITLE_DRAG_THIS},
    { WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   526,   575,     0,    13, STR_704C_KEY,                    STR_704D_SHOW_KEY_TO_GRAPHS},
    {      WWT_PANEL,   RESIZE_NONE,    14,     0,   575,    14,   173, 0x0,                             STR_NULL},
    {   WIDGETS_END},
    }

Definition at line 422 of file graph_gui.cpp.

const WindowDesc _performance_history_desc`[static]`

Initial value:

     {
      WDP_AUTO, WDP_AUTO, 576, 238, 576, 238,
      WC_PERFORMANCE_HISTORY, WC_NONE,
      WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
      _performance_history_widgets,
      PerformanceHistoryWndProc
    }

Definition at line 635 of file graph_gui.cpp.

const Widget _performance_history_widgets[]`[static]`

Initial value:

     {
    {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                             STR_018B_CLOSE_WINDOW},
    {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   475,     0,    13, STR_7051_COMPANY_PERFORMANCE_RATINGS, STR_018C_WINDOW_TITLE_DRAG_THIS},
    { WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   526,   575,     0,    13, STR_704C_KEY,                         STR_704D_SHOW_KEY_TO_GRAPHS},
    { WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   476,   525,     0,    13, STR_PERFORMANCE_DETAIL_KEY,           STR_704D_SHOW_KEY_TO_GRAPHS},
    {      WWT_PANEL,   RESIZE_NONE,    14,     0,   575,    14,   237, 0x0,                                  STR_NULL},
    {   WIDGETS_END},
    }

Definition at line 626 of file graph_gui.cpp.

const WindowDesc _performance_rating_detail_desc`[static]`

Initial value:

     {
      WDP_AUTO, WDP_AUTO, 299, 228, 299, 228,
      WC_PERFORMANCE_DETAIL, WC_NONE,
      WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
      _performance_rating_detail_widgets,
      PerformanceRatingDetailWndProc
    }

Definition at line 1156 of file graph_gui.cpp.

const Widget _performance_rating_detail_widgets[]`[static]`

Initial value:

     {
    {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,               STR_018B_CLOSE_WINDOW},
    {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   298,     0,    13, STR_PERFORMANCE_DETAIL, STR_018C_WINDOW_TITLE_DRAG_THIS},
    {      WWT_PANEL,   RESIZE_NONE,    14,     0,   298,    14,    27, 0x0,                    STR_NULL},

    {      WWT_PANEL,   RESIZE_NONE,    14,     0,   298,    28,    47, 0x0,                    STR_PERFORMANCE_DETAIL_VEHICLES_TIP},
    {      WWT_PANEL,   RESIZE_NONE,    14,     0,   298,    48,    67, 0x0,                    STR_PERFORMANCE_DETAIL_STATIONS_TIP},
    {      WWT_PANEL,   RESIZE_NONE,    14,     0,   298,    68,    87, 0x0,                    STR_PERFORMANCE_DETAIL_MIN_PROFIT_TIP},
    {      WWT_PANEL,   RESIZE_NONE,    14,     0,   298,    88,   107, 0x0,                    STR_PERFORMANCE_DETAIL_MIN_INCOME_TIP},
    {      WWT_PANEL,   RESIZE_NONE,    14,     0,   298,   108,   127, 0x0,                    STR_PERFORMANCE_DETAIL_MAX_INCOME_TIP},
    {      WWT_PANEL,   RESIZE_NONE,    14,     0,   298,   128,   147, 0x0,                    STR_PERFORMANCE_DETAIL_DELIVERED_TIP},
    {      WWT_PANEL,   RESIZE_NONE,    14,     0,   298,   148,   167, 0x0,                    STR_PERFORMANCE_DETAIL_CARGO_TIP},
    {      WWT_PANEL,   RESIZE_NONE,    14,     0,   298,   168,   187, 0x0,                    STR_PERFORMANCE_DETAIL_MONEY_TIP},
    {      WWT_PANEL,   RESIZE_NONE,    14,     0,   298,   188,   207, 0x0,                    STR_PERFORMANCE_DETAIL_LOAN_TIP},
    {      WWT_PANEL,   RESIZE_NONE,    14,     0,   298,   208,   227, 0x0,                    STR_PERFORMANCE_DETAIL_TOTAL_TIP},

    {      WWT_PANEL,   RESIZE_NONE,    14,     2,    38,    14,    26, 0x0,                    STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
    {      WWT_PANEL,   RESIZE_NONE,    14,    39,    75,    14,    26, 0x0,                    STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
    {      WWT_PANEL,   RESIZE_NONE,    14,    76,   112,    14,    26, 0x0,                    STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
    {      WWT_PANEL,   RESIZE_NONE,    14,   113,   149,    14,    26, 0x0,                    STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
    {      WWT_PANEL,   RESIZE_NONE,    14,   150,   186,    14,    26, 0x0,                    STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
    {      WWT_PANEL,   RESIZE_NONE,    14,   187,   223,    14,    26, 0x0,                    STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
    {      WWT_PANEL,   RESIZE_NONE,    14,   224,   260,    14,    26, 0x0,                    STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
    {      WWT_PANEL,   RESIZE_NONE,    14,   261,   297,    14,    26, 0x0,                    STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
    {   WIDGETS_END},
    }

Definition at line 1129 of file graph_gui.cpp.

const StringID _performance_titles[]`[static]`

Initial value:

     {
      STR_7066_ENGINEER,
      STR_7066_ENGINEER,
      STR_7067_TRAFFIC_MANAGER,
      STR_7067_TRAFFIC_MANAGER,
      STR_7068_TRANSPORT_COORDINATOR,
      STR_7068_TRANSPORT_COORDINATOR,
      STR_7069_ROUTE_SUPERVISOR,
      STR_7069_ROUTE_SUPERVISOR,
      STR_706A_DIRECTOR,
      STR_706A_DIRECTOR,
      STR_706B_CHIEF_EXECUTIVE,
      STR_706B_CHIEF_EXECUTIVE,
      STR_706C_CHAIRMAN,
      STR_706C_CHAIRMAN,
      STR_706D_PRESIDENT,
      STR_706E_TYCOON,
    }

Definition at line 850 of file graph_gui.cpp.