yogesh Posted November 16, 2012 Report Share Posted November 16, 2012 Here is my code to draw line series. I was trying to create line chart with following data. Can you please help me what I am doing wrong here. var items = [{"Date":"Thu 11/15/2012 18:34","Value":5972.0},{"Date":"Thu 11/15/2012 17:38","Value":4196.0},{"Date":"Thu 11/15/2012 16:53","Value":4198.0},{"Date":"Thu 11/15/2012 15:37","Value":4233.0},{"Date":"Thu 11/15/2012 14:38","Value":4401.0},{"Date":"Thu 11/15/2012 13:42","Value":4487.0}]; var assetForecastedGraph = new cfx.Chart(); assetForecastedGraph.getAllSeries().setMarkerShape(cfx.MarkerShape.None); assetForecastedGraph.getLegendBox().setVisible(true); assetForecastedGraph.getLegendBox().setBorder(cfx.DockBorder.Internal); assetForecastedGraph.getLegendBox().setContentLayout(cfx.ContentLayout.Spread); assetForecastedGraph.getLegendBox().setDock(cfx.DockArea.Bottom); var axisY = assetForecastedGraph.getAxisY(); axisY.getGrids().getMinor().setVisible(true); assetForecastedGraph.getAxisX().setLabelAngle(45); var fields = assetForecastedGraph.getDataSourceSettings().getFields(); //alert(44); var field1 = new cfx.FieldMap(); field1.setName("Value"); field1.setUsage(cfx.FieldUsage.Value); fields.add(field1); //alert(55); var field2 = new cfx.FieldMap(); field2.setName("Date"); field2.setUsage(cfx.FieldUsage.XValue); fields.add(field2); // assetForecastedGraph.setGallery(cfx.Gallery.Bar); // assetForecastedGraph.getAxisX().getLabelsFormat().setFormat(cfx.AxisFormat.DateTime); assetForecastedGraph.getAxisX().getLabelsFormat().setCustomFormat("EEE MM/dd/yyyy HH:mm"); // alert(dataArray); //alert(1); assetForecastedGraph.setDataSource(items); // alert(2); var chartDiv = document.getElementById('historyChartContainer'); //alert(chartDiv); assetForecastedGraph.create(chartDiv); It Quote Link to comment Share on other sites More sharing options...
0 yogesh Posted November 17, 2012 Author Report Share Posted November 17, 2012 It has been fixed. I removed fields mapping, and it works fine. I commented following lines: var fields = assetForecastedGraph.getDataSourceSettings().getFields(); //alert(44); var field1 = new cfx.FieldMap(); field1.setName("Value"); field1.setUsage(cfx.FieldUsage.Value); fields.add(field1); //alert(55); var field2 = new cfx.FieldMap(); field2.setName("Date"); field2.setUsage(cfx.FieldUsage.XValue); fields.add(field2); Thanks!! Quote Link to comment Share on other sites More sharing options...
Question
yogesh
Here is my code to draw line series. I was trying to create line chart with following data. Can you please help me what I am doing wrong here.
var items = [{"Date":"Thu 11/15/2012 18:34","Value":5972.0},{"Date":"Thu 11/15/2012 17:38","Value":4196.0},{"Date":"Thu 11/15/2012 16:53","Value":4198.0},{"Date":"Thu 11/15/2012 15:37","Value":4233.0},{"Date":"Thu 11/15/2012 14:38","Value":4401.0},{"Date":"Thu 11/15/2012 13:42","Value":4487.0}];
var assetForecastedGraph = new cfx.Chart();
assetForecastedGraph.getAllSeries().setMarkerShape(cfx.MarkerShape.None);
assetForecastedGraph.getLegendBox().setVisible(true);
assetForecastedGraph.getLegendBox().setBorder(cfx.DockBorder.Internal);
assetForecastedGraph.getLegendBox().setContentLayout(cfx.ContentLayout.Spread);
assetForecastedGraph.getLegendBox().setDock(cfx.DockArea.Bottom);
var axisY = assetForecastedGraph.getAxisY();
axisY.getGrids().getMinor().setVisible(true);
assetForecastedGraph.getAxisX().setLabelAngle(45);
var fields = assetForecastedGraph.getDataSourceSettings().getFields();
//alert(44);
var field1 = new cfx.FieldMap();
field1.setName("Value");
field1.setUsage(cfx.FieldUsage.Value);
fields.add(field1);
//alert(55);
var field2 = new cfx.FieldMap();
field2.setName("Date");
field2.setUsage(cfx.FieldUsage.XValue);
fields.add(field2);
// assetForecastedGraph.setGallery(cfx.Gallery.Bar);
// assetForecastedGraph.getAxisX().getLabelsFormat().setFormat(cfx.AxisFormat.DateTime);
assetForecastedGraph.getAxisX().getLabelsFormat().setCustomFormat("EEE MM/dd/yyyy HH:mm");
// alert(dataArray);
//alert(1);
assetForecastedGraph.setDataSource(items);
// alert(2);
var chartDiv = document.getElementById('historyChartContainer');
//alert(chartDiv);
assetForecastedGraph.create(chartDiv);
It
Link to comment
Share on other sites
1 answer to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.