W3Image: Demos
W3Image Chart Pack
->
LineChart demos
Line Chart - Demo
A very static LineChart.
Source code
All code for the LineChart is written in Jscript, and it relies on four include files. These are included in the package, and you are free to modify them for personal use.
<%@LANGUAGE="JScript">
// Include the LineDiagram script library.
<!--#include file="LineDiagram.asp"-->
<%
// Create a new LineDiagram
var diagramObj = new LineDiagram();
diagramObj.CreateBackground(500, 300, 0xC9F0FF)
// Settings for the x-scale
diagramObj.xScale.label = "Month";
diagramObj.xScale.SetPosition(100, 180, 260);
diagramObj.xScale.SetLabelFont("Arial", 12, "normal", 0x000000, true, false, 0);
diagramObj.xScale.SetValueFont("Arial", 12, "normal", 0x000000, true, false, 0);
diagramObj.xScale.minValue = 0;
diagramObj.xScale.maxValue = 12;
diagramObj.xScale.stepSize = 1;
diagramObj.xScale.lineColor = 0x000000;
diagramObj.xScale.lineSize = 1;
diagramObj.xScale.showGrid = true;
// Settings for the y-scale
diagramObj.yScale.label = "Sales (million units)";
diagramObj.yScale.SetPosition(100, 180, 150);
diagramObj.yScale.SetLabelFont("Arial", 13, "bold", 0x000000, true, false, 0);
diagramObj.yScale.SetValueFont("Arial", 12, "normal", 0x000000, true, false, 0);
diagramObj.yScale.minValue = 0;
diagramObj.yScale.maxValue = 10;
diagramObj.yScale.stepSize = 2;
diagramObj.yScale.lineColor = 0x000000;
diagramObj.yScale.lineSize = 1;
diagramObj.yScale.showGrid = true;
var graph1 = new LDGraph();
graph1.label = "Bad Trend";
graph1.lineColor = 0xff0000;
graph1.lineSize = 1;
graph1.showLabel = true;
var graph2 = new LDGraph();
graph2.label = "Positive Trend";
graph2.lineColor = 0x0000FF;
graph2.lineSize = 1;
graph2.showLabel = true;
graph1.AddPoint(1,8);
graph1.AddPoint(2,5);
graph1.AddPoint(6,7);
graph1.AddPoint(10,6);
graph1.AddPoint(11,5);
graph1.AddPoint(12,0);
graph2.AddPoint(1,2);
graph2.AddPoint(2,6);
graph2.AddPoint(3,6);
graph2.AddPoint(5,6);
graph2.AddPoint(6,7);
graph2.AddPoint(8,8);
graph2.AddPoint(10,8);
graph2.AddPoint(11,7);
graph2.AddPoint(12,8);
// Add the graphs
diagramObj.graphs.push(graph1);
diagramObj.graphs.push(graph2);
// Set the value
diagramObj.graphInfo.startXPos = 370;
diagramObj.graphInfo.startYPos = 20;
diagramObj.graphInfo.boxWidth = 15;
diagramObj.graphInfo.boxHeight = 10;
diagramObj.graphInfo.boxSpacing = 5;
diagramObj.graphInfo.lineColor = 0x000000;
diagramObj.graphInfo.SetLabelFont("Tahoma", 12, "normal", 0x000000, true, false);
// Draw the diagram
diagramObj.DrawDiagram();
%>