Menu

#10 [0.2.0_pre2] WISH: Autofit chart to screen

closed-fixed
Charts (19)
2
2006-08-17
2006-06-08
No

Version: 0.2.0_pre2
Contact: mswilliamson@uwaterloo.ca

Use javascript to detect what the screen resolution of the client is and automatically fit the chart to the screen. This will be useful for people who use ast on multiple computers with different screen resolutions.

Discussion

  • Michael Williamson

    • labels: --> Charts
    • milestone: --> Version 0.2.x (Final)
    • priority: 5 --> 2
    • assigned_to: nobody --> mwilliamson
     
  • Michael Williamson

    • status: open --> closed-fixed
     
  • Michael Williamson

    Logged In: YES
    user_id=1281708

    Implemented in SVN comit #297. When you login to AST it
    records your resolution. There is a new selector for chart
    size called "Automatic".

    Index: share/templates/en/login

    =======
    --- share/templates/en/login (revision 282)
    +++ share/templates/en/login (working copy)
    @@ -5,8 +5,9 @@
    <link rel="stylesheet" type="text/css"
    href="$stylesheet">
    <link rel="shortcut icon" HREF="images/ast-icon.png"
    type="image/png">
    </head>
    -<body>
    -<form method="POST" action="$target">
    +<body onload="loginform.screenres.value=screen.width + 'x'
    + screen.height;">
    +<form method="POST" action="$target" id="loginform">
    +<input type="hidden" name="screenres" value="0x0">
    <table align="center" boarder="0" class="awf_form">
    <tr>
    <td colspan="2"><img src="images/ast-logo-welcome.
    png" alt="welcome"></td>
    Index: src/src/stockchartform.cc
    ============================================================
    =======
    --- src/src/stockchartform.cc (revision 282)
    +++ src/src/stockchartform.cc (working copy)
    @@ -271,7 +271,7 @@
    }else
    {
    // Load settings from xml
    - xf->set_if_not_exists( "size", 800 );
    + xf->set_if_not_exists( "size", 0 );
    xf->set_if_not_exists( "type", "line" );
    xf->set_if_not_exists( "average_type", "sma" );
    xf->set_if_not_exists( "averages", "25,40" );
    @@ -314,6 +314,31 @@
    colour_up = (unsigned long)xf->get("colour_up") == 1;
    logscale = (unsigned long)xf->get("logscale") == 1;
    }
    +
    + if( chart_size == 0 )
    + {
    + // Chart size 0 means automatic selection. In this
    case we
    + // should pick ~160 less than the screen width
    because the
    + // sidebar in AST takes up 160 pixels. This way we
    get a chart
    + // that fits perfectly only the screen.
    + try
    + {
    + std::string res = get_cookie( "screenres" );
    + unsigned int screenwidth = atoi( res.substr( 0,
    res.find("x") ).c_str() );
    +
    + if( screenwidth < 640 || screenwidth > 3000 )
    + {
    + chart_size = 800;
    + }else
    + {
    + // Subtract pixels for borders on the page (menu,
    etc).
    + chart_size = screenwidth - 200;
    + }
    + }catch(libawf::cookie_not_found_error&)
    + {
    + chart_size = 800;
    + }
    + }

    try
    {
    @@ -385,7 +410,7 @@
    {
    // error downloading the quotes likely, just ignore
    it.
    }
    -
    +
    stock_chart_image* img = new stock_chart_image(
    parent(), symbol, market );
    col.add_object( img, true );
    img->set_period( period );
    @@ -421,6 +446,7 @@
    tmpl.set_field( "time_options", time_options.get_options(
    time, false ) );

    libawf::options_list size_options;
    + size_options.add_option( _("Automatic"), 0 );
    size_options.add_option( _("Very Small"), 640 );
    size_options.add_option( _("Small"), 800 );
    size_options.add_option( _("Medium"), 1024 );
    @@ -536,7 +562,7 @@
    libawf::xml_settings_file* xf = open_chart_settings(
    parent(), period );

    // Load settings from xml
    - xf->set_if_not_exists( "size", 800 );
    + xf->set_if_not_exists( "size", 0 );
    xf->set_if_not_exists( "type", "line" );
    xf->set_if_not_exists( "average_type", "sma" );
    xf->set_if_not_exists( "averages", "25,40" );
    Index: src/libawf/loginpage.cc
    ============================================================
    =======
    --- src/libawf/loginpage.cc (revision 282)
    +++ src/libawf/loginpage.cc (working copy)
    @@ -88,6 +88,11 @@
    lm.authenticate( username, pset["password"] );
    set_cookie( cookie( "session-key", lm.session_key() )
    );
    set_cookie( cookie( "username", username ) );
    +
    + if( pset.is_set( "screenres" ) )
    + {
    + set_cookie( cookie( "screenres", pset["screenres"]
    ) );
    + }

    html_template tmpl( "login-success", parent().
    file_system() );
    parameter_set ps;

     

Log in to post a comment.