private void Draw()
        {
            StringBuilder sb = new StringBuilder();

            byte[][] defaultColourScheme;
            int      nClassesValue = 3;
            string   colourSchemeComboBoxSelection = colourSchemeComboBox.SelectedValue.ToString();

            if (!_datasetModel.IsColourQualitative)
            {
                ComboBoxItem nClassesComboBoxSelection = (ComboBoxItem)numDataClassesComboBox.SelectedValue;
                nClassesValue       = int.Parse(nClassesComboBoxSelection.Content.ToString());
                defaultColourScheme = _colourScheme.GetRGBColours(colourSchemeComboBoxSelection, nClassesValue);
            }
            else
            {
                _distinctCategories = _datasetModel.Dataset.Select(o => o[_colourValueIndex]).Distinct().ToList();
                nClassesValue       = _distinctCategories.Count();
                defaultColourScheme = _colourScheme.GetRGBColours(colourSchemeComboBoxSelection, nClassesValue);
            }

            foreach (string[] row in _datasetModel.Dataset)
            {
                ParallelCoordsPolyline line = new ParallelCoordsPolyline();
                line.ColourValue = row[_colourValueIndex];
                sb.AppendLine(row[_idIndex]);

                // Apply line colour
                if (_datasetModel.IsColourQualitative)
                {
                    int index = _distinctCategories.IndexOf(row[_colourValueIndex]);
                    line.LineColour = defaultColourScheme[index];
                }
                else
                {
                    double colourValue     = double.Parse(row[_colourValueIndex]);
                    double linearTransform = (colourValue - _datasetModel.ColourMinMax[0]) /
                                             (_datasetModel.ColourMinMax[1] - _datasetModel.ColourMinMax[0]) * (nClassesValue - 1);
                    int colourIndex = (int)Math.Truncate(linearTransform);
                    line.LineColour = defaultColourScheme[colourIndex];
                }

                PointCollection points     = new PointCollection();
                double[]        dataValues = new double[_axesIndexes.Length];

                for (int i = 0; i < _axesIndexes.Length; i++)
                {
                    // get value for the axis
                    double val = double.Parse(row[_axesIndexes[i]]);
                    dataValues[i] = val;

                    // get max/min values for the axis
                    string   axisTitle = _datasetModel.ColumnHeadings[_axesIndexes[i]];
                    double[] minMax    = _datasetModel.GetAxisMinMaxValues(axisTitle);

                    // get normalised value (between 0 and 1) and multiply
                    // by screen height to convert it into a screen coordinate
                    double yCoord = NormaliseValue(val, minMax[1], minMax[0]) * _canvasHeight;
                    double xCoord = _xSeparation * i;

                    points.Add(new Point(xCoord, yCoord));

                    sb.Append(_datasetModel.ColumnHeadings[_axesIndexes[i]]);
                    sb.Append(": ");
                    sb.AppendLine(val.ToString());
                }

                // colour value tooltip text
                // check to see if the colour value is already an axis
                if (Array.IndexOf(this.Axes, this.ColourValue) < 0)
                {
                    // colour value is not an axis, add to the tooltip text
                    sb.Append(_datasetModel.ColumnHeadings[_colourValueIndex]);
                    sb.Append(": ");
                    sb.Append(row[_colourValueIndex]);
                }

                line.Details = sb.ToString();
                sb.Clear();

                line.PolylinePoints = points;
                line.DataValues     = dataValues;
                _polylines.Add(line);
                canvas.Children.Add(line);
            }

            // Assign event handlers at the end so events are not fired during initialisation
            numDataClassesComboBox.SelectionChanged   += numDataClassesComboBox_SelectionChanged;
            colourSchemeTypeComboBox.SelectionChanged += colourSchemeTypeComboBox_SelectionChanged;
            colourSchemeComboBox.SelectionChanged     += colourSchemeComboBox_SelectionChanged;
        }
        private void Draw()
        {
            StringBuilder sb = new StringBuilder();
            byte[][] defaultColourScheme;
            int nClassesValue = 3;
            string colourSchemeComboBoxSelection = colourSchemeComboBox.SelectedValue.ToString();

            if (!_datasetModel.IsColourQualitative)
            {
                ComboBoxItem nClassesComboBoxSelection = (ComboBoxItem)numDataClassesComboBox.SelectedValue;
                nClassesValue = int.Parse(nClassesComboBoxSelection.Content.ToString());
                defaultColourScheme = _colourScheme.GetRGBColours(colourSchemeComboBoxSelection, nClassesValue);
            }
            else
            {
                _distinctCategories = _datasetModel.Dataset.Select(o => o[_colourValueIndex]).Distinct().ToList();
                nClassesValue = _distinctCategories.Count();
                defaultColourScheme = _colourScheme.GetRGBColours(colourSchemeComboBoxSelection, nClassesValue);
            }

            foreach (string[] row in _datasetModel.Dataset)
            {
                ParallelCoordsPolyline line = new ParallelCoordsPolyline();
                line.ColourValue = row[_colourValueIndex];
                sb.AppendLine(row[_idIndex]);

                // Apply line colour
                if (_datasetModel.IsColourQualitative)
                {
                    int index = _distinctCategories.IndexOf(row[_colourValueIndex]);
                    line.LineColour = defaultColourScheme[index];
                }
                else
                {
                    double colourValue = double.Parse(row[_colourValueIndex]);
                    double linearTransform = (colourValue - _datasetModel.ColourMinMax[0]) /
                        (_datasetModel.ColourMinMax[1] - _datasetModel.ColourMinMax[0]) * (nClassesValue - 1);
                    int colourIndex = (int)Math.Truncate(linearTransform);
                    line.LineColour = defaultColourScheme[colourIndex];
                }

                PointCollection points = new PointCollection();
                double[] dataValues = new double[_axesIndexes.Length];
                
                for (int i = 0; i < _axesIndexes.Length; i++)
                {
                    // get value for the axis
                    double val = double.Parse(row[_axesIndexes[i]]);
                    dataValues[i] = val;

                    // get max/min values for the axis
                    string axisTitle = _datasetModel.ColumnHeadings[_axesIndexes[i]];
                    double[] minMax = _datasetModel.GetAxisMinMaxValues(axisTitle);

                    // get normalised value (between 0 and 1) and multiply
                    // by screen height to convert it into a screen coordinate
                    double yCoord = NormaliseValue(val, minMax[1], minMax[0]) * _canvasHeight;
                    double xCoord = _xSeparation * i;

                    points.Add(new Point(xCoord, yCoord));

                    sb.Append(_datasetModel.ColumnHeadings[_axesIndexes[i]]);
                    sb.Append(": ");
                    sb.AppendLine(val.ToString());
                }

                // colour value tooltip text
                // check to see if the colour value is already an axis
                if (Array.IndexOf(this.Axes, this.ColourValue) < 0)
                {
                    // colour value is not an axis, add to the tooltip text
                    sb.Append(_datasetModel.ColumnHeadings[_colourValueIndex]);
                    sb.Append(": ");
                    sb.Append(row[_colourValueIndex]);
                }

                line.Details = sb.ToString();
                sb.Clear();

                line.PolylinePoints = points;
                line.DataValues = dataValues;
                _polylines.Add(line);
                canvas.Children.Add(line);
            }

            // Assign event handlers at the end so events are not fired during initialisation
            numDataClassesComboBox.SelectionChanged += numDataClassesComboBox_SelectionChanged;
            colourSchemeTypeComboBox.SelectionChanged += colourSchemeTypeComboBox_SelectionChanged;
            colourSchemeComboBox.SelectionChanged += colourSchemeComboBox_SelectionChanged;
        }