DataSrc:T241b: Difference between revisions

    From UNITApedia
    No edit summary
    No edit summary
     
    (19 intermediate revisions by one other user not shown)
    Line 24: Line 24:
    }}
    }}


    {{#ask:
    [[-Has subobject::{{FULLPAGENAME}}]]
    |?entry_date
    |?participants
    |?status_of_mobility_participant
    |format=graph
    |charttype=datatable
    |stacked=true
    |xprop=entry_date
    |yprop=participants
    |group=status_of_mobility_participant
    |sort=entry_date
    |order=ascending
    |limit=50
    |headers=show
    |charttitle=BIP Mobilities (Stacked Column Chart)
    |class=sortable wikitable smwtable
    }}


    {{#vardefine: t241dateData |
    [
      [
        "entry_date",
        "Student bachelor",
        "Student master",
        "Student doctorate"
      ],
      [
        "Nov 2023",
        {{#ask:
          [[-Has subobject::{{FULLPAGENAME}}]]
          [[entry_date::2023-11-01]]
          [[type_of_mobility::BIP-student mobility for studies]]
          [[status_of_mobility_participant::Student bachelor]]
          |?participants
          |format=plain
          |headers=hide
          |link=none
          |mainlabel=-
        }},
        {{#ask:
          [[-Has subobject::{{FULLPAGENAME}}]]
          [[entry_date::2023-11-01]]
          [[status_of_mobility_participant::Student master]]
          |?participants
          |format=plain
          |headers=hide
          |link=none
          |mainlabel=-
        }},
        {{#ask:
          [[-Has subobject::{{FULLPAGENAME}}]]
          [[entry_date::2023-11-01]]
          [[status_of_mobility_participant::Student doctorate]]
          |?participants
          |format=plain
          |headers=hide
          |link=none
          |mainlabel=-
        }}
      ],
      [
        "Dec 2023",
        {{#ask:
          [[-Has subobject::{{FULLPAGENAME}}]]
          [[entry_date::2023-12-01]]
          [[status_of_mobility_participant::Student bachelor]]
          |?participants
          |format=plain
          |headers=hide
          |link=none
          |mainlabel=-
        }},
        {{#ask:
          [[-Has subobject::{{FULLPAGENAME}}]]
          [[entry_date::2023-12-01]]
          [[status_of_mobility_participant::Student master]]
          |?participants
          |format=plain
          |headers=hide
          |link=none
          |mainlabel=-
        }},
        {{#ask:
          [[-Has subobject::{{FULLPAGENAME}}]]
          [[entry_date::2023-12-01]]
          [[status_of_mobility_participant::Student doctorate]]
          |?participants
          |format=plain
          |headers=hide
          |link=none
          |mainlabel=-
        }}
      ],
      [
        "Jan 2024",
        {{#ask:
          [[-Has subobject::{{FULLPAGENAME}}]]
          [[entry_date::2024-01-01]]
          [[status_of_mobility_participant::Student bachelor]]
          |?participants
          |format=plain
          |headers=hide
          |link=none
          |mainlabel=-
        }},
        {{#ask:
          [[-Has subobject::{{FULLPAGENAME}}]]
          [[entry_date::2024-01-01]]
          [[status_of_mobility_participant::Student master]]
          |?participants
          |format=plain
          |headers=hide
          |link=none
          |mainlabel=-
        }},
        {{#ask:
          [[-Has subobject::{{FULLPAGENAME}}]]
          [[entry_date::2024-01-01]]
          [[status_of_mobility_participant::Student doctorate]]
          |?participants
          |format=plain
          |headers=hide
          |link=none
          |mainlabel=-
        }}
      ],
      [
        "Feb 2024",
        {{#ask:
          [[-Has subobject::{{FULLPAGENAME}}]]
          [[entry_date::2024-02-01]]
          [[status_of_mobility_participant::Student bachelor]]
          |?participants
          |format=plain
          |headers=hide
          |link=none
          |mainlabel=-
        }},
        {{#ask:
          [[-Has subobject::{{FULLPAGENAME}}]]
          [[entry_date::2024-02-01]]
          [[status_of_mobility_participant::Student master]]
          |?participants
          |format=plain
          |headers=hide
          |link=none
          |mainlabel=-
        }},
        {{#ask:
          [[-Has subobject::{{FULLPAGENAME}}]]
          [[entry_date::2024-02-01]]
          [[status_of_mobility_participant::Student doctorate]]
          |?participants
          |format=plain
          |headers=hide
          |link=none
          |mainlabel=-
        }}
      ],
      [
        "Mar 2024",
        {{#ask:
          [[-Has subobject::{{FULLPAGENAME}}]]
          [[entry_date::2024-03-01]]
          [[status_of_mobility_participant::Student bachelor]]
          |?participants
          |format=plain
          |headers=hide
          |link=none
          |mainlabel=-
        }},
        {{#ask:
          [[-Has subobject::{{FULLPAGENAME}}]]
          [[entry_date::2024-03-01]]
          [[status_of_mobility_participant::Student master]]
          |?participants
          |format=plain
          |headers=hide
          |link=none
          |mainlabel=-
        }},
        {{#ask:
          [[-Has subobject::{{FULLPAGENAME}}]]
          [[entry_date::2024-03-01]]
          [[status_of_mobility_participant::Student doctorate]]
          |?participants
          |format=plain
          |headers=hide
          |link=none
          |mainlabel=-
        }}
      ],
      [
        "Apr 2024",
        {{#ask:
          [[-Has subobject::{{FULLPAGENAME}}]]
          [[entry_date::2024-04-01]]
          [[status_of_mobility_participant::Student bachelor]]
          |?participants
          |format=plain
          |headers=hide
          |link=none
          |mainlabel=-
        }},
        {{#ask:
          [[-Has subobject::{{FULLPAGENAME}}]]
          [[entry_date::2024-04-01]]
          [[status_of_mobility_participant::Student master]]
          |?participants
          |format=plain
          |headers=hide
          |link=none
          |mainlabel=-
        }},
        {{#ask:
          [[-Has subobject::{{FULLPAGENAME}}]]
          [[entry_date::2024-04-01]]
          [[status_of_mobility_participant::Student doctorate]]
          |?participants
          |format=plain
          |headers=hide
          |link=none
          |mainlabel=-
        }}
      ],
      [
        "May 2024",
        {{#ask:
          [[-Has subobject::{{FULLPAGENAME}}]]
          [[entry_date::2024-05-01]]
          [[status_of_mobility_participant::Student bachelor]]
          |?participants
          |format=plain
          |headers=hide
          |link=none
          |mainlabel=-
        }},
        {{#ask:
          [[-Has subobject::{{FULLPAGENAME}}]]
          [[entry_date::2024-05-01]]
          [[status_of_mobility_participant::Student master]]
          |?participants
          |format=plain
          |headers=hide
          |link=none
          |mainlabel=-
        }},
        {{#ask:
          [[-Has subobject::{{FULLPAGENAME}}]]
          [[entry_date::2024-05-01]]
          [[status_of_mobility_participant::Student doctorate]]
          |?participants
          |format=plain
          |headers=hide
          |link=none
          |mainlabel=-
        }}
      ],


    {{#ask: [[-Has subobject::{{FULLPAGENAME}}]]  
      [
    |?entry_date
        "Jun 2024",
    |?participants
        {{#ask:
    |format=timeseries
          [[-Has subobject::{{FULLPAGENAME}}]]
    |link=all
          [[entry_date::2024-06-01]]
    |xprop=entry_date
          [[status_of_mobility_participant::Student bachelor]]
    |yprop=files_created
          |?participants
    |accumulate=true
          |format=plain
    |sort=entry_date
          |headers=hide
    |limit=50
          |link=none
    |order=ascending
          |mainlabel=-
    |headers=show
        }},
    |charttitle=UNITA Files Created
        {{#ask:
    |layout=line
          [[-Has subobject::{{FULLPAGENAME}}]]
    |group=property
          [[entry_date::2024-06-01]]
    |zoomarea=bottom
          [[status_of_mobility_participant::Student master]]
    |tablearea=bottom
          |?participants
    |class=sortable wikitable smwtable
          |format=plain
    }}
          |headers=hide
    <echarts>
          |link=none
    <script>
          |mainlabel=-
    // Retrieve your data as JSON using an askjson query.
        }},
    // (Make sure your query returns valid dates and numeric participants.)
        {{#ask:
    var askData = {{#askjson:
          [[-Has subobject::{{FULLPAGENAME}}]]
      [[-Has subobject::{{FULLPAGENAME}}]]
          [[entry_date::2024-06-01]]
      |?entry_date
          [[status_of_mobility_participant::Student doctorate]]
      |?participants
          |?participants
      |?status_of_mobility_participant
          |format=plain
      |limit=100
          |headers=hide
      |sort=entry_date
          |link=none
      |order=ascending
          |mainlabel=-
    }};
        }}
      ],


    // Prepare arrays to hold unique x-axis dates and series data.
      [
    var xAxisDates = []; // will hold sorted dates (as strings)
        "Jul 2024",
    var seriesData = {}; // an object keyed by status
        {{#ask:
          [[-Has subobject::{{FULLPAGENAME}}]]
          [[entry_date::2024-07-01]]
          [[status_of_mobility_participant::Student bachelor]]
          |?participants
          |format=plain
          |headers=hide
          |link=none
          |mainlabel=-
        }},
        {{#ask:
          [[-Has subobject::{{FULLPAGENAME}}]]
          [[entry_date::2024-07-01]]
          [[status_of_mobility_participant::Student master]]
          |?participants
          |format=plain
          |headers=hide
          |link=none
          |mainlabel=-
        }},
        {{#ask:
          [[-Has subobject::{{FULLPAGENAME}}]]
          [[entry_date::2024-07-01]]
          [[status_of_mobility_participant::Student doctorate]]
          |?participants
          |format=plain
          |headers=hide
          |link=none
          |mainlabel=-
        }}
      ],


    // Process each data row.
      [
    askData.forEach(function(item) {
        "Aug 2024",
      // Assume item.entry_date is in a format ECharts can display (like "2024-02-01")
        {{#ask:
      var date = item.entry_date;
          [[-Has subobject::{{FULLPAGENAME}}]]
      // Ensure the date is recorded in the x-axis array.
          [[entry_date::2024-08-01]]
      if (xAxisDates.indexOf(date) === -1) {
          [[status_of_mobility_participant::Student bachelor]]
         xAxisDates.push(date);
          |?participants
      }
          |format=plain
     
          |headers=hide
      // Get the group/status.
          |link=none
      var status = item.status_of_mobility_participant;
          |mainlabel=-
      if (!seriesData[status]) {
         }},
        seriesData[status] = {};
        {{#ask:
      }
          [[-Has subobject::{{FULLPAGENAME}}]]
     
          [[entry_date::2024-08-01]]
      // Record the participant count. Convert to number in case it's a string.
          [[status_of_mobility_participant::Student master]]
      seriesData[status][date] = parseFloat(item.participants);
          |?participants
    });
          |format=plain
          |headers=hide
          |link=none
          |mainlabel=-
        }},
        {{#ask:
          [[-Has subobject::{{FULLPAGENAME}}]]
          [[entry_date::2024-08-01]]
          [[status_of_mobility_participant::Student doctorate]]
          |?participants
          |format=plain
          |headers=hide
          |link=none
          |mainlabel=-
        }}
      ],


    // Sort the x-axis dates.
      [
    xAxisDates.sort();
        "Sep 2024",
        {{#ask:
          [[-Has subobject::{{FULLPAGENAME}}]]
          [[entry_date::2024-09-01]]
          [[status_of_mobility_participant::Student bachelor]]
          |?participants
          |format=plain
          |headers=hide
          |link=none
          |mainlabel=-
        }},
        {{#ask:
          [[-Has subobject::{{FULLPAGENAME}}]]
          [[entry_date::2024-09-01]]
          [[status_of_mobility_participant::Student master]]
          |?participants
          |format=plain
          |headers=hide
          |link=none
          |mainlabel=-
        }},
        {{#ask:
          [[-Has subobject::{{FULLPAGENAME}}]]
          [[entry_date::2024-09-01]]
          [[status_of_mobility_participant::Student doctorate]]
          |?participants
          |format=plain
          |headers=hide
          |link=none
          |mainlabel=-
        }}
      ],


    // Build the series array. For each status, align data with the x-axis dates.
      [
    var legendData = [];
        "Oct 2024",
    var seriesArray = [];
        {{#ask:
          [[-Has subobject::{{FULLPAGENAME}}]]
          [[entry_date::2024-10-01]]
          [[status_of_mobility_participant::Student bachelor]]
          |?participants
          |format=plain
          |headers=hide
          |link=none
          |mainlabel=-
        }},
        {{#ask:
          [[-Has subobject::{{FULLPAGENAME}}]]
          [[entry_date::2024-10-01]]
          [[status_of_mobility_participant::Student master]]
          |?participants
          |format=plain
          |headers=hide
          |link=none
          |mainlabel=-
        }},
        {{#ask:
          [[-Has subobject::{{FULLPAGENAME}}]]
          [[entry_date::2024-10-01]]
          [[status_of_mobility_participant::Student doctorate]]
          |?participants
          |format=plain
          |headers=hide
          |link=none
          |mainlabel=-
        }}
      ],


    for (var status in seriesData) {
      [
      legendData.push(status);
        "Nov 2024",
      // Build data array for this status.
        {{#ask:
      var dataArray = xAxisDates.map(function(date) {
          [[-Has subobject::{{FULLPAGENAME}}]]
         // If no value exists for this date, use 0.
          [[entry_date::2024-11-01]]
         return seriesData[status][date] || 0;
          [[status_of_mobility_participant::Student bachelor]]
      });
          |?participants
     
          |format=plain
      seriesArray.push({
          |headers=hide
         name: status,
          |link=none
         type: 'line',      // line chart; change to 'bar' if you prefer columns.
          |mainlabel=-
        stack: 'Total',    // this enables stacking
         }},
        areaStyle: {},      // makes it an area chart (stacked area)
         {{#ask:
        emphasis: { focus: 'series' },
          [[-Has subobject::{{FULLPAGENAME}}]]
         data: dataArray
          [[entry_date::2024-11-01]]
       });
          [[status_of_mobility_participant::Student master]]
    }
          |?participants
          |format=plain
          |headers=hide
          |link=none
          |mainlabel=-
         }},
         {{#ask:
          [[-Has subobject::{{FULLPAGENAME}}]]
          [[entry_date::2024-11-01]]
          [[status_of_mobility_participant::Student doctorate]]
          |?participants
          |format=plain
          |headers=hide
          |link=none
          |mainlabel=-
         }}
       ]
    ]
    }}


    // Build the ECharts option object.
    {{#echarts:
    var option = {
    width=1000px |
    height=600px |
    option = {
       title: {
       title: {
         text: 'BIP Mobilities'
         text: 'BIP-student mobility for studies'
       },
       },
       tooltip: {
       tooltip: {
         trigger: 'axis',
         trigger: 'axis',
         axisPointer: {
         axisPointer: {
           type: 'cross',
           type: 'shadow'
           label: { backgroundColor: '#6a7985' }
        }
      },
      toolbox: {
        feature: {
           magicType: {
            type: ["line", "bar","stack"]
          },
          saveAsImage: {},
         }
         }
       },
       },
       legend: {
       legend: {
         data: legendData
         data: ['Student bachelor', 'Student master', 'Student doctorate']
      },
      toolbox: {
        feature: { saveAsImage: {} }
       },
       },
       grid: {
       grid: {
    Line 149: Line 509:
         containLabel: true
         containLabel: true
       },
       },
       xAxis: [{
       dataset: {
         type: 'category',
         source: {{#var:t241dateData}}
        boundaryGap: false,
      },
         data: xAxisDates
      xAxis: {
       }],
         type: 'category'
       yAxis: [{
       },
       yAxis: {
         type: 'value'
         type: 'value'
       }],
       },
       series: seriesArray
       series: [
    };
        {
     
          type: 'bar',
    // Initialize the chart in the div with id "myChart" (or let the extension handle it).
          stack: 'total',
    // If the ECharts extension expects the option variable, just output it.
          emphasis: { focus: 'series' }
    echarts.init(document.getElementById('myChart')).setOption(option);
        },
    </script>
        {
    <div id="myChart" style="width: 600px; height: 400px;"></div>
          type: 'bar',
    </echarts>
          stack: 'total',
          emphasis: { focus: 'series' }
        },
        {
          type: 'bar',
          stack: 'total',
          emphasis: { focus: 'series' }
        }
      ]
    }
    }}

    Latest revision as of 14:50, 2 April 2025