# category: line charts

import altair as alt

source = alt.sequence(start=0, stop=12.7, step=0.1, as_='x')

alt.Chart(source).mark_line().transform_calculate(
    sin='sin(datum.x)'
).transform_calculate(
    cos='cos(datum.x)'
).transform_fold(
    ['sin', 'cos']
).encode(
    x='x:Q', 
    y='value:Q', 
    color='key:N'
)

# category: line charts

import altair as alt

source = alt.sequence(start=0, stop=12.7, step=0.1, as_='x')

alt.Chart(source).mark_line().transform_calculate(
    sin='sin(datum.x)',
    cos='cos(datum.x)'
).transform_fold(
    ['sin', 'cos']
).encode(
    x='x:Q', 
    y='value:Q', 
    color='key:N'
)

Modify generator example to use single calculation transform
DOC: Modify generator example to use single calculation transform

  # category: line charts
  
  import altair as alt
  
  source = alt.sequence(start=0, stop=12.7, step=0.1, as_='x')
  
  alt.Chart(source).mark_line().transform_calculate(
-     sin='sin(datum.x)'
+     sin='sin(datum.x)',
- ).transform_calculate(
      cos='cos(datum.x)'
  ).transform_fold(
      ['sin', 'cos']
  ).encode(
      x='x:Q', 
      y='value:Q', 
      color='key:N'
  )
  
Modify generator example to use single calculation transform
## Code Before:
# category: line charts

import altair as alt

source = alt.sequence(start=0, stop=12.7, step=0.1, as_='x')

alt.Chart(source).mark_line().transform_calculate(
    sin='sin(datum.x)'
).transform_calculate(
    cos='cos(datum.x)'
).transform_fold(
    ['sin', 'cos']
).encode(
    x='x:Q', 
    y='value:Q', 
    color='key:N'
)

## Instruction:
Modify generator example to use single calculation transform
## Code After:
# category: line charts

import altair as alt

source = alt.sequence(start=0, stop=12.7, step=0.1, as_='x')

alt.Chart(source).mark_line().transform_calculate(
    sin='sin(datum.x)',
    cos='cos(datum.x)'
).transform_fold(
    ['sin', 'cos']
).encode(
    x='x:Q', 
    y='value:Q', 
    color='key:N'
)
