caelum0x 2b68bde5d5 Predikt: full Polymarket-style prediction market — web + mobile + on-chain + bots
Working tree is now the canonical repo. Off-chain play-money + trustless on-chain
(FPMM AMM + CLOB via UMA settlement), AI market factory, creator/social/distribution,
mobile shell + push, one-command demo + deploy-kit. Secrets excluded (see ENV-AND-KEYS.md).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-06 23:29:50 +03:00

85 lines
2.1 KiB
TypeScript

import { axisBottom, axisRight } from 'd3-axis'
import { scaleLinear } from 'd3-scale'
import { range } from 'lodash'
import { SVGChart, formatPct } from './helpers'
type Point = { x: number; y: number }
// Calibration bucket points
const CALIBRATION_POINTS = [1, 3, 5, ...range(10, 100, 10), 95, 97, 99]
export function CalibrationChart(props: {
yesPoints: Point[]
noPoints: Point[]
width: number
height: number
}) {
const { yesPoints, noPoints, width, height } = props
const xScale = scaleLinear().domain([0, 1]).range([0, width])
const yScale = scaleLinear().domain([0, 1]).range([height, 0])
const tickVals = CALIBRATION_POINTS.map((p) => p / 100)
const format = (d: number) =>
(d <= 0.9 || d === 0.99) && (d >= 0.1 || d === 0.01) ? formatPct(d) : ''
const xAxis = axisBottom<number>(xScale)
.tickFormat(format)
.tickValues(tickVals)
const yAxis = axisRight<number>(yScale)
.tickFormat(format)
.tickValues(tickVals)
const px = (p: Point) => xScale(p.x)
const py = (p: Point) => yScale(p.y)
return (
<SVGChart w={width} h={height} xAxis={xAxis} yAxis={yAxis} noGridlines>
{/* diagonal line x = y */}
<line
x1={xScale(0)}
y1={yScale(0)}
x2={xScale(1)}
y2={yScale(1)}
stroke="rgb(99 102 241)"
strokeWidth={1.5}
strokeDasharray="4 8"
/>
{/* points */}
{noPoints.map((p, i) => (
// triangle pointing down (red points)
<polygon
key={i}
points={`
${px(p)},${py(p) + 6}
${px(p) - 3 * V3},${py(p) - 3}
${px(p) + 3 * V3},${py(p) - 3}`}
fill="#ef4444"
stroke="#b91c1c"
strokeWidth={0.5}
/>
))}
{yesPoints.map((p, i) => (
// triangle pointing up (green points)
<polygon
key={i}
points={`
${px(p)},${py(p) - 6}
${px(p) - 3 * V3},${py(p) + 3}
${px(p) + 3 * V3},${py(p) + 3}`}
fill="#10b981"
stroke="#047857"
strokeWidth={0.5}
/>
))}
</SVGChart>
)
}
// √3
const V3 = Math.sqrt(3)