I am looking to dynamically generate the Y
axis based on a JSON response. For example:
{
"totalCount":"4",
"data":[
{"asOfDate":"12-JAN-14","eventA":"575","eventB":"16","eventC":"13",...},
{"asOfDate":"13-JAN-14","eventA":"234","eventB":"46","eventC":"23",...},
...and more.
]
}
The goal is to create a line chart with date vs event
. Dates on the x-axis and eventA, eventB, and so forth on the Y-axis. Currently, this is what I have attempted:
var fieldsForChart = ['eventA','eventB',...]; //Currently hardcoded
Ext.define("TestBug.view.TrendsChart", {
extend: "Ext.chart.Chart",
alias: "widget.trendschart",
store: "Trends",
style: 'background:#fff',
animate: true,
shadow: true,
theme: 'Category1',
legend: {position: 'right'},
axes: [
{
type: "numeric",
position: "left",
fields: [fieldsForChart],
title:"Start Open",
},
{
type: "Time",
dateFormat:"d-M-y",
position: "bottom",
fields: "asOfDate",
title: 'Date'
}
],
series: [
{
type: "line",
axis: "left",
xField: "asOfDate",
yField: "fieldsForChart "
}
]
});
Despite these efforts, the graph has not been successfully plotted. The aim is to dynamically render axes and series based on the JSON response. Any assistance would be greatly appreciated. Thank you in advance. :)
This is my model:
Ext.define("TestBug.model.Trend", {
extend: "Ext.data.Model",
fields: [
{name:"asOfDate",type:"date",dateFormat:"d-M-y"},
{name:"eventA",type:"int"},
{name:"eventB",type:"int"},
...and more.
]
});
Currently, all aspects related to events are hardcoded but there is a need to generate them dynamically.