"""
Parallel Coordinates Example
----------------------------
A `Parallel Coordinates <https://en.wikipedia.org/wiki/Parallel_coordinates>`_
chart is a chart that lets you visualize the individual data points by drawing
a single line for each of them.
Such a chart can be created in Altair, but requires some data preprocessing
to transform the data into a suitable representation.
This example shows a parallel coordinates chart with the Iris dataset.
"""
# category: other charts

import altair as alt
from vega_datasets import data

source = data.iris()
source_transformed = source.reset_index().melt(['species', 'index'])

alt.Chart(source_transformed).mark_line().encode(
    x='variable:N',
    y='value:Q',
    color='species:N',
    detail='index:N',
    opacity=alt.value(0.5)
).properties(width=500)

@@ -286,49 +286,17 @@
 tair
-,
  b
-ut requires some data preprocessing%0Ato
+y first
  tra
@@ -301,16 +301,19 @@
 ransform
+ing
  the dat
@@ -320,17 +320,17 @@
 a into a
- 
+%0A
 suitable
@@ -521,23 +521,35 @@
 .iris()%0A
+%0Aalt.Chart(
 source
-_
+).
 transfor
@@ -553,90 +553,120 @@
 form
-ed = source.reset_index().melt(
+_window(%0A    index='count()'  %0A).transform_fold(%0A    
 %5B'
-s
 pe
-cies', 'index'%5D)%0A%0Aalt.Chart(source_transformed
+talLength', 'petalWidth', 'sepalLength', 'sepalWidth'%5D%0A
 ).ma
@@ -694,16 +694,11 @@
  x='
-variable
+key
 :N',

update parallel coordinates chart