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

refactored to a newable object, and updated the examples #17

Merged
merged 1 commit into from
Dec 23, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion site/source/pages/api-reference/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: API Reference
layout: documentation.hbs
---

# Esri Cedar API Reference
# (NOT CURRENT) Esri Cedar API Reference

## Public Methods
* [`Cedar.show`]({{assets}}api-reference/show.html)
Expand Down
11 changes: 5 additions & 6 deletions site/source/pages/examples/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ layout: example.hbs
{{#markdown}}
```html
{{>example-code-header}}
//render
Cedar.show({
var cedar = new Cedar();
cedar.show({
elementId: "#chart",
spec: "/data/charts/scatter-chart.json"
spec: "{{assets}}data/charts/simple-scatter-chart.json"
});

{{>example-code-footer}}
```
{{/markdown}}
Expand All @@ -26,8 +25,8 @@ layout: example.hbs

<script>

//render
Cedar.show({
var cedar = new Cedar();
cedar.show({
elementId: "#chart",
spec: "{{assets}}data/charts/simple-scatter-chart.json"
});
Expand Down
70 changes: 29 additions & 41 deletions site/source/pages/examples/scatter-events.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,23 @@ layout: example.hbs
```html

{{>example-code-header}}
//render
function showItem(item){
function showItem(data){
var tmpl = document.getElementById("school-detail-template").innerHTML;
compiled = _.template(tmpl);

document.getElementById('details').innerHTML = compiled(item.datum.data.attributes);
document.getElementById('details').innerHTML = compiled(data);
}

var cb = function(err, chart){
chart.on('mouseover', function(evt, item){
console.log('mouseover ' + evt.currentTarget);

});
chart.on('mouseout', function(evt, item){
console.log('mouseout');

});
chart.on('click', function(evt, item){
console.log('click');
showItem(item);
});
};

Cedar.show({

var chart = new Cedar();
//attach handlers before the view exists
chart.on('mouseover', showItem);
//show the chart
chart.show({
elementId: "#chart",
spec: "{{assets}}data/charts/evt-scatter-chart.json"
}, cb);
});
//add more handlers after starting chart creation
chart.on('mouseout', showItem);
chart.on('click', showItem);

{{>example-code-footer}}
```
Expand All @@ -64,30 +54,28 @@ layout: example.hbs

<script>
//render
function showItem(item){
function showItem(data){
var tmpl = document.getElementById("school-detail-template").innerHTML;
compiled = _.template(tmpl);

document.getElementById('details').innerHTML = compiled(item.datum.data.attributes);
document.getElementById('details').innerHTML = compiled(data);
}
function report(data){
console.log('caught event ' + data);
}


var cb = function(err, chart){
chart.on('mouseover', function(evt, item){
console.log('mouseover ' + evt.currentTarget);

});
chart.on('mouseout', function(evt, item){
console.log('mouseout');

});
chart.on('click', function(evt, item){
console.log('click');
showItem(item);
});
};

Cedar.show({
var chart = new Cedar();
//attach handlers before the view exists
chart.on('mouseover', report);

chart.show({
elementId: "#chart",
spec: "{{assets}}data/charts/evt-scatter-chart.json"
}, cb);
});
//and after
chart.on('mouseout', report);
chart.on('click', showItem);


</script>
10 changes: 6 additions & 4 deletions site/source/pages/examples/simple-bar.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ layout: example.hbs
{{#markdown}}
```html
{{>example-code-header}}
//render
Cedar.show({

var cedar = new Cedar();
cedar.show({
elementId: "#chart",
spec: "/data/charts/simple-pie-chart.json"
spec: "{{assets}}data/charts/simple-bar-chart.json"
});

{{>example-code-footer}}
Expand All @@ -25,7 +26,8 @@ layout: example.hbs

<script>
//render
Cedar.show({
var cedar = new Cedar();
cedar.show({
elementId: "#chart",
spec: "{{assets}}data/charts/simple-bar-chart.json"
});
Expand Down
11 changes: 6 additions & 5 deletions site/source/pages/examples/simple-pie.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ layout: example.hbs
{{#markdown}}
```html
{{>example-code-header}}
//render
Cedar.show({
var cedar = new Cedar();
cedar.show({
elementId: "#chart",
spec: "/data/charts/simple-pie-chart.json"
spec: "{{assets}}data/charts/simple-pie-chart.json"
});

{{>example-code-footer}}
Expand All @@ -24,8 +24,9 @@ layout: example.hbs


<script>
//render
Cedar.show({

var cedar = new Cedar();
cedar.show({
elementId: "#chart",
spec: "{{assets}}data/charts/simple-pie-chart.json"
});
Expand Down
11 changes: 5 additions & 6 deletions site/source/pages/examples/simple-scatter.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ layout: example.hbs
{{#markdown}}
```html
{{>example-code-header}}
//render
Cedar.show({
var cedar = new Cedar();
cedar.show({
elementId: "#chart",
spec: "/data/charts/scatter-chart.json"
spec: "{{assets}}data/charts/simple-scatter-chart.json"
});

{{>example-code-footer}}
Expand All @@ -24,9 +24,8 @@ layout: example.hbs


<script>

//render
Cedar.show({
var cedar = new Cedar();
cedar.show({
elementId: "#chart",
spec: "{{assets}}data/charts/simple-scatter-chart.json"
});
Expand Down
17 changes: 11 additions & 6 deletions site/source/pages/examples/template-from-url.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,31 @@ layout: example.hbs
{{#markdown}}
```html
{{>example-code-header}}
var cedar = new Cedar();

var fieldMappings = {
"x": "POPULATION_ENROLLED_2008",
"y": "SQUARE_FOOTAGE",
"color":"FACUSE"
}
var serviceUrl = "http://maps2.dcgis.dc.gov/dcgis/rest/services/DCGIS_DATA/Education_WebMercator/MapServer/5"
var tmplUrl = "/data/templates/scatter-template.json";
var tmplUrl = "{{assets}}data/templates/scatter-template.json";

Cedar.getJson(tmplUrl, function(err,template){
if(err){
console.error(err);
return;
}
//cook the spec
var chartJson = Cedar.create(template, serviceUrl, fieldMappings);
var chartJson = cedar.create(template, serviceUrl, fieldMappings);
console.info()
var opts = {
elementId: "#chart",
spec: chartJson
};

//render
Cedar.show( opts );
cedar.show( opts );

});
{{>example-code-footer}}
Expand All @@ -40,7 +43,8 @@ layout: example.hbs



<script>
<script>
var cedar = new Cedar();

var fieldMappings = {
"x": "POPULATION_ENROLLED_2008",
Expand All @@ -49,21 +53,22 @@ layout: example.hbs
}
var serviceUrl = "http://maps2.dcgis.dc.gov/dcgis/rest/services/DCGIS_DATA/Education_WebMercator/MapServer/5"
var tmplUrl = "{{assets}}data/templates/scatter-template.json";

Cedar.getJson(tmplUrl, function(err,template){
if(err){
console.error(err);
return;
}
//cook the spec
var chartJson = Cedar.create(template, serviceUrl, fieldMappings);
var chartJson = cedar.create(template, serviceUrl, fieldMappings);
console.info()
var opts = {
elementId: "#chart",
spec: chartJson
};

//render
Cedar.show( opts );
cedar.show( opts );

});

Expand Down
4 changes: 3 additions & 1 deletion site/source/pages/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ layout: page.hbs


<script>
Cedar.show({

var cedar = new Cedar();
cedar.show({
elementId: "#chart",
spec: "{{assets}}data/charts/home-scatter-chart.json"
});
Expand Down
Loading