Post Reply 
 
Thread Rating:
  • 217 Votes - 2.73 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Page 6: Structure of a Program that Specifies the Graph Colors
06-20-2011, 01:08 PM (This post was last modified: 06-23-2011 04:19 PM by ashimo.)
Post: #1
Page 6: Structure of a Program that Specifies the Graph Colors
Structure of the program that specifies the graph colors



Graph colors are specified with an array. First, therefore, we should explain an array.

An array consists of a group of elements that are arranged into an order. Each element has a corresponding index, beginning from 0. Array-of is one kind of array; the data type of the elements in the array is specified when the array is declared. As the data type, we can specify primitive types such as int and char, as well as class types such as String.


In Curl, we can create an array by coding the following.



Creating an Array

Code:
{{Array-of element_type} element_1, element_2, element_3, …}



For example, we would code a character string array with three elements as follows:

Code:
{{Array-of String} “ character string 1”, “character string 2”, “character string 3”}

To declare array variables, we code the following:

Code:
let array_variable_name:{Array-of element type} =
    {{Array-of data type} element_1, element_2, element_3, …}

For example, the following declaration specifies a variable called “array” which is bound to an array having three character string elements:

Code:
let array:{Array-of String} =
    {{Array-of String} “ character string 1”, “character string 2”, “character string 3”}

When we create an array in Curl, we specify the element type. There is no need to specify the size of the array in advance. The number of elements can change later.

Also, using array_name[index] syntax, we can access elements from the array. For example, to access “character string 2” whose index is 1, we specify array[1].



1. Array variable declaration

Code:
let color-array:{Array-of FillPattern} =
    {{Array-of FillPattern} orange, pink}

Graph colors are specified with a FillPattern array. FillPattern is used to specify how an object is colored. Monochrome shades can also be specified using a string.

2. Specifying the graph color

Code:
color-palette = color-array,

We can use the color-palette option of LayeredChart to specify the color of a graph. Here, we specify the array that we created in (1).
Find all posts by this user
Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Page 5: Application 2: Specifying the Graph Colors ashimo 1 3,859 11-19-2016 01:59 PM
Last Post: milijacob
  Page 8: Extra Practice ashimo 0 3,012 06-20-2011 01:10 PM
Last Post: ashimo
  Page 7: Summary ashimo 0 2,691 06-20-2011 01:09 PM
Last Post: ashimo
  Page 4: Structure of a Program that Specifies the Graph Axes ashimo 0 2,931 06-20-2011 01:06 PM
Last Post: ashimo
  Page 3: Application 1: Specifying the Graph Axes ashimo 0 2,837 06-20-2011 01:05 PM
Last Post: ashimo
  Page 2: Structure of a Program that Displays Data as a Graph ashimo 0 2,749 06-20-2011 01:03 PM
Last Post: ashimo
  Page 1: Displaying Data as a Graph ashimo 0 2,592 06-20-2011 11:59 AM
Last Post: ashimo
Forum Jump:


User(s) browsing this thread:
1 Guest(s)