|
214 | 214 | </div> |
215 | 215 | </Preview> |
216 | 216 |
|
| 217 | +<h2>Multiple series (using overrides)</h2> |
| 218 | + |
| 219 | +<Preview data={multiSeriesFlatData}> |
| 220 | + <div class="h-[300px] p-4 border rounded"> |
| 221 | + <Chart |
| 222 | + data={multiSeriesData} |
| 223 | + x="date" |
| 224 | + y={['apples', 'bananas', 'oranges']} |
| 225 | + yDomain={[0, null]} |
| 226 | + yNice |
| 227 | + padding={{ left: 16, bottom: 24, right: 48 }} |
| 228 | + tooltip={{ mode: 'bisect-x' }} |
| 229 | + > |
| 230 | + <Svg> |
| 231 | + <Axis placement="left" grid rule /> |
| 232 | + <Axis |
| 233 | + placement="bottom" |
| 234 | + format={(d) => format(d, PeriodType.Day, { variant: 'short' })} |
| 235 | + rule |
| 236 | + /> |
| 237 | + |
| 238 | + <Area |
| 239 | + y1={(d) => d.apples} |
| 240 | + class="stroke-2" |
| 241 | + fill={fruitColors.apples} |
| 242 | + fill-opacity={0.3} |
| 243 | + line={{ stroke: fruitColors.apples, class: 'stroke-2' }} |
| 244 | + /> |
| 245 | + <Area |
| 246 | + y1={(d) => d.bananas} |
| 247 | + class="stroke-2" |
| 248 | + fill={fruitColors.bananas} |
| 249 | + fill-opacity={0.3} |
| 250 | + line={{ stroke: fruitColors.bananas, class: 'stroke-2' }} |
| 251 | + /> |
| 252 | + <Area |
| 253 | + y1={(d) => d.oranges} |
| 254 | + class="stroke-2" |
| 255 | + fill={fruitColors.oranges} |
| 256 | + fill-opacity={0.3} |
| 257 | + line={{ stroke: fruitColors.oranges, class: 'stroke-2' }} |
| 258 | + /> |
| 259 | + <!-- TODO: Fix points with y array --> |
| 260 | + <Highlight lines /> |
| 261 | + </Svg> |
| 262 | + <Tooltip header={(data) => formatDate(data.date, 'eee, MMMM do')} let:data> |
| 263 | + <TooltipItem label="apples" value={data.apples} /> |
| 264 | + <TooltipItem label="bananas" value={data.bananas} /> |
| 265 | + <TooltipItem label="oranges" value={data.oranges} /> |
| 266 | + </Tooltip> |
| 267 | + </Chart> |
| 268 | + </div> |
| 269 | +</Preview> |
| 270 | + |
217 | 271 | <h2>Multiple series (highlight on hover)</h2> |
218 | 272 |
|
219 | 273 | <Preview data={multiSeriesFlatData}> |
|
0 commit comments