Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dimple js not ploting the bar graph #281

Open
jyoti111992 opened this issue Jul 31, 2017 · 0 comments
Open

dimple js not ploting the bar graph #281

jyoti111992 opened this issue Jul 31, 2017 · 0 comments

Comments

@jyoti111992
Copy link

i am new to dimple js,i want to plot a bar chart where x axis represent date(yyyy-mm-dd) and y axis represent time(hh:mm:ss).here is my code

                CAM Sweep

<script src="https://d3js.org/d3.v4.min.js"></script> <script src="http://dimplejs.org/dist/dimple.v2.3.0.min.js"></script> <script type="text/javascript">
var result=new Array();
var svg = dimple.newSvg("#chartContainer", 690, 600);

var data = [
{ "Executiondate":"2010-07-12","Time":"10:00:25"},
{ "Executiondate":"2010-07-20","Time":"10:20:28"},
{ "Executiondate":"2010-08-01","Time":"10:40:22"},
{ "Executiondate":"2010-08-08","Time":"10:10:56"},
{ "Executiondate":"2010-08-20","Time":"11:00:41"},
{ "Executiondate":"2010-09-07","Time":"09:50:55"},
{ "Executiondate":"2010-09-13","Time":"10:10:49"},
{ "Executiondate":"2010-10-01","Time":"12:00:33"},
{ "Executiondate":"2010-10-09","Time":"10:10:31"},
{ "Executiondate":"2010-10-29","Time":"11:40:00"},
{ "Executiondate":"2010-10-23","Time":"10:30:23"},
{ "Executiondate":"2010-11-01","Time":"09:30:12"},
{ "Executiondate":"2010-11-09","Time":"10:50:36"},
{ "Executiondate":"2010-11-20","Time":"10:10:39"},
{ "Executiondate":"2010-12-01","Time":"10:50:05"},
{ "Executiondate":"2010-12-23","Time":"12:20:01"},
{ "Executiondate":"2010-12-02","Time":"10:10:06"},
{ "Executiondate":"2010-12-13","Time":"10:00:17"},
{ "Executiondate":"2010-07-11","Time":"16:00:02"},
{ "Executiondate":"2010-07-30","Time":"17:30:59"},
{ "Executiondate":"2010-08-11","Time":"15:40:36"},
{ "Executiondate":"2010-08-13","Time":"13:10:25"},
{ "Executiondate":"2010-09-21","Time":"15:00:13"},
{ "Executiondate":"2010-08-07","Time":"15:50:45"},
{ "Executiondate":"2010-08-13","Time":"14:10:56"},
{ "Executiondate":"2010-08-30","Time":"13:00:17"},
{ "Executiondate":"2010-09-11","Time":"15:50:19"},
{ "Executiondate":"2010-09-23","Time":"15:10:28"},
{ "Executiondate":"2010-12-11","Time":"15:50:36"},
{ "Executiondate":"2010-12-01","Time":"15:20:27"},
{ "Executiondate":"2010-03-11","Time":"15:10:10"},
{ "Executiondate":"2010-09-11","Time":"08:20:00"}
];

for(var i in data){
result[i]=data[i].Executiondate;
}

var sorted = result.sort(result);
var minDate = sorted[0];
var maxDate = sorted[sorted.length-1];
//console.log(maxDate);
//console.log(minDate);

data.forEach(function (d) {
    d["days"] = d["Executiondate"].substring(d["Executiondate"]);
    d["TimeofDay"] =d["Time"].substring(d["Time"]);
});

// Create the chart as usual
var myChart = new dimple.chart(svg, data);
myChart.setBounds(70, 40, 590, 420)

var x = myChart.addTimeAxis("x", "days","%Y-%m-%d","%Y-%m-%d");

var y = myChart.addTimeAxis("y", "TimeofDay",
    "%H:%M:%S", "%H:%M:%S");
	
x.overrideMin = new Date(minDate);
x.overrideMax = new Date(maxDate);

var s = myChart.addSeries("Total", dimple.plot.bar);
y.showGridlines = true;
//s.lineMarkers = true;
myChart.assignColor("Total", "blue");
myChart.draw();
x.shapes.selectAll("text").attr("transform", "rotate(15)");
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant