'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _objectDestructuringEmpty2 = require('babel-runtime/helpers/objectDestructuringEmpty');

var _objectDestructuringEmpty3 = _interopRequireDefault(_objectDestructuringEmpty2);

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _Codeblock = require('./Codeblock');

var _Codeblock2 = _interopRequireDefault(_Codeblock);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var _jsxFileName = '/Users/hshoff/code/vx/packages/vx-demo/components/codeblocks/SimpleLineCode.js';

exports.default = function (_ref) {
  (0, _objectDestructuringEmpty3.default)(_ref);

  return _react2.default.createElement(_Codeblock2.default, {
    __source: {
      fileName: _jsxFileName,
      lineNumber: 6
    }
  }, '// SimpleLineChart.js\nfunction SimpleLineChart({\n  margin,\n  dataset,\n  screenWidth,\n  screenHeight,\n}) {\n  if (!Array.isArray(dataset)) dataset = [dataset];\n\n  const width = screenWidth / 1.5;\n  const height = width / 2;\n\n  const allData = dataset.reduce((ret, d) => {\n    return ret.concat(d.data)\n  }, []);\n\n  // bounds\n  const xMax = width - margin.left - margin.right;\n  const yMax = height - margin.top - margin.bottom;\n\n  // accessors\n  const x = d => d.date;\n  const y = d => d.value;\n\n  // scales\n  const xScale = Scale.scaleTime({\n    range: [0, xMax],\n    domain: extent(allData, x),\n    nice: true,\n  });\n  const yScale = Scale.scaleLinear({\n    range: [yMax, 0],\n    domain: [0, max(allData, y)],\n    nice: true,\n  });\n\n  const yFormat = yScale.tickFormat ? yScale.tickFormat() : identity;\n  const xFormat = xScale.tickFormat ? xScale.tickFormat() : identity;\n\n  const markerDatum = allData[3];\n  const markerLabel = \'Deploy\';\n  const markerFrom = new Point({\n    x: xScale(x(markerDatum)),\n    y: 0,\n  });\n  const markerTo = new Point({\n    x: xScale(x(markerDatum)),\n    y: yMax,\n  });\n\n  const annotationPoint = new Point({\n    x: xScale(x(markerDatum)),\n    y: yScale(y(markerDatum)),\n  });\n\n  return (\n    <svg width={width} height={height}>\n      <defs>\n        <linearGradient\n          id="linear" x1="0%" y1="0%" x2="100%" y2="0%"\n        >\n          <stop offset="0%"   stopColor="#f101f6"/>\n          <stop offset="100%" stopColor="#01d4f9"/>\n        </linearGradient>\n        <linearGradient\n          id="linearFade" x1="0%" y1="0%" x2="100%" y2="0%"\n        >\n          <stop offset="0%"   stopColor="#f101f6" stopOpacity="0.3"/>\n          <stop offset="100%" stopColor="#01d4f9" stopOpacity="0.3"/>\n        </linearGradient>\n      </defs>\n      <Axis.AxisLeft\n        top={margin.top}\n        left={margin.left}\n        scale={yScale}\n        hideZero\n        numTicks={numTicksForHeight(height)}\n        label={\'value\'}\n        stroke={\'#1b1a1e\'}\n        tickTextFill={\'#fff\'}\n      />\n      <Group\n        top={margin.top}\n        left={margin.left}\n      >\n        <Grid.Grid\n          xScale={xScale}\n          yScale={yScale}\n          width={xMax}\n          height={yMax}\n          numTicksRows={numTicksForHeight(height)}\n          numTicksColumns={numTicksForWidth(width)}\n          stroke={\'#1b1a1e\'}\n          tickStroke={\'#1b1a1e\'}\n        />\n\n        <Shape.AreaClosed\n          data={dataset[0].data}\n          xScale={xScale}\n          yScale={yScale}\n          x={x}\n          y={y}\n          strokeWidth={2}\n          stroke={"url(\'#linear\')"}\n          fill={"url(\'#linearFade\')"}\n        />\n\n        <Shape.LinePath\n          data={dataset[1].data}\n          xScale={xScale}\n          yScale={yScale}\n          x={x}\n          y={y}\n          stroke={"url(\'#linearFade\')"}\n          strokeWidth={2}\n        />\n\n        <Marker\n          from={markerFrom}\n          to={markerTo}\n          stroke={\'white\'}\n          label={markerLabel}\n          labelStroke={\'none\'}\n          labelDx={6}\n          labelDy={15}\n        />\n        <Annotation.LinePathAnnotation\n          label={\'expected from deploy\'}\n          stroke={\'white\'}\n          labelFill={\'white\'}\n          labelStroke={\'none\'}\n          labelStrokeWidth={2}\n          points={[\n            annotationPoint,\n            new Point({\n              x: annotationPoint.x + (width / allData.length),\n              y: annotationPoint.y - (height / allData.length),\n            })\n          ]}\n        />\n      </Group>\n      <Axis.AxisBottom\n        top={height - margin.bottom}\n        left={margin.left}\n        scale={xScale}\n        numTicks={numTicksForWidth(width)}\n        label={\'time\'}\n        stroke={\'#1b1a1e\'}\n        tickStroke={\'#1b1a1e\'}\n        tickTextFill={\'#fff\'}\n      />\n    </svg>\n  );\n}\n\nexport default Responsive.withScreenSize(SimpleLineChart);');
};