1 /*************************************************************************** 2 * Copyright (c) 2024 Microsoft Corporation 3 * 4 * This program and the accompanying materials are made available under the 5 * terms of the MIT License which is available at 6 * https://opensource.org/licenses/MIT. 7 * 8 * SPDX-License-Identifier: MIT 9 **************************************************************************/ 10 11 12 /**************************************************************************/ 13 /**************************************************************************/ 14 /** */ 15 /** GUIX Component */ 16 /** */ 17 /** Line Chart Management (Line Chart) */ 18 /** */ 19 /**************************************************************************/ 20 21 #define GX_SOURCE_CODE 22 23 24 /* Include necessary system files. */ 25 26 #include "gx_api.h" 27 #include "gx_window.h" 28 #include "gx_line_chart.h" 29 30 31 /**************************************************************************/ 32 /* */ 33 /* FUNCTION RELEASE */ 34 /* */ 35 /* _gx_line_chart_y_scale_calculate PORTABLE C */ 36 /* 6.1 */ 37 /* AUTHOR */ 38 /* */ 39 /* Kenneth Maxwell, Microsoft Corporation */ 40 /* */ 41 /* DESCRIPTION */ 42 /* */ 43 /* This function calculates chart y axis scale value */ 44 /* */ 45 /* INPUT */ 46 /* */ 47 /* chart Line chart */ 48 /* return_value location to pass return value */ 49 /* */ 50 /* OUTPUT */ 51 /* */ 52 /* Completion Status */ 53 /* */ 54 /* CALLS */ 55 /* */ 56 /* none */ 57 /* */ 58 /* CALLED BY */ 59 /* */ 60 /* Application Code */ 61 /* */ 62 /* RELEASE HISTORY */ 63 /* */ 64 /* DATE NAME DESCRIPTION */ 65 /* */ 66 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ 67 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */ 68 /* resulting in version 6.1 */ 69 /* */ 70 /**************************************************************************/ _gx_line_chart_y_scale_calculate(GX_LINE_CHART * chart,INT * return_value)71UINT _gx_line_chart_y_scale_calculate(GX_LINE_CHART *chart, INT *return_value) 72 { 73 INT y_scale; 74 GX_LINE_CHART_INFO *chart_info; 75 76 chart_info = &chart -> gx_line_chart_info; 77 78 y_scale = chart -> gx_widget_size.gx_rectangle_bottom - chart -> gx_widget_size.gx_rectangle_top + 1; 79 y_scale -= chart_info -> gx_line_chart_top_margin + chart_info -> gx_line_chart_bottom_margin; 80 y_scale -= chart_info -> gx_line_chart_axis_line_width; 81 82 y_scale = GX_FIXED_VAL_MAKE(y_scale); 83 84 if (chart_info -> gx_line_chart_max_val != chart_info -> gx_line_chart_min_val) 85 { 86 y_scale /= (chart_info -> gx_line_chart_max_val - chart_info -> gx_line_chart_min_val); 87 } 88 *return_value = y_scale; 89 return GX_SUCCESS; 90 } 91 92 93 94 95 96