How to Get Exchange Rates in Excel Automatically Using a Free API (VBA Step-by-Step)

Imagen
How to Get Exchange Rates in Excel Automatically Using a Free API (VBA Step-by-Step) Automate exchange rates in Excel in minutes. In this guide, you’ll learn how to retrieve currency data from multiple countries (including African currencies) using a free API and VBA. This example is perfect if you work with financial reports, currency analysis, or need updated data without manual input. 🚀 What will you learn? How to get real-time exchange rates in Excel How to use a free API (no API key required) How to automate Excel with VBA How to retrieve multiple currencies (USD, MXN, EUR, ZAR, NGN, etc.) 🌍 Free Exchange Rate API For this example, we will use the following free API: 👉 https://open.er-api.com/v6/latest/USD Advantages: No API key required 150+ currencies available Includes African currencies Daily updated data (not historical) 💻 VBA Macro to Get Exchange Rates in Excel Copy and paste this code into a VBA module: Sub GetExchangeRates(...

Graficar Funciones con JavaScript y HTML Chart.js

 Cuando trabajamos con datos o funciones matemáticas, es muy útil poder visualizarlos en una gráfica. Con JavaScript y HTML, esto es sencillo si utilizamos una biblioteca como Chart.js.

A continuación, te presento un ejemplo donde graficamos la función cuadrática y = x^3. Usaremos etiquetas en el eje X desde -10 hasta 10 y graficar los valores correspondientes para y.

Guia para graficar funciones con javascript


Aquí tienes el código que necesitas para generar la gráfica:



<html lang="es">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Graficar Funciones con JavaScript</title>

    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>

</head>

<body>

    <h1>Graficar Funciones con JavaScript y HTML</h1>

    <canvas id="miGrafica" width="400" height="200"></canvas>


    <script>

        // Generar datos para la función y = x^3

        const etiquetas = [];

        const datosFuncion = [];


        for (let x = -10; x <= 10; x++) {

            etiquetas.push(x);

            datosFuncion.push(x * x);  // y = x^2

        }


        const ctx = document.getElementById('miGrafica').getContext('2d');

        const miGrafica = new Chart(ctx, {

            type: 'line',  // Tipo de gráfica

            data: {

                labels: etiquetas,

                datasets: [{

                    label: 'y = x^3',

                    data: datosFuncion,

                    borderColor: 'rgba(75, 192, 192, 1)',

                    borderWidth: 2,

                    fill: false

                }]

            },

            options: {

                scales: {

                    x: { title: { display: true, text: 'Valor de x' } },

                    y: { title: { display: true, text: 'Valor de y' } }

                }

            }

        });

    </script>

</body>

</html>

 Este código utiliza un elemento <canvas> donde se dibuja la gráfica. Luego, mediante un script de JavaScript, generamos los datos para la función y = x^3 y los pasamos a Chart.js para que los graficaque. 

Visita la url https://www.programacionparatodos.com/p/graficar-funciones-con-javascript-y.html Para ver el resultado


Conclusión

Este ejemplo es una introducción básica, pero Chart.js tiene una gran variedad de opciones para crear gráficos más complejos, incluyendo gráficos de barras, líneas, radar, y más. Puedes personalizar tu gráfica para que se ajuste a tus necesidades.

Comentarios

🚀 Mantener este blog funcionando requiere tiempo y café. ¡Puedes contribuir con uno aquí!

Entradas más populares de este blog

Guía Práctica: Ejemplo Completo de ASPX para Desarrolladores Web

👉 Cómo obtener el tipo de cambio en Excel con API de Banxico (paso a paso)

Macro en Word para automatizar documentos: genera diplomas en segundos (con código VBA)