Widgets > Chart Widgets > wijbarchart > wijbarchart Tutorial > wijbarchart Step 2 of 3: Initializing the Widget |
In the previous step, you added markup to add the content that will appear in the bar chart. Now you can add the jQuery script to initialize the widget as well as set the text of the X and Y axes, add a tooltip to the chart labels, add a chart header called, “Hardware Distribution”, and use the seriesList to create three data series with string data for the X-Axis and numerical data for the Y-Axis.
After the closing </div>
tags you added in the previous step, enter the following jQuery script to initialize the wijbarchart widget:
<script id="scriptInit" type="text/javascript">
$(document).ready(function () {
$("#wijbarchart").wijbarchart({
axis: {
y: {
text: "Total Hardware"
},
x: {
text: ""
}
},
hint: {
content: function () {
return this.data.label + '<br/> ' + this.y + '';
}
},
header: {
text: "Hardware Distribution"
},
seriesList: [{
label: "West",
legendEntry: true,
data: { x: ['Desktops', 'Notebooks', 'AIO', 'Tablets', 'Phones'], y: [5, 3, 4, 7, 2] }
}, {
label: "Central",
legendEntry: true,
data: { x: ['Desktops', 'Notebooks', 'AIO', 'Tablets', 'Phones'], y: [2, 2, 3, 2, 1] }
}, {
label: "East",
legendEntry: true,
data: { x: ['Desktops', 'Notebooks', 'AIO', 'Tablets', 'Phones'], y: [3, 4, 4, 2, 5] }
}]
});
});
</script>