I built a line chart with Highcharts: see fiddle
The visible series can be chosen by a dropdown menu. This drop down menu is based on a csv file. Now I want to select a specific entry of the list by name, e.g. "Großbritannien". It should not be chosen by value because the value can change from time to time.
Here is my code for getting the drop down list from csv file:
function insertCountryInList(country) {
var list = $('select#countries');
var newOption =
$('<option></option>')
.attr('value', country.value)
.text(country.name);
list.append(newOption);
}
var CSV_URL = 'https://johanneschrist.de/grafiken/dropdown.csv';
$.get(CSV_URL, function (data) {
var lines = data.split("\n");
lines.shift();
var countries = lines.map(function (line) {
var fields = line.split(",");
return {
value: fields[0],
name: fields[1]
};
});
countries.forEach(insertCountryInList);
});
I tried this but it did not work:
$('#countries').val('22');
$('#countries').trigger('change');
How can I do that?