Calling all jscript wizards.
This is my dilemma, and I think this will prove useful to other bubblers looking for the same solution.
I am trying to work my way through jscript and absolute newby and can read the code and no what it does but not clear on syntax or how to make it work.
So this is the problem:
I have a solution which will allow for the implementation of heatmaps charts in my app https://apexcharts.com/docs/chart-types/heatmap-charts/
The solution works great using the example, so what I need to do now is create a script which writes an array in the correct format for the chart script to render the chart correctly.
Let’s look at an example provided by APEXCHARTS:
function generateData(count, yrange) {
var i = 0;
var series = [];
while (i < count) {
var x = 'w' + (i + 1).toString();
var y = Math.floor(Math.random() * (yrange.max - yrange.min + 1)) + yrange.min;
series.push({
x: x,
y: y
});
i++;
}
return series;
}
var options = {
chart: {
height: 350,
type: 'heatmap',
},
dataLabels: {
enabled: false
},
colors: ["#008FFB"],
series: [{
name: 'Metric1',
data: generateData(18, {
min: 0,
max: 90
})
},
This example code basically creates a random set of numbers for each series up to 18 columns, the full example has 9 series.
I understand what this does, but this is what I want to do:
For ‘x’ I have a list of unique names (string) in the database which I pull from using a bubble query.
y = Search for Feedback_round's date_month:unique elements (example: ["Jan", "Feb", "March", "April"])
For ‘y’ I have a list of numbers for each round in a month which is calculated like this:
Jan = Search for Activitys's Score:formatted as 1029 (example: [40, 15, 10, 10, 25])
I have have the same number series in each month:
series = Search for Feedback_round's title:unique elements (example: ["round 1", "round 2", "round 3", "round 4"])
Jan Feb March April
Round 1 40 25 10 10
Round 2 15 35 20 25
Round 3 10 10 30 25
Round 4 10 20 30 10
Round 5 25 10 10 30
So what I need to be able to do is take the data and print it into the format which is correct.
For example:
series: [
{
name: "Round 1",
data: [{
x: 'Jan',
y: 40
}, {
x: 'Feb',
y: 25
}, {
x: 'March',
y: 10
}, {
x: 'April',
y: 10
}]
},
{
name: "Round 2",
data: [{
x: 'Jan',
y: 15
}, {
x: 'Feb',
y: 35
}, {
x: 'March',
y: 20
}, {
x: 'April',
y: 25
}]
}
]
}
So that’s it I have tried, but like I said I am a newby and basically falling my way through this.
I think it would also be a great solution for other bubble users here looking to implement a similar style chart.
Can you help?