Hexastack / eazychart

EazyChart is a reactive chart library 📈, it allows you to easily add SVG charts in your React and Vue web applications.
https://eazychart.com
MIT License
23 stars 14 forks source link

fix: line-column-chart centred points (vue) #60

Closed yassinedorbozgithub closed 2 years ago

yassinedorbozgithub commented 2 years ago

Motivation

This PR fixes the LineColumnChart to have centred points (Vue).

Fixes #43

Type of change

Please delete options that are not relevant.

Checklist:

marrouchi commented 2 years ago

@yassinedorbozgithub There's a simpler solution for this after the refactoring i've made. You could alter the x coordinate in shapeDatum, in LineColumnChart recipe you do the following :

    <Points
          xDomainKey={xAxis.domainKey}
          yDomainKey={yLineAxis.domainKey}
          scopedSlots={{
            default: ({ shapeData, scales: { xScale } }) => {
              const bandwidth = xScale.scale.bandwith();
              const centeredShapeData = shapeData.map((shapeDatum) => ({ ...shapeDatum, x: shapeDatum.x + bandwidth / 2 }))
              return (
                <g className="ez-line">
                  <LinePath
                    shapeData={centeredShapeData}
                    curve={line.curve}
                    beta={line.beta}
                    stroke={line.stroke}
                    strokeWidth={line.strokeWidth}
                  />
                  {!marker.hidden &&
                    centeredShapeData.map((pointDatum) => {
                      return (
                        <Point
                          key={pointDatum.id}
                          shapeDatum={pointDatum}
                          r={marker.radius}
                          stroke={marker.color}
                          fill={marker.color}
                          strokeWidth={line.strokeWidth}
                        />
                      );
                    })}
                </g>
              );
            },
          }}
        />
marrouchi commented 2 years ago

I suggest we close this PR since there's a lot of conflicts due to the changes I've made. (sorry)

So let's open a new one :)